PHP Apache - 多站点虚拟主机配置
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot "/var/www/site1"
ServerName site1.example.com
ServerAlias www.site1.example.com
<Directory "/var/www/site1">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog "/var/log/apache2/site1-error.log"
CustomLog "/var/log/apache2/site1-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot "/var/www/site2"
ServerName site2.example.com
ServerAlias www.site2.example.com
<Directory "/var/www/site2">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog "/var/log/apache2/site2-error.log"
CustomLog "/var/log/apache2/site2-access.log" common
</VirtualHost>
这个示例代码演示了如何在Apache服务器中配置两个虚拟主机,每个虚拟主机对应一个网站。每个<VirtualHost>
块定义了一个站点的配置,包括管理员邮箱、网站根目录、服务器名和服务器别名。同时,定义了目录权限、日志记录等设置。这是PHP多站点配置的一个基本示例。
评论已关闭