php学习-本地配置虚拟域名

集成环境phpstudy Apache+php5.4

Apache配置虚拟域名首先是在httpd-conf里注释掉

#Include conf/extra/httpd-vhosts.conf  

打开vhost-conf

<VirtualHost *:80>
ServerAdmin [email protected]
    DocumentRoot "根目录"
    ServerName 域名
    <Directory "根目录">
    Options +Indexes +FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

windows下打开本机的C:\WINDOWS\system32\drivers\etc\hosts,填上

127.0.0.1 你的域名

重启服务器即可

如果出现访问的了域名,但是访问不了localhost的情况,需要再在vhsot-conf里加上

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot  "www根目录"
    ServerName localhost
    <Directory />
    Options +Indexes +FollowSymLinks +ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
    </Directory>
</VirtualHost>

并且注释掉httpd-conf里的

#ServerName localhost

我也不明白为什么要注释掉这里,但是不注释就是不行

猜你喜欢

转载自blog.csdn.net/qq_35513792/article/details/81133314
今日推荐