创建时间:2017-11-09
Apache配置多站点
进入目录,新建目录,进入新建目录,新建文件httpd-vhosts.conf
cd /etc/httpd
mkdir config.d
cd config.d
touch httpd-vhosts.conf
vi httpd-vhosts.conf将下面内容添加进去,域名跟目录名称改成自己的即可
我这里配置了一个主域名,以及一个二级域名,分别访问不一样的目录
<VirtualHost *:80>
ServerName mrchen.top
ServerAlias mrchen.cn www.mrchen.cn
DocumentRoot /var/www/html/tp5
DirectoryIndex index.html index.php
</VirtualHost>
<Directory "/var/www/html/tp5">
Options +Includes -Indexes
AllowOverride All
Order Deny,Allow
Allow from All
</Directory>
<VirtualHost *:80>
ServerName admin.mrchen.top
ServerAlias admin.mrchen.top
DocumentRoot /var/www/html/admin
DirectoryIndex index.html index.php
</VirtualHost>
<Directory "/var/www/html/admin">
Options +Includes -Indexes
AllowOverride All
Order Deny,Allow
Allow from All
</Directory>修改apache配置文件
cd /etc/httpd/conf
vi httpd.conf进入编辑模式,在文件的最后一行添加下面代码
告诉apache,配置的多站点文件在哪里,自动引入文件
Include config/*.conf保存退出,重启apache即可
service httpd restart