Rootop 服务器运维与web架构

配置Apache 监听多个端口及运行在不同的端口上

| 暂无评论

     在IIS中,可以设置web服务跑在不同的端口下,仅需简单的点点鼠标配置下即可:

                                               我们可以将 端口(T):改为其他的,比如8080

然后确定后我们查看端口状态:

C:\>netstat -an | find “80”
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING

下面说一下在linux下apache的配置方法:

首先,dns做好了,分别为80.com   8080.com   对应的IP都是1.1.1.1

首先设置apache的监听端口:

# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 80
listen 8080

#  有几个写几个

接着配置虚拟主机,那我机器肯定是基于域名的虚拟主机了。

# Use name-based virtual hosting.
#
#NameVirtualHost *:80
namevirtualhost 1.1.1.1:80
#

<virtualhost www.80.com:80>
serveradmin venuslinux@gmail.com
servername www.80.com
documentroot /wz/80
errorlog logs/80_error.log
customlog logs/80_access.log common
directoryindex index.html
</virtualhost>

<virtualhost www.8080.com:8080>
serveradmin venuslinux@gmail.com
servername www.8080.com
documentroot /wz/8080
errorlog logs/8080_error.log
customlog logs/8080_access.log common
directoryindex index.html
</virtualhost>

然后为其创建根目录,index.html内容分别为80 8080

然后客户端测试:

http://www.80.com                            显示80

http://www.8080.com:8080/           显示8080(因为运行的端口不是在默认的80上,所以要手动指定)

至此,配置结束。

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/273.html

作者:Venus

服务器运维与性能优化

发表回复