Skip to content

多站点独立配置

本页教程不准确

创建站点配置文件

c
└─Apache2.4.39
   └─conf
      ├─sites-available 站点配置文件
      └─sites-enabled   站点配置文件符号链接

在 sites-available 目录下创建 example1.com.conf 和 example2.com.conf

php
# sites-available/example1.com.conf
# 按照实际情况进行填写
<VirtualHost *:80>
    ServerAdmin webmaster@example1.com
    ServerName example1.com
    ServerAlias www.example1.com
    DocumentRoot "D:/phpstudy_pro/WWW/example1.com"

    <Directory "D:/phpstudy_pro/WWW/example1.com">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>
php
# sites-available/example2.com.conf
# 按照实际情况进行填写
<VirtualHost *:80>
    ServerAdmin webmaster@example2.com
    ServerName example2.com
    ServerAlias www.example2.com
    DocumentRoot "D:/phpstudy_pro/WWW/example2.com"

    <Directory "D:/phpstudy_pro/WWW/example2.com">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>

启用/禁用 站点配置

启用

sh
sudo a2ensite example1.com.conf
sh
sudo a2ensite example2.com.conf

禁用

sh
sudo a2dissite example1.com.conf

保存所有配置文件后,重启 Apache 服务以使更改生效

Released under the MIT License.