【问题标题】:Apache webserver status in UbuntuUbuntu 中的 Apache Web 服务器状态
【发布时间】:2022-12-10 04:54:41
【问题描述】:

我在我的 Ubuntu 机器上安装了 apache 网络服务器并将端口更改为 8080(/etc/apache2/apache2.conf,/etc/apache2/000-default.conf)并且能够在浏览器中成功加载测试页面

使用以下命令进行管理(也安装了 w3m):

sudo apache2ctl start
sudo apache2ctl stop
sudo apache2ctl status

但是, sudo apache2ctl status 给出以下错误:

w3m: Can't load http://localhost:80/server-status

我猜 apache2ctl status 正在选择默认端口而不是 8080。任何人都可以指导在哪里更改它

【问题讨论】:

    标签: apache ubuntu webserver devops


    【解决方案1】:

    您没有提到您在 apache2.conf 文件和 000-default.conf 中做了什么更改。 您需要在 apache2.conf 中设置 Listen 8080 的值,如果您定义了虚拟主机,则需要将打开的虚拟代码标记设置为 <VirtualHost *:8080>

    【讨论】:

    • 感谢您的回复。是的,我添加了相同的内容并能够在端口 8080 的浏览器中查看索引页面。但问题是,sudo apache2ctl status 给出错误:w3m:无法加载 localhost:80/server-status。是否有一个配置文件,我需要在其中指定用于检查服务器状态的端口命令拾取
    • 是的,这个答案是错误的。请编辑它,@Inder - 他是正确的,事实上你需要通过检查 ports.conf 和 sites-enabled/000-default 设置来确保 localhost 绑定到端口 80 for http(非 ssl) .
    【解决方案2】:

    听起来你可能强制重定向到 SSL 或者你的配置搞砸了。

    在您的主 000-default.conf 文件中,在 <VirtualHost *:80> 上方添加这些行

    <VirtualHost localhost:80>
    #dont redirect localhost on 80 (apache2 status/etc)
    DocumentRoot /var/www/html
    </VirtualHost>
    

    并重启服务器:

    sudo systemctl restart apache2.service
    

    然后再试一次:sudo apache2ctl status..

    如果您在 VirtualHost 中为 <*:80> 重定向(我的重定向所有内容到端口 :443/SSL),上面添加的行将获取本地主机 VirtualHost(首先)并且仍然允许状态模块在本地主机下正常工作浏览器或命令行。如果您使用此方法,它将无法在 LAN 或公共 IP 上工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-22
      • 2015-06-14
      • 2016-11-27
      • 2010-09-10
      • 2012-04-14
      • 2018-06-25
      • 1970-01-01
      相关资源
      最近更新 更多