apache虚拟主机
2020-02-03 本文已影响0人
lancelu
一、配置多个系统到不同的端口
# httpd.conf中配置监听端口
Listen 80
Listen 82
Listen 9999
# vhosts.conf中配置
<VirtualHost _default_:82>
ServerName localhost
DocumentRoot "项目路径"
<Directory "项目路径">
Options -Indexes -FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost _default_:9999>
ServerName localhost
DocumentRoot "项目路径"
<Directory "项目路径">
Options -Indexes -FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
二、多个项目配置到一个主项目下
# vhosts.conf中配置
<VirtualHost _default_:80>
## 主目录
DocumentRoot "路径"
<Directory "路径">
Options -Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
## 挂载到主项目下的子项目
Alias /test1 "路径"
<Directory "路径">
Options -Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>