我使用的是 wamp 2.5 版 我的 Apache 是 2.4.9 PHP:5.5.12 MySQL:5.6.17
我有这些配置:
在我的httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
在我的 G:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhost.conf
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "g:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "g:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "g:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "g:\wamp\www\mysite\public"
ServerName mysite.dev
</VirtualHost>
在我的 c:\Windows\System32\Drivers\etc\hosts
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
127.0.0.1 mysite.dev
# ::1 localhost
我尝试使用此 URL 访问我的项目:http://www.mysite.dev/ 但是我收到一个未找到服务器错误 我尝试使用 www.mysite.dev 、 http://mysite.dev 访问它,但仍然运气不佳!
我的虚拟主机以前可以工作,但我不确定为什么现在不工作了。发生了一些奇怪的事情。
我不确定发生了什么。任何想法将不胜感激!
谢谢!
最佳答案
首先,您需要从 vhost-httpd.conf 文件中删除示例 dummy 定义。它们只是作为示例存在,只是为了让您开始使用语法,不应保留在事件的 conf/extra/httpd-vhosts.conf 中。因为它们指向不存在的文件夹。
因此从文件中删除这两个定义:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "g:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "g:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
第二个 Apache 2.4.x 支持 IPV4 (127.0.0.1) 和 IPV6 (::1),因此您的 hosts文件应如下所示,其中包含每个站点的 IPV4 和 IPV6 版本的定义。浏览器可以任意使用其中任何一个,因此您需要两者,但如果两者实际上在您的 PC 上处于事件状态,则可能会优先使用 IPV6 网络而不是 IPV4。
127.0.0.1 localhost
::1 localhost
127.0.0.1 mysite.dev
::1 mysite.dev
现在在您系统上实际存在的 2 个虚拟主机上尝试将此作为虚拟主机定义:
<VirtualHost *:80>
DocumentRoot "g:/wamp/www"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "G:/wamp/www">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "g:\wamp\www\mysite\public"
ServerName mysite.dev
ServerAlias www.mysite.dev
ErrorLog "logs/mysite-error.log"
CustomLog "logs/mysite-access.log" common
<Directory "G:/wamp/www/mysite/public">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
<Directory>....</Directory> <VirtualHost>....</VirtualHost> 内的部分部分告诉 Apache 允许它接受来自哪些 IP 地址的连接,因此使用 Apache 2.4 语法 Require local限制访问,以便只有运行 WAMPServer(即 Apache)的 PC 才能连接到这些站点中的任何一个。
避免在同一定义中混合使用 Apache 2.2 语法和 Apache 2.4 语法。所以不要使用
Order Allow,Deny
Allow from all
和
Require all granted
定义相同。您使用的是 Apache 2.4,因此请使用 Apache 2.4 语法。
如果您发现您希望允许本地网络中的其他 PC 查看您的站点,即工作伙伴或 child 等,您可以将此语法添加到一个或多个虚拟主机定义中。
只允许一台其他 PC 进入您的站点
Require local
Require ip 192.168.1.100
或另外 2 台 PC
Require local
Require ip 192.168.1.100, 192.168.1.101
或者对于您本地网络上的任何人,只需使用 ip 地址的 4 个四分位数中的前 3 个。
Require ip 192.168.1
还要避免使用允许从任何地方访问的语法,即
Require all granted <--Apache 2.4 syntax
or
Order Allow,Deny <-- Apache 2.2 syntax
Allow from all
它可能会在短期内解决您的问题,但只是在等您决定要向 friend /客户/老板展示您的网站时再捕获您。如果您进入端口转发阶段,您的路由器允许世界进入您的网络,这将导致您的所有站点对世界可用。
最好更改您希望人们从 Require local 看到的用于测试/吹嘘的 ONE 站点的 ONE 虚拟主机定义。至 Require all granted并且只允许从 Internet 访问该单个站点。
完成所有这些更改后,记得重新启动 Apache。
另外,如果您更改主机文件以使 chnages 处于事件状态,则您应该重新启动或从命令窗口的命令行运行这些命令 ising Runs as Administrator选项。
net stop dnscache
net start dnscache
If you are using Windows 10 the above dns commands no longer work, you should do this instead.
ipconfig /flushdns
关于php - WAMP 虚拟主机不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26113258/
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion在首页我有:汽车:VolvoSaabMercedesAudistatic_pages_spec.rb中的测试代码:it"shouldhavetherightselect"dovisithome_pathit{shouldhave_select('cars',:options=>['volvo','saab','mercedes','audi'])}end响应是rspec./spec/request
在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo
我已经构建了一些serverspec代码来在多个主机上运行一组测试。问题是当任何测试失败时,测试会在当前主机停止。即使测试失败,我也希望它继续在所有主机上运行。Rakefile:namespace:specdotask:all=>hosts.map{|h|'spec:'+h.split('.')[0]}hosts.eachdo|host|begindesc"Runserverspecto#{host}"RSpec::Core::RakeTask.new(host)do|t|ENV['TARGET_HOST']=hostt.pattern="spec/cfengine3/*_spec.r
我有一个存储主机名的Ruby数组server_names。如果我打印出来,它看起来像这样:["hostname.abc.com","hostname2.abc.com","hostname3.abc.com"]相当标准。我想要做的是获取这些服务器的IP(可能将它们存储在另一个变量中)。看起来IPSocket类可以做到这一点,但我不确定如何使用IPSocket类遍历它。如果它只是尝试像这样打印出IP:server_names.eachdo|name|IPSocket::getaddress(name)pnameend它提示我没有提供服务器名称。这是语法问题还是我没有正确使用类?输出:ge
使用Ruby1.9.2运行IDE提示说需要gemruby-debug-base19x并提供安装它。但是,在尝试安装它时会显示消息Failedtoinstallgems.Followinggemswerenotinstalled:C:/ProgramFiles(x86)/JetBrains/RubyMine3.2.4/rb/gems/ruby-debug-base19x-0.11.30.pre2.gem:Errorinstallingruby-debug-base19x-0.11.30.pre2.gem:The'linecache19'nativegemrequiresinstall
我知道全局变量$!包含最新的异常对象,但我对下面的语法感到困惑。谁能帮助我理解以下语法?rescue$! 最佳答案 此构造可防止异常停止您的程序并使堆栈跟踪冒泡。它还会将该异常作为值返回,这很有用。a=get_me_datarescue$!在此行之后,a将保存请求的数据或异常。然后您可以分析该异常并采取相应措施。defget_me_dataraise'Nodataforyou'enda=get_me_datarescue$!puts"Executioncarrieson"pa#>>Executioncarrieson#>>#更现实的
在VMware16.2.4安装Ubuntu一、安装VMware1.打开VMwareWorkstationPro官网,点击即可进入。2.进入后向下滑动找到Workstation16ProforWindows,点击立即下载。3.下载完成,文件大小615MB,如下图:4.鼠标右击,以管理员身份运行。5.点击下一步6.勾选条款,点击下一步7.先勾选,再点击下一步8.去掉勾选,点击下一步9.点击下一步10.点击安装11.点击许可证12.在百度上搜索VM16许可证,复制填入,然后点击输入即可,亲测有效。13.点击完成14.重启系统,点击是15.双击VMwareWorkstationPro图标,进入虚拟机主