在一个centos7服务器上面搭建多个站点

1,创建站点文件目录

mkdir -pv /var/www/网站1
mkdir -pv /var/www/网站2

2,创建站点日志存放目录

mkdir -pv /var/log/httpd/网站1
mkdir -pv /var/log/httpd/网站2

3,修改httpd.conf文件

vim /etc/httpd/conf/httpd.conf

在末尾添加

<VirtualHost *:80>
 ServerName www.网站1.com
 DocumentRoot /var/www/网站1 
 ErrorLog “/var/log/httpd/网站1/error_log”
 CustomLog “/var/log/httpd/网站1/access_log” combined
 <Directory /var/www/网站1>
 Options -Indexes +Includes +FollowSymLinks +MultiViews
 AllowOverride All
 Require all granted 
 </Directory> 
</VirtualHost>

<VirtualHost *:80>
 ServerName www.网站2.com
 DocumentRoot /var/www/网站2 
 ErrorLog “/var/log/httpd/网站2/error_log”
 CustomLog “/var/log/httpd/网站2/access_log” combined
 <Directory /var/www/网站2>
 Options -Indexes +Includes +FollowSymLinks +MultiViews
 AllowOverride All
 Require all granted 
 </Directory> 
</VirtualHost> 

保存退出后重启服务器即可

发表评论

电子邮件地址不会被公开。 必填项已用*标注