流浪分享 - 访问虚拟主机和访问那些不在默认Web根 [英] Vagrant Share - Accessing Virtual Hosts and accessing those that are not in the default web root

查看:149
本文介绍了流浪分享 - 访问虚拟主机和访问那些不在默认Web根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有流浪的设置和运行的CentOS 6.5 x64和它运行很好。没有问题,运行此一台虚拟机内多个站点。所有的网站都在 /无功/网络/公共文件夹phpMyAdmin的除外从的/ var / www / html等运行运行。我试图使用流浪汉份额即可访问所有正在运行的虚拟主机站点。问题是,流浪汉份额只显示在的/ var / www / html等文件夹中的内容。

I have Vagrant setup and running CentOS 6.5 x64 and it runs great. No issues running multiple sites within this one VM. All sites are running from the /var/www/public folder with the exception of PhpMyAdmin which runs from /var/www/html. I am trying to use vagrant share to gain access to any of the vhost sites that are running. The problem is that vagrant share is only displaying the contents of the /var/www/html folder.

有什么进一步的,我需要,以获得我的新创建 /无功/网络/公共文件夹的访问呢?我曾尝试编辑hosts文件,另一台机器上,看看我是否能提出任何分配给这些网站目前时髦的无业游民分享地址URL的我,但这行不通。我只是在个人对我下一步应该做什么损失。

Is there something further that I need to do in order to gain access to my newly created /var/www/public folder? I have tried editing the hosts file, on another machine, to see if I can forward any of the url's I assigned to these sites to the current funky 'vagrant share' address but this does not work. I am just personally at a loss for what I should do next.

这是我的基本设置。
流浪1.5.4版,版本的VirtualBox 4.3.8版,Windows 7 64位,由PuPHPet配置文件,但下载后高度定制的虚拟主机添加,SSH配置,MySQL和bash的文件。

This is my basic setup. Vagrant version 1.5.4, VirtualBox version 4.3.8, Windows 7 x64, Config file by PuPHPet but highly customized after download for added vhosts, ssh config, mysql, and bash files.

希望别人可能也会遇到这个问题。有没有人有一个很好的方向,我可以走呢?

Hopefully someone else may have run into this issue as well. Does anyone have a good direction I can turn?

谢谢大家,

c0p

我有我自己的问题显著进展。我在做什么的一点是允许从我的流浪机器进入人的异地。我也不需要他们拥有完全访问所有的时间而只是审查东西,因为他们,并告知我,他们可能需要的任何更改。要知道,标准开发的东西。因此,这里是我想出了。

I have significant headway with my own question. The point of what I'm doing is to allow access to person's offsite from my Vagrant machine. I don't need them to have complete access all of the time but rather just review things as they are and inform me of any changes they may need. You know, standard dev stuff. So here is what I have come up with.

研究一般网络我遇到了这个链接:
<一href=\"https://groups.google.com/forum/#!topic/vagrant-up/IcEl9-V9wsU\">https://groups.google.com/forum/#!topic/vagrant-up/IcEl9-V9wsU

Researching the web in general I ran into this link: https://groups.google.com/forum/#!topic/vagrant-up/IcEl9-V9wsU

这家伙正在运行Nginx的,看起来会问为我同样的问题,但使用不同的网络服务器。如果你正在运行到与Nginx的类似的东西请看看页面。他确实有一个答案在那里。我什么都不知道Nginx的,但依然能推断了一下我所需要的。

This guy is running Nginx and looks to be asking the same question as me but using a different webserver. Please take a look at the page if you are running into something similar with Nginx. He does have an answer there. I know nothing about Nginx but was still able to extrapolate a bit of what I needed.

所以,我从该网站得到的是,一旦他收到了流浪的网站上的链接异常,他迅速编辑了配置文件的Nginx并重新启动Web服务器。现在,疯狂的网址是指向虚拟主机文件的位置,导致他想出现,真正出现,不只是显示默认的欢迎的页面。

So what I got from that page was that once he received the unusual link from the Vagrant site, he quickly edited his config files for Nginx and restarted the webserver. Now, the crazy url was pointing to the virtual hosts file location and causing the page he wanted to appear, to actually appear and not just show the default 'Welcome' page.

我思考了一会儿,决定编辑我自己的配置,看看会发生什么。

I thought about it for a while and decided to edit my own config and see what happens.

我运行CentOS的,所以我编辑了 /etc/httpd/conf/httpd.conf中文件。

I'm running CentOS so I edited the /etc/httpd/conf/httpd.conf file.

有一个评论 #Listen 80 约一半时该文件中的行。紧接着此行(或给它一个空间,如果你想),我说这样的:

