美文网首页
apache配置说明

apache配置说明

作者: 子非鱼_aee3 | 来源:发表于2019-10-24 13:37 被阅读0次

1.安装(centos7)

yum -y install httpd

systemctl start|stop|restart|enable|disable httpd

2.配置

/etc/httpd/   #配置文件目录

/etc/httpd/conf/httpd.conf  #apache的主配置文件

/var/www/html/  #默认存放网页的目录

打开httpd.conf 

虚拟主机配置:

apache虚拟主机可以实现一台服务器多个网站

1.不同ip(如服务器有2个网卡),相同端口

2.相同ip,不同端口

3.相同ip,端口,不同主机头(a.baidu.com, b.baidu.com)

打开 vim /etc/httpd/conf.d/vhosts.conf,粘贴下面2个

也可在conf.d目录下新建两个×××.conf,粘贴一个

<VirtualHost *:80>

ServerName helloworld.cn   #绑定的主域

ServerAlias www.helloworld.cn  #绑定的子域名

DocumentRoot /var/www/cn   #网页存放目录,创建cn文件夹

ErrorLog /var/log/httpd/cn_error.log  #错误日志

CustomLog /var/log/httpd/cn_access.log common  #访问日志

#ServerSignature Off

</VirtualHost>

<Directory "/var/www/cn/">

    Options FollowSymLinks

    AllowOverride All

    Require all granted

</Directory>

<VirtualHost *:80>

ServerName helloworld.com

ServerAlias www.helloworld.com

DocumentRoot /var/www/com   #创建com文件夹

ErrorLog /var/log/httpd/com_error.log

CustomLog /var/log/httpd/com_access.log common

#ServerSignature Off

</VirtualHost>

<Directory "/var/www/com/">

    Options FollowSymLinks

    AllowOverride All

    Require all granted

</Directory>

相关文章

网友评论

      本文标题:apache配置说明

      本文链接:https://www.haomeiwen.com/subject/iybrvctx.html