Apache虚拟主机配置简单说明
目录
为方便管理,节省成本,使用虚拟主机+CF的方案
httpd.conf
- 找到如下代码片段并去除前面的#
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#Include etc/extra/httpd-vhosts.conf
- 屏蔽如下内容,应配置在vhost中
DocumentRoot "/opt/lampp/htdocs"
<Directory "/opt/lampp/htdocs">
</Directory>
httpd-vhosts.conf
添加如下配置
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs/www.site01.com"
ServerName www.site01.com
<Directory "/opt/lampp/htdocs/www.site01.com">
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/www.site01.com.ltd-error_log"
CustomLog "logs/www.site01.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs/www.site02.com"
ServerName www.site02.com
<Directory "/opt/lampp/htdocs/www.site02.com">
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/www.site02.com-error_log"
CustomLog "logs/www.site02.com-access_log" common
</VirtualHost>
joomla(个人需求,配置虚拟主机无需看这部分)
创建数据库,复制数据库
configuration.php
public $db = '数据库名称';
遇到的问题 - 总结
- 报错信息如下exceeded the limit of 10
AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error.
- .htaccess文件一定要复制到网站目录中去
- Directory要配置到vhost中,每个网站的目录不一样,.htaccess文件也不该公用
- 权限问题,文件夹给的权限不够导致的 failed to open stream: Permission denied in File.php