当前位置: 移动技术网 > 网络运营>服务器>Linux > winxp apache用php建本地虚拟主机的方法

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

2019年05月07日  | 移动技术网网络运营  | 我要评论
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
</ifmodule>
改为
<ifmodule dir_module>
directoryindex .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
分别输入以上三个进行测试

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网