Apache 未启动

Apache 未启动

因此我尝试使用以下命令启动我的 apache2 服务器...

sudo service apache2 start

但后来我收到了这个错误信息......

Job for apache2.service failed. See "systemctl status apache2.service" and "journalctl -xe" for details.

因此,当我尝试查看 systemctl 时,我得到了这个......

● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2)
   Active: failed (Result: exit-code) since Mon 2015-07-06 10:34:49 IST; 4min 23s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 8899 ExecStart=/etc/init.d/apache2 start (code=exited, status=2)

Jul 06 10:34:49 archisman-HP-ProBook-440-G2 systemd[1]: Starting LSB: Apache2 web server...
Jul 06 10:34:49 archisman-HP-ProBook-440-G2 apache2[8899]: /etc/init.d/apache2: 64: .: Can't open /etc/apache2/envvars
Jul 06 10:34:49 archisman-HP-ProBook-440-G2 apache2[8899]: /etc/init.d/apache2: 76: .: Can't open /etc/apache2/envvars
Jul 06 10:34:49 archisman-HP-ProBook-440-G2 apache2[8899]: ERROR: APACHE_PID_FILE needs to be defined in /etc/apache2/envvars
Jul 06 10:34:49 archisman-HP-ProBook-440-G2 systemd[1]: apache2.service: control process exited, code=exited status=2
Jul 06 10:34:49 archisman-HP-ProBook-440-G2 systemd[1]: Failed to start LSB: Apache2 web server.
Jul 06 10:34:49 archisman-HP-ProBook-440-G2 systemd[1]: Unit apache2.service entered failed state.
Jul 06 10:34:49 archisman-HP-ProBook-440-G2 systemd[1]: apache2.service failed.

http://本地主机/我的浏览器也出现错误,这意味着 apache 没有运行。

当我这样做时...

sudo restart apache2

我收到这个错误...

restart: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused

请有人帮忙。

答案1

我认为由于某种原因你删除了 envvars 配置文件

Jul 06 10:34:49 archisman-HP-ProBook-440-G2 apache2[8899]: /etc/init.d/apache2: 64: .: Can't open /etc/apache2/envvars
Jul 06 10:34:49 archisman-HP-ProBook-440-G2 apache2[8899]: /etc/init.d/apache2: 76: .: Can't open /etc/apache2/envvars

因此,您必须创建它并粘贴来自这里(此文件的默认内容)

sudo touch /etc/apache2/envvars
sudo nano /etc/apache2/envvars

然后照常重启 apache 服务

sudo service apache2 restart

答案2

我遇到了同样的问题,我apache.conf file出于某种原因做出了更改,这导致我遇到与您相同的错误。

我已经重新安装了 Apache 服务器,现在一切运行正常。

使用以下命令:

  1. 卸载 Apache:

     sudo apt-get remove apache2*
    
  2. 安装 Apache

     sudo apt-get install apache2
    
  3. 重启服务器

     sudo service apache2 restart
    
  4. 如果您看到错误“没有可用的监听套接字,正在关闭”,请将端口更改为 8080 或 /etc/apache2/ports.conf 文件下的其他端口,这可能是由于 TCP 端口 80 已被另一个程序使用。

相关内容