Apache httpd.conf 新增子配置文件 配置虚拟主机 多端口访问多站点

需求:访问同一个IP地址下的不同端口,转到不同的站点/访问不同的项目

项目A:http://123.456.78.9:8100

项目B:http://123.456.78.9:8101

项目C:http://123.456.78.9:8102

修改Apache配置:增加端口

新增一个端口 避免占用80端口:这里测试端口为8100

防火墙开通端口(如果是阿里云后台,则需要在安全组新增端口)

查看端口是否可用,可用,则在防火墙添加这个端口:

查看端口是否占用 无内容输出,表示未被占用

lsof -i tcp:8100

查看防火墙是否开通端口 未找到 则表示未开通

firewall-cmd --permanent --list-port

防火墙开通端口 并重载防火墙 使之生效

firewall-cmd --permanent --zone=public --add-port=8100/tcp
firewall-cmd --reload

httpd.conf Apache默认的配置文件:

一般 Apache的 /etc/httpd/conf/httpd.conf 文件最后一行 ,IncludeOptional 后默认是引入 conf.d目录下的所有.conf文件,如果能搜到这一行 则不用改动,如果搜不到,就追加这一行代码 并保存:IncludeOptional对应的值为 /etc/httpd/conf.d/*.conf ,如果值不同,则以文件内的值为准

httpd.conf 文件: 基本不用动,下面代码块仅作参考

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see 
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/etc/httpd"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the defaul
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值