Apache虚拟主机配置(多个域名访问多个目录)
一、windows下:
1. 打开 apache/conf/httpd.conf 文件
2. 找到 # Include conf/extra/httpd-vhosts.conf
3. 去掉前面的注释符#号
4. 打开 apache/conf/extra/httpd-vhosts.conf
5. 添加以上的多端口或多域名代码(这里以多域名为例):
6. 打开apache2/conf/extra/httpd-vhost.conf
二、centos7下的apache2.4,直接在/etc/httpd/conf.d/下添加你的 xxx.conf即可(xxx随你取,可以是www)
示例:
<VirtualHost 192.168.1.1:80>
ServerAdmin [email protected] (你的邮箱)
DocumentRoot /usr/local/apache2/htdocs/Joomla(此虚拟主机的根目录)
ServerName www.abc.com(此处为域名)
ErrorLog /usr/local/apache2/htdocs/abc/error_log (日志)
TransferLog /usr/local/apache2/htdocs/abc/access_log (日志)
</VirtualHost>
ServerAdmin [email protected] (你的邮箱)
DocumentRoot /usr/local/apache2/htdocs/bbs (此虚拟主机的根目录)
ServerName www.bbs.com (此处为域名)
ErrorLog /usr/local/apache2/htdocs/bbs/error_log (日志)
TransferLog /usr/local/apache2/htdocs/bbs/access_log (日志)
</VirtualHost>