Home > Database > Mysql Tutorial > CentOS apache配置虚拟服务器

CentOS apache配置虚拟服务器

WBOY
Release: 2016-06-07 15:04:22
Original
1379 people have browsed it

注意: 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也可以进入文件,但是显示的是乱码,在网上扒了很久,没有找到问题的解决方法,最后被迫把配置文件重新弄了一遍,教训:做好数据的备份!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template