CentOS7 安装apache 配置多站点


配置apache服务器

YUM 安装配置,简单方便可靠

yum install httpd 

安装完成后

systemctl start httpd  <启动httpd服务   restrat是重启
systemctl start httpd   ##启动httpd服务   restrat是重启

systemctl stop  firewalld     ##关闭防火墙

 systemctl disable firewalld    ##开启不开启防火墙

 systemctl enable  httpd      ##开机自动开启httpd服务 
DirectoryIndex index.html 后面加上 index.htm index.php index.shtml

apache 配置多个虚拟主机

// 新建配置文件
vim /etc/httpd/conf.d/vhost.conf
// 下面是输入的内容 在明白其中含义的情况下,设置内的注释可以删除
#
# 测试网站一
#
<VirtualHost *:80>
#绑定的主域
ServerName test.com
#绑定的子域名
ServerAlias www.test.com
#网站主目录
DocumentRoot /home/website/com.test.www/
#日志配置
ErrorLog /home/web_log/com.test.www_error.log
CustomLog /home/web_log/com.test.www_access.log common
#ServerSignature Off
</VirtualHost>
#测试一的配置
<Directory "/home/website/com.test.www/">
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

// 如果有更多内容,重复上面的

切记在vim /etc/httpd/conf/httpd.conf

修改或添加  Include conf/vhosts.conf   《《指定配置加载文件


httpd常用命令

systemctl start httpd.service #启动apache

systemctl stop httpd.service #停止apache

systemctl restart httpd.service #重启apache

systemctl enable httpd.service #设置apache开机启动

猜你喜欢

转载自blog.csdn.net/sym134/article/details/79829252
今日推荐