欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

winxp apache用php建本地虚拟主机的方法

程序员文章站 2023-12-25 13:24:51
1 在c:\windows\system32\drivers\etc\hosts 添加如下代码: 127.0.0.1 localhost 127.0.0.1 x.test....
1 在c:\windows\system32\drivers\etc\hosts
添加如下代码:
127.0.0.1 localhost
127.0.0.1 x.test.com x.test1.com x.test2.com
注:x.test.com(假设的dns)
2 在e:\wamp\apache2.2\conf\extra\httpd-vhosts.conf
修改内容:
namevirtualhost *
<virtualhost *>
serveradmin web@xxx.com
documentroot e:/wamp/www
servername localhost
errorlog logs/localhost-error_log
customlog logs/localhost-access_log common
</virtualhost>
<virtualhost *>
serveradmin web@xxx.com
documentroot e:/wamp/www/app (应用目录)
servername test.com
serveralias x.test.com admin.teeume.com
errorlog logs/x.test.com-error_log
customlog logs/x.test.com-access_log common
</virtualhost>
<virtualhost *>
serveradmin web@xxx.com
documentroot e:/wamp/www/app/assets
servername x.test1.com
errorlog logs/img.test1.com-error_log
customlog logs/img.test1.com-access_log common
</virtualhost>
#自己建的目录
<virtualhost *>
serveradmin web@xxx.com
documentroot e:/wamp/www/test/assets
servername x.test2.com
errorlog logs/img.test2.com-error_log
customlog logs/img.test2.com-access_log common
</virtualhost>
============================
3 检查是否关联php
在e:\wamp\apache2.2\conf 找到httpd.conf
在末尾是否有如下在代码:
############start for php5
loadmodule php5_module e:/wamp/php5/php5apache2_2.dll
phpinidir e:/wamp/php5
addtype application/x-httpd-php .php .phtml .php5
addtype application/x-httpd-php-source .phps
#####end for php5
若无则添加上以代码。
4 查找
# virtual hosts
#include conf/extra/httpd-vhosts.conf
改为
# virtual hosts
include conf/extra/httpd-vhosts.conf
5 查找
<ifmodule dir_module>
directoryindex index.html
</ifmodule>
改为
<ifmodule dir_module>
directoryindex index.html index.html.var index.php
</ifmodule>
6 查找 <directory "e:/wamp/apache2.2/htdocs">
改为 <directory "e:/wamp/www"> (www为apache应用目录)
7 查找 documentroot "e:/wamp/apache2.2/htdocs"
改为 documentroot "e:/wamp/www"
8 查找 serverroot "e:/xxx/apache2.2" (apache安装目录)
改为 serverroot "e:/wamp/apache2.2" (apache服务器目录)
9 x.test.com x.test1.com x.test2.com
分别输入以上三个进行测试

上一篇:

下一篇: