打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
centos7下apache2.4.6虚拟主机配置

1,/etc/httpd/conf.d 目录下新增 vhost.conf,添加内容如下:

<VirtualHost *:80>#绑定的主域ServerName centos7.xxx.com#绑定的子域名ServerAlias localhost#网站主目录DocumentRoot /var/www/html/#日志配置ErrorLog /var/log/httpd/error.logCustomLog /var/log/httpd/access.log common#ServerSignature Off</VirtualHost>#测试一的配置<Directory "/var/www/html/">    Options FollowSymLinks    AllowOverride All    Require all granted</Directory><VirtualHost *:80>#绑定的主域ServerName test.com#绑定的子域名ServerAlias www.test.com#网站主目录DocumentRoot /home/website/com.test.www/#日志配置ErrorLog /home/web_log/com.test.www_error.logCustomLog /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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

2,确认apache的主配置文件(/etc/httpd/conf/httpd.conf)的下述配置项:

Include conf/extra/httpd-vhosts.conf
  • 1

3,/etc/hosts 新增 127.0.0.1 test.com www.test.com

4,设置selinux,使得apache有合适的对脚本和日志的操作权限:
chcon -R -t httpd_sys_content_t /home/website/com.test.www
chcon -R -t httpd_log_t /home/web_log
(ps:ls -Zl 可查看目录或档案的selinux权限)

5,检测配置文件正确性:apachectl configtest

6,重启apache:systemctl restart httpd

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
CentOS Apache配置详解
完整配置CentOS6安装LAMP(Apache/MySQL/PHP)环境搭建教程
Apache2.2多域名虚拟主机配置
如何配置虚拟主机
Mac自带apache配置小记
CentOS+Apache配置详细版
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服