There is a commented #Listen 80 line about half way down this file. Immediately following this line (or give it a space if you want), I added this:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin some_dude@home.com
    DocumentRoot /var/www/public/sitename
    ServerName hungry-lovebird-7142.vagrantshare.com
    ServerAlias hungry-lovebird-7142
    ErrorLog /var/www/www.sitename.dev-error_log
    CustomLog /var/www/www.sitename.dev-access_log common
</VirtualHost>

我已经指出了的DocumentRoot我要访问并设置服务器名和ServerAlias​​到流浪汉份额链接网站的文件夹中。然后,我保存的文件并重新启动Apache的是须藤服务的httpd重新启动

I've pointed the DocumentRoot to the folder of the site I want to access and set the ServerName and ServerAlias to the vagrant share link. I then saved the file and restarted Apache with sudo service httpd restart

然后我跳上回火狐(Windows 7)中,并刷新我已经去之前,编辑这个文件的古怪vagrantshare.com页面。它实际上拉起我曾在的httpd.conf 文件给它在站点名称文件夹的内容。因此,它的工作原理!受诅咒的酷!

I then jumped back to Firefox (Windows 7) and refreshed the oddball vagrantshare.com page that I had already gone to prior to editing this file. It actually pulled up the contents of the sitename folder I had given it in the httpd.conf file. So it works! Friggin' cool!

我有这个唯一的问题是,我收到这样的警告重启动Apache时:

The only issue I have with this is that I was receiving this warning when restarting Apache:

Stopping httpd:                                            [  OK  ]
Starting httpd: [Wed May 21 00:11:37 2014] [warn] NameVirtualHost *:80 has no Vi
rtualHosts

阿帕奇将开始得很好,但我不知道做什么用的警告做。后来,我只是删除了了NameVirtualHost *:80 什么我添加并重新启动Apache的部分。这次根本没有警告。

Apache would start just fine but I didn't know what to do with that warning. Later I just removed the NameVirtualHost *:80 portion of what I added and restarted Apache. This time with no warnings at all.

明白这可以让我展现一个客户端更新,只是个别网站。这个工作对静态站点和字preSS站点。我只是改变那里的vagrantshare.com链接一直在寻找的文件。我可以通过编辑的httpd.conf 文件和所有在同一流浪汉份额重启动Apache改为多个网站会话(他们这样做超时)。我使用Windows,所以我不得不混帐的bash (msysgit)的两个副本在同一时间运行。其中托管在流浪汉份额会话和其他后接受编辑的的httpd.conf 流浪汉SSH ING到VM。

Understand that this allows me to show a client updates to an individual site only. This worked for both static sites and for WordPress sites. I just changed where the vagrantshare.com link was looking for files. I was able to change to multiple sites by editing the httpd.conf file and restarting Apache all within the same vagrant share session (they do time-out). I'm using Windows so I had two copies of git-bash(msysgit) running at the same time. One hosting the vagrant share session and the other accepting edits to httpd.conf after vagrant ssh'ing in to the VM.

如果你打算使用了一段字preSS的网站,你还需要编辑 wp_options 表该网站。更改 SITEURL 首页值在请将option_value 列由无业游民分享给你的链接的完整网址。您还可以在管理面板中刚编辑这些值,但我有很多与MySQL快,所以我选择了这条路。

If you are going to be using this for some WordPress site, you will also need to edit the wp_options table for that site. Change the siteurl and home values in the option_value column to the complete url of the link given to you by vagrant share. You may also be able to just edit these values in the Admin Panel but I'm a lot faster with MySql so I chose that route.

耶!太好了。我已经实现了几乎我想要的东西开始。希望有人能解释为什么我做什么实际工作的一些情况。难道我基本上只是该地址进行重定向?

Yay! Ok, great. I have achieved almost what I wanted to begin with. Hopefully someone can shed some light on why what I did actually works. Did I just basically do a redirect for that address?

顺便说一句,当你与完成的流浪汉份额后,不要忘了注释掉那些行(让他们为你可能需要它们更高版本)和重新启动Apache。现在回去与任何客户都想改变工作!

By the way, when you're done with vagrant share, don't forget to comment out those lines (keep them as you'll probably need them later) and restart Apache. Now get back to work with whatever the client wants changed!

无论如何,我希望有人能回答为什么这样做工作的问题剩下的,我真的希望它能帮助沿途的人。

Anyway, I hope someone can answer the 'why did this work' question that remains and I really hope it helps someone along the way.

谢谢,

c0p

推荐答案

通过添加ServerAlias​​更改从动地的WhateverItIs.conf文件:

Change your WhateverItIs.conf file followingly by adding ServerAlias:

ServerName WhateverItIs.com
ServerAlias *.vagrantshare.com 

和现在你是好去。

这篇关于流浪分享 - 访问虚拟主机和访问那些不在默认Web根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