CentOS apache配置虚拟服务器

原创
2016-06-07 15:04:22 921浏览

注意: 1、需要确定的端口是否存在: semanageport-l|grephttp,如果http_port_t后面有需要用到的端口,则需要确定该端口是否被占用:semanageport-l|grephttp81,如果被占用,则需要添加额外的端口: semanageport-a-thttp_port_t-ptcp82 ; 2、用到的端口

注意:

1、需要确定的端口是否存在:

semanage port -l | grep http,如果http_port_t 后面有需要用到的端口,则需要确定该端口是否被占用:semanage port -l | grep http 81,如果被占用,则需要添加额外的端口:semanage port -a -t http_port_t -p tcp 82

2、用到的端口需要先在防火墙中添加,否则只能用内网访问到挂载的站点;

vim /etc/sysconfig/iptables

在里面加入:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 8888 -j ACCEPT

重启防火墙服务:service iptables restart

1、基于同一个IP、多端口的虚拟主机配置

Listen 80
Listen 8888
ServerName localhsot
NameVirtualHost *:80

DocumentRoot /var/www/example1
ServerName www.example1.com
ErrorLog logs/example1-error_log
CustomLog logs/example1-access_log common

NameVirtualHost *:8888

DocumentRoot /var/www/example2
ServerName www.example2.com
ErrorLog logs/example2-error_log
CustomLog logs/example2-access_log common

ServerName需要注册,否则无效!

3、用vim打开httpd.conf文件时,提示输入密码,如果不输入密码直接按enter也可以进入文件,但是显示的是乱码,在网上扒了很久,没有找到问题的解决方法,最后被迫把配置文件重新弄了一遍,教训:做好数据的备份!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。