apache配置多站点

系统环境:CentOS 7 + Apache 2.4.6  + PHP  + MySQL

# 创建网站目录
mkdir -p /var/www/linuxidc.com/public_html    #  帅旗军个人博客 
mkdir -p /var/www/hmgzh.net/public_html    #  黄梅公众号网站

# www目录755权限
chmod -R 755 /var/www

# 创建主页
vi /var/www/linuxidc.com/public_html/index.html    #添加任意内容

# 创建Virtual配置目录
mkdir /etc/httpd/sites-available
mkdir /etc/httpd/sites-enabled

# 配置httpd.conf
vi /etc/httpd/conf/httpd.conf
# 添加以下内容
IncludeOptional sites-enabled/*.conf
注释掉# DocumentRoot "/var/www/html"

# 创建网站Virtual配置文件
vi /etc/httpd/sites-available/linuxidc.com.conf
# 添加以下内容
<VirtualHost *:80>
    ServerName www.linuxidc.com
    ServerAlias linuxidc.com
    DocumentRoot /var/www/linuxidc.com/public_html
</VirtualHost>
<Directory "/var/www/linuxidc.com">  
    Options +Includes -Indexes 
    AllowOverride All
    Require all granted    
</Directory>

#创建链接
ln -s /etc/httpd/sites-available/linuxidc.com.conf /etc/httpd/sites-enabled/linuxidc.com.conf

#配置HOSTS
vi /etc/hosts
# 更改如下
127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4
::1        localhost localhost.localdomain localhost6 localhost6.localdomain6
10.100.18.100 linuxidc.com
10.100.18.100 hmgzh.net

#重启Apache
systemctl restart httpd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值