11

So I tried to start my apache2 server with the following command...

sudo service apache2 start

But then I get this error message...

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

So when I try and see the systemctl, I get this...

● 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/ on my browser also gives me an error which means apache is not running.

When I do this...

sudo restart apache2

I get this error...

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

Somebody please help.

2

2 Answers 2

5

I think for some reason you deleted envvars config file

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

So you have to create it and paste the content from here (default content for this file)

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

Then restart apache service as usual

sudo service apache2 restart
1

I had the same problem, I made changes in apache.conf file for some reason, which leads me to the same error as you.

I have reinstalled Apache server, now everything is working fine.

Use the following commands:

  1. Uninstall Apache:

    sudo apt-get remove apache2*
    
  2. Install Apache

    sudo apt-get install apache2
    
  3. Restart server

    sudo service apache2 restart
    
2
  • @arnaudbey: Could you please review my edits and also review the editing help to improve your own edits in the future... ;-)
    – Fabby
    Aug 17, 2015 at 9:05
  • 2
    Without checking log file direct suggesting someone to remove and reinstall apache2 might bring huge data loss to someone. Apr 10, 2017 at 11:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.