win系统 Apache配置本地域名

win系统 Apache配置本地域名

配置本地域名
在C:\Windows\System32\drivers\etc下hosts文件
20170218201343

配置 httpd.conf
找到#Include conf/extra/httpd-vhosts.conf
去掉#注释

找到conf/extra/httpd-vhosts.conf
配置 httpd-vhosts.conf
[php]
Listen 8081
Listen 8082
<VirtualHost *:8081>
DocumentRoot "F:\web\lzcms"
ServerName lz.liuyp.com
ServerAlias phpStudy.net
<Directory "F:\web\lzcms">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:8082>
DocumentRoot "F:\web\lzcms"
ServerName lz.liuyp.com
ServerAlias phpStudy.net
<Directory "F:\web\lzcms">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
[/php]

好后保存并重启apache.

我用的时8080端口,所以访问域名需要把端口加过去,如果时80端口就可以忽略。

在本地Windows10系统下Apache2.4.43配置基于域名的虚拟主机
[php]
<VirtualHost *:80>
DocumentRoot "站点目录"
ServerName 主机名
<Directory "站点目录">
AllowOverride None
Require all granted
Options Indexes FollowSymLinks
DirectoryIndex index.html index.htm index.php
</Directory>
</VirtualHost>
[/php]

Options Indexes FollowSymLinks 在没有index的情况下显示目录结构
DirectoryIndex index.html index.htm index.php 指定默认访问文件

发表评论

© 2022. powered by PHP 个人小站