• Register
0 votes
206 views

Problem :

I am trying to restart my apache from terminal using the following command:

sudo service apache2 restart

But when executing above command I am facing below error:

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

On executing the "systemctl status apache2.service" I got below output

apache2.service - (null)
   Loaded: loaded (/etc/init.d/apache2)
   Active: failed (Result: exit-code) since Mon 2019-12-16 02:22:41 IST; 12s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 4866 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

Please find below my apache error.log

AH00489: Apache/2.4.12 (Unix) configured -- resuming normal operations
AH00094: Command line: '/usr/local/apache2/bin/httpd'
6 5 3
7,540 points

2 Answers

0 votes

Solution :

The problem is occurring because of some configuration files are deleted, so you have to reinstall them as below.

REINSTALL THE APACHE2:

To replace your configuration files that have been deleted, and without purging your package, you can do as below :

sudo apt-get -o DPkg::Options::="--force-confmiss" --reinstall install apache2

To fully remove your apache2 config files, you should try:

sudo apt-get purge apache2

Which will then allow you to reinstall it in the usual way with below command:

sudo apt-get install apache2

Purge is required when you want to remove all the config files - if you delete just the config files but you only remove the package, then this is remembered & the missing config files are not reinstalled by default.

Then REINSTALL PHP5 as below :

apt-get purge libapache2-mod-php5 php5 && \
apt-get install libapache2-mod-php5 php5
9 7 4
38,600 points
0 votes

Solution:

Maybe this will help to trace the reason:

journalctl | tail

In my instance it was a mistake in the configuration file:

AH00526: Syntax error on line 5 of /etc/apache2/sites-enabled/mydomain-wsf.lan.conf

There is few syntax error in the file apache2.conf.

In a terminal, type:

cd /etc/apache2

Then:

apache2ctl configtest

It will display you where is the error in the apache2.conf file to correct

The issue is since few configuration files are deleted, you have to reinstall it.

REINSTALL APACHE2:

To replace configuration files that have been deleted, without purging the package, you can work:

sudo apt-get -o DPkg::Options::="--force-confmiss" --reinstall install apache2

To totally remove the apache2 config files, you must:

sudo apt-get purge apache2

which will then let you reinstall it in the simple method with:

sudo apt-get install apache2

Purge is necessary to remove all the config files - in case you delete the config files however just remove the package, then this is remembered & missing config files are not reinstalled by default.

Then REINSTALL PHP5:

apt-get purge libapache2-mod-php5 php5 && \
apt-get install libapache2-mod-php5 php5

I got the similar error after removing a virtual host. The problem was the lingering SSL conf file attached with that host located in /etc/apache2/sites-enabled. The SSL was through Let's Encrypt hence the code for me to remove was:

sudo rm yourdomain.com-le-ssl.conf

in case you use

sudo apt-get install apache2

to install Apache2

10 6 4
31,120 points

Related questions

0 votes
1 answer 100 views
100 views
Problem : I have installed the fresh copy of the Centos 7. Then I just restarted Apache but my Apache failed to start. I am stuck with the bellow error from past 5 days. Even my support could not figure out the below error. sudo service httpd start Failed to ... could not bind to address 85.25.12.20:xx Jan 04 16:08:02 startdedicated.de httpd[5710]: no listening sockets available, shutting down
asked Jan 10 alecxe 7.5k points
0 votes
1 answer 39 views
39 views
Problem : I got below problem which I am trying to fix from the few days now and I am unable to know what should I do, I am looking for the answers but all of those which I found are of no use for me. I am very new here so I really hope that somebody can help me in resolving my error $ ... ------------ f...e) Jan 05 13:23:33 startdedicated.com nginx[8315]: nginx: [emerg] bind() to ----- f...e)
asked Jan 6 alecxe 7.5k points
1 vote
1 answer 52 views
52 views
Problem : I am facing the problem which I am trying to fix from the couple of days now and still I don't know what should I do, I am searching for answers but all of those I came across are of no use to me. I am very new here and I am really hopeful ... systemd/system/nginx.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Sun 2019-12-29 13:23:35 GMT; 2min 20s ago
asked Dec 30, 2019 alecxe 7.5k points
0 votes
1 answer 40 views
40 views
Problem : I have just installed the Apache 2.2.17, and I am using it first time. Now when I try to start my server using a command service httpd start it gives me the below message: httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ... a IP address as I search through Google. But I don't know in which file I have to set it. How can I fix above problem?
asked Jan 17 jwilliam 3.9k points
1 vote
1 answer 216 views
216 views
Problem : We are now running the 32-bit Windows server 2008 with the IIS version of 7. We are trying to publish the asp.net 4.0 webapp but so far our attempts have failed and only yielded the few warnings in our serverlog without even the stopping our 4.0 application ... very badly after that we ran out of the ideas on what to do on our issue so any form of the input would be greatly appreciated.
asked Dec 30, 2019 alecxe 7.5k points