添加另一个端口 apache2

Posted

技术标签:

【中文标题】添加另一个端口 apache2【英文标题】:Adding another port apache2 【发布时间】:2015-12-14 04:39:02 【问题描述】:

我试图在 apache2 和 inn 站点上的端口 80 和 1998 上运行一个网站 - 我的配置如下所示:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin admin@mafiakampen.com
    DocumentRoot /var/www/html/mv

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog $APACHE_LOG_DIR/error.log
    CustomLog $APACHE_LOG_DIR/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

<VirtualHost *:1998>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin admin@mafiakampen.com
    DocumentRoot /var/www/html/

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog $APACHE_LOG_DIR/error.log
    CustomLog $APACHE_LOG_DIR/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

然后我重新启动 apache2 并发送命令 iptables -A INPUT -p tcp --dport 1998 --jump ACCEPT

现在,当我转到 myserverip:1998 时,我发现该页面不可用,并且位于该 ERR_CONNECTION_REFUSED 之下。我该如何解决这个问题?

【问题讨论】:

【参考方案1】:

我忘了去 /etc/apache2/ports.conf 并添加 Listen 1998 然后我在我的虚拟主机中添加了 NameVirtualHost *:1998

【讨论】:

以上是关于添加另一个端口 apache2的主要内容,如果未能解决你的问题,请参考以下文章

在httpd.conf中添加另一个要监听的端口会导致Apache崩溃

模块调用端口的连接规则

docker给已存在的容器添加或修改端口映射

Apache虚拟主机/端口多开

iis无法启动。提示“另一个程序正在使用此文件,进程无法访问“

synology git管理程序添加