码迷,mamicode.com
首页 > Web开发 > 详细

apache单ip配置多端口多站点

时间:2016-07-15 00:04:26      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:

1.修改 /etc/httpd/conf/httpd.conf

添加一个Listen,如:

Listen 80
Listen 8001
Listen 8002

 

2.添加一个VirtualHost

#vim /etc/httpd/conf.d/vhost.conf
NameVirtualHost *:8001
<VirtualHost *:8001>
    DocumentRoot /var/www/html/public_html
    ServerName localhost
    ServerAdmin gr00kiter@gmail.com
    #ErrorLog "| /usr/sbin/rotatelogs /var/www/html/log/public_html_error_%Y_%m_%d.log 86400 480"
    #CustomLog "| /usr/sbin/rotatelogs /var/www/html/log/public_html_access_%Y_%m_%d.log 86400 480" common
    ErrorLog "/var/www/html/log/error.log"
    CustomLog "/var/www/html/log/access.log" common
</VirtualHost>

NameVirtualHost *:8002
<VirtualHost *:8002>
    DocumentRoot /var/www/html/phpmyadmin
    ServerName localhost
    ServerAdmin gr00kiter@gmail.com
    #ErrorLog "| /usr/sbin/rotatelogs /var/www/html/log/public_html_error_%Y_%m_%d.log 86400 480"
    #CustomLog "| /usr/sbin/rotatelogs /var/www/html/log/public_html_access_%Y_%m_%d.log 86400 480" common
    ErrorLog "/var/www/html/log/error.log"
    CustomLog "/var/www/html/log/access.log" common
</VirtualHost>

 

3.为新端口添加防火墙规则

iptables -I INPUT -p tcp --dport 8001 -j ACCEPT
/etc/rc.d/init.d/iptables save

 

4.禁用selinux(如果不禁用,会无法重新启动apache)

方法1.关闭selinux

vim /etc/selinux/config

首先将SELINUX=enforcing添加注释

#SELINUX=enforcing

然后在文件末尾添加如下代码

SELINUX=disabled

方法2.修改selinux规则
首先查看现在支持http的端口有哪些

semanage port -l | grep http

然后为http服务新的端口号

semanage port -a -t http_port_t -p tcp 8001

查看添加的结果

semanage port -l | grep http

 

5.重启httpd服务

service httpd restart

 

apache单ip配置多端口多站点

标签:

原文地址:http://www.cnblogs.com/tiger2soft/p/5671911.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!