Apache无法启动


9

所以我试图用以下命令启动我的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:// localhost /也给我一个错误,这意味着apache没有运行。

当我这样做时...

sudo restart apache2

我收到此错误...

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

有人请帮忙。



如果有错误也会发生这种情况在配置文件中像apache2.conf ...
Sudip班达

Answers:


4

我认为出于某些原因您删除了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

1

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

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

使用以下命令:

  1. 卸载Apache:

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

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

    sudo service apache2 restart
    

@arnaudbey:能否请您检查我的编辑内容,并查看编辑帮助以将来改进您自己的编辑内容… ;-)
Fabby 2015年

1
如果不直接检查日志文件,则建议某人删除并重新安装apache2可能会给某人带来大量数据丢失。
MAK Ripon
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.