winxp apache用php建本地虚拟主机的方法
<p><strong>1 在C:\WINDOWS\system32\drivers\etc\hosts</strong><br>
添加如下代码:<br>
127.0.0.1 localhost<br>
127.0.0.1 x.test.com x.test1.com x.test2.com<br>
注:x.test.com(假设的DNS)<br><strong>2 在E:\WAMP\Apache2.2\conf\extra\httpd-vhosts.conf</strong><br>
修改内容:<br>
NameVirtualHost *<br>
<VirtualHost *><br>
ServerAdmin web@xxx.com<br>
DocumentRoot E:/WAMP/www<br>
ServerName localhost<br>
ErrorLog logs/localhost-error_log<br>
CustomLog logs/localhost-access_log common<br>
</VirtualHost><br>
<VirtualHost *><br>
ServerAdmin web@xxx.com<br>
DocumentRoot E:/WAMP/www/app (应用目录)<br>
ServerName test.com<br>
ServerAlias x.test.com admin.teeume.com<br>
ErrorLog logs/x.test.com-error_log<br>
CustomLog logs/x.test.com-access_log common<br>
</VirtualHost><br>
<VirtualHost *><br>
ServerAdmin web@xxx.com<br>
DocumentRoot E:/WAMP/www/app/assets<br>
ServerName x.test1.com<br>
ErrorLog logs/img.test1.com-error_log<br>
CustomLog logs/img.test1.com-access_log common<br>
</VirtualHost><br>
#自己建的目录<br>
<VirtualHost *><br>
ServerAdmin web@xxx.com<br>
DocumentRoot E:/WAMP/www/test/assets<br>
ServerName x.test2.com<br>
ErrorLog logs/img.test2.com-error_log<br>
CustomLog logs/img.test2.com-access_log common<br>
</VirtualHost><br>
============================<br><strong>3 检查是否关联php</strong><br>
在E:\WAMP\Apache2.2\conf 找到httpd.conf<br>
在末尾是否有如下在代码:<br>
############start for php5<br>
LoadModule php5_module E:/WAMP/php5/php5apache2_2.dll<br>
PHPIniDir E:/WAMP/php5<br>
AddType application/x-httpd-php .php .phtml .php5<br>
AddType application/x-httpd-php-source .phps<br>
#####end for php5<br>
若无则添加上以代码。<br><strong>4 查找</strong><br>
# Virtual hosts<br>
#Include conf/extra/httpd-vhosts.conf<br><strong>改为 </strong><br>
# Virtual hosts<br>
Include conf/extra/httpd-vhosts.conf<br><strong>5 查找 </strong><br>
<IfModule dir_module><br>
DirectoryIndex index.html<br>
</IfModule><br><strong>改为 </strong><br>
<IfModule dir_module><br>
DirectoryIndex index.html index.html.var index.php<br>
</IfModule><br>
6 查找 <Directory "E:/WAMP/Apache2.2/htdocs"><br>
改为 <Directory "E:/WAMP/www"> (www为apache应用目录)<br>
7 查找 DocumentRoot "E:/WAMP/Apache2.2/htdocs"<br>
改为 DocumentRoot "E:/WAMP/www"<br>
8 查找 ServerRoot "E:/XXX/Apache2.2" (apache安装目录)<br>
改为 ServerRoot "E:/WAMP/Apache2.2" (apache服务器目录)<br>
9 x.test.com x.test1.com x.test2.com<br>
分别输入以上三个进行测试</p>
頁:
[1]