zl程序教程

您现在的位置是:首页 >  后端

当前栏目

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

PHP方法 本地 虚拟主机
2023-06-13 09:14:11 时间
1在C:\WINDOWS\system32\drivers\etc\hosts
添加如下代码:
127.0.0.1localhost
127.0.0.1x.test.comx.test1.comx.test2.com
注:x.test.com(假设的DNS)
2在E:\WAMP\Apache2.2\conf\extra\httpd-vhosts.conf
修改内容:
NameVirtualHost*
<VirtualHost*>
ServerAdminweb@xxx.com
DocumentRootE:/WAMP/www
ServerNamelocalhost
ErrorLoglogs/localhost-error_log
CustomLoglogs/localhost-access_logcommon
</VirtualHost>
<VirtualHost*>
ServerAdminweb@xxx.com
DocumentRootE:/WAMP/www/app(应用目录)
ServerNametest.com
ServerAliasx.test.comadmin.teeume.com
ErrorLoglogs/x.test.com-error_log
CustomLoglogs/x.test.com-access_logcommon
</VirtualHost>
<VirtualHost*>
ServerAdminweb@xxx.com
DocumentRootE:/WAMP/www/app/assets
ServerNamex.test1.com
ErrorLoglogs/img.test1.com-error_log
CustomLoglogs/img.test1.com-access_logcommon
</VirtualHost>
#自己建的目录
<VirtualHost*>
ServerAdminweb@xxx.com
DocumentRootE:/WAMP/www/test/assets
ServerNamex.test2.com
ErrorLoglogs/img.test2.com-error_log
CustomLoglogs/img.test2.com-access_logcommon
</VirtualHost>
============================
3检查是否关联php
在E:\WAMP\Apache2.2\conf找到httpd.conf
在末尾是否有如下在代码:
############startforphp5
LoadModulephp5_moduleE:/WAMP/php5/php5apache2_2.dll
PHPIniDirE:/WAMP/php5
AddTypeapplication/x-httpd-php.php.phtml.php5
AddTypeapplication/x-httpd-php-source.phps
#####endforphp5
若无则添加上以代码。
4查找
#Virtualhosts
#Includeconf/extra/httpd-vhosts.conf
改为
#Virtualhosts
Includeconf/extra/httpd-vhosts.conf
5查找
<IfModuledir_module>
DirectoryIndexindex.html
</IfModule>
改为
<IfModuledir_module>
DirectoryIndexindex.htmlindex.html.varindex.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服务器目录)
9x.test.comx.test1.comx.test2.com
分别输入以上三个进行测试