• Register
0 votes
516 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

Please log in or register to answer this question.

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 2 views
2 views
Problem: Do you have any suggestions about how I can resolve this? Thank you so much!
asked 2 days ago zayed1 35.6k points
0 votes
1 answer 219 views
219 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, 2020 alecxe 7.5k points
0 votes
1 answer 98 views
98 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, 2020 alecxe 7.5k points
1 vote
1 answer 90 views
90 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 61 views
61 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, 2020 jwilliam 3.9k points
0 votes
1 answer 2 views
2 views
Problem: I can't seem to find a solution; could you please help me “Httpd.service: control process exited, code=exited status=1”?
asked Apr 1 rakib1 51.5k points
0 votes
1 answer 12 views
12 views
Problem: Hello Kodlogs, I want to make a Python program that will ask the user for a restart or end the program itself. I googled a bit to get an idea for this type of execution and gather some pieces of information. After researching a bit understand, I need to ... OS module from the library. How can I proceed further? Could you please help me on this regard? I am expecting your answers. Thanks.
asked Jul 4, 2020 adamSw 11.3k points
0 votes
1 answer 4 views
4 views
Problem: Error is occurring: Not Found The requested URL /phpmyadmin was not found on this server. Apache/2.2.22 (Ubuntu) Server at myclassbook.in Port 80 Where am I going wrong?
asked Mar 20 ummesalma 25.2k points
0 votes
1 answer 6 views
6 views
Problem: namevirtualhost *:80 has no virtualhosts. make me clear what is this all about.
asked Mar 14 Ethan ross 2.7k points
0 votes
1 answer 13 views
13 views
Problem: invalid mutex directory in argument file:${apache_lock_dir}
asked Feb 17 charles mathews 5.5k points