xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

php 配置主机虚拟目录(使用虚拟域名访问 127.0.0.1)

steps:

1>

打开目录  D:xwampinapacheapache2.4.9conf     修改文件 httpd.conf

Ctrl+F 搜索
#LoadModule rewrite_module modules/mod_rewrite.so   修改为(开启模块功能)

LoadModule rewrite_module modules/mod_rewrite.so


#Include conf/extra/httpd-vhosts.conf  修改为(开启模块功能)

Include conf/extra/httpd-vhosts.conf

2>

打开目录 D:xwampinapacheapache2.4.9confextra 修改文件 httpd-vhosts.conf

添加

#my vhost www.xgqfrms.com
#listen 8888
#NameVirtualHost *:8888
#NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin webmaster@www.xgqfrms.com
    DocumentRoot "D:/xwamp/www/PHPExcel1.8"
    ServerName xgqfrms.com
    ServerAlias www.xgqfrms.com
    ErrorLog "logs/www.xgqfrms.com-error.log"
    CustomLog "logs/www.xgqfrms.com-access.log" common
</VirtualHost>

#DocumentRoot "D:/xwamp/www/PHPExcel1.8"

#注意root路径的 修改为 /

3>

打开1>的  httpd.conf

搜索,复制

<Directory />
    AllowOverride none
    Require all denied
</Directory>



<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    deny from all
</Directory>

添加到 2>的</VirtualHost>后面

并修改为

<Directory "D:/xwamp/www/PHPExcel1.8"/>
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
</Directory>

4>hosts

打开目录 C:WindowsSystem32driversetc
修改 hosts
添加 127.0.0.1 www.xgqfrms.com
#注意在 127.0.0.1    localhost 后面

5>

测试配置php

<?php

echo  "#add 127.0.0.1    www.xgqfrms.com
127.0.0.1    www.xgqfrms.com";

$string x= <<<pre

#add 127.0.0.1    www.xgqfrms.com
127.0.0.1    www.xgqfrms.com

pre;

?>

原文地址:https://www.cnblogs.com/xgqfrms/p/4895117.html