【发布时间】:2015-01-17 08:31:43
【问题描述】:
对于我一整天都在努力解决的问题,我真的很感激……我使用 WAMP 在本地安装了 WordPress,一切正常。我在 C:/wamp/www 中创建了一个文件夹,并将其命名为 wordpress。 我只能通过在浏览器的 URL 上键入 localhost 来访问 localhost,并且我访问了键入 localhost/wordpress/ 但是当我决定安装另一个 wordpress 网站时遇到问题的站点。我在 www 中创建了第二个文件夹,将其命名为 joanaweb 并按照本教程的步骤操作:http://www.marolinedesign.com/tutorials/how-to-install-more-than-one-wordpress-site-on-your-local-wamp-server/ PLUS 我删除了位于 httpd.conf 上的 Include conf/extra/httpd-vhosts.conf 之前的 #,这在教程。 在此之后,第一个网站像以前一样访问,而第二个网站通过键入 joanaweb....但是我无法再访问 localhost :( 我只收到一个 403 错误。在这个网站 http://www.apptools.com/phptools/virtualhost.php 在文章末尾我发现一个解决方案,但它对我不起作用:/ 他们建议使用:
<VirtualHost 127.0.0.1>
DocumentRoot C:\Apache\htdocs
ServerName localhost
</VirtualHost>
由于我的 htdocs 位于另一个文件夹中,因此我在 httpd-vhosts.conf 上使用了此代码
<VirtualHost *:80>
DocumentRoot "C:/wamp/bin/apache/apache2.4.9/htdocs/"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost.log"
CustomLog "logs/localhost.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/joanaweb"
ServerName joanaweb
ServerAlias joanaweb
ErrorLog "logs/joanaweb.log"
CustomLog "logs/joanaweb.log" common
</VirtualHost>
我做错了什么??
这也是我的 hosts 文件中的所有代码(在 cmets 之后):
127.0.0.1 localhost
::1 localhost
127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 localhost localhost
127.0.0.1 localhost wordpress
127.0.0.1 localhost joanaweb
127.0.0.1 localhost lifestylepro
127.0.0.1 localhost xxxxxTranslations
这是 httpd-vhosts.conf 中的代码:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "c:/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 "c:/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>
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
AllowOverride All
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/wordpress"
ServerName wordpress
ServerAlias wordpress
<Directory "C:/wamp/www/wordpress">
AllowOverride All
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
ErrorLog "logs/wordpress.log"
CustomLog "logs/wordpress.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/joanaweb"
ServerName joanaweb
ServerAlias joanaweb
<Directory "C:/wamp/www/joanaweb">
AllowOverride All
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
ErrorLog "logs/joanaweb.log"
CustomLog "logs/joanaweb.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/lifestylepro"
ServerName lifestylepro
ServerAlias lifestylepro
<Directory "C:/wamp/www/lifestylepro">
AllowOverride All
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
ErrorLog "logs/lifestylepro.log"
CustomLog "logs/lifestylepro.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/xxxxxTranslations"
ServerName xxxxxTranslations
ServerAlias www.xxxxxTranslations
<Directory "C:/wamp/www/xxxxxTranslations">
AllowOverride All
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
ErrorLog "logs/xxxxxTranslations.log"
CustomLog "logs/xxxxxTranslations.log" common
</VirtualHost>
【问题讨论】:
-
你在
C:\Windows\System32\drivers\etc中编辑过你的hosts文件吗? -
是的,我已经为第二个网站添加了这行代码... 127.0.0.1 joanaweb
-
您的姓名和别名应以 TLD 结尾(
.com或.dev等)。 -
我在某处读到它们是可选的,但也许这不正确。谢谢你的回答,我马上试试
-
它没有用:/我想我必须“关闭”其他网站,当我需要访问 localhost 时只允许 www/wordpress,谢谢 :)
标签: wordpress apache localhost wamp vhosts