• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

CentOS apache配置虚拟服务器

mysql 搞代码 4年前 (2022-01-09) 11次浏览 已收录 0个评论

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

<link href=”/js/syntaxhighlighter/SyntaxHighlighter.css” rel=”stylesheet” type=”text/css” />

注意:

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 http://www.example1.com
ErrorLog logs/example1-error_log
CustomLog logs/example1-access_log common

NameVirtualHost *:8888

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

ServerName需要注册,否则无效!

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


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:CentOS apache配置虚拟服务器

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址