3

Last time I try add new domain on localhost and I leave it on few weeks so now I try run my apache this command /etc/init.d/apache2 start and I get error

[....] Starting apache2 (via systemctl): apache2.serviceJob for apache2.service failed. See "systemctl status apache2.service" and "journalctl -xe" for details.
 failed!

If i tried to do reinstall apache2 but it is still not work.

2

9 Answers 9

8

I just did these two lines.It worked.

Two web servers cannot be active on the one port at the same time

this code for apache & nginx:

or

if error journalctl -xe used this code

sudo apt-get install psmisc
sudo lsof -t -i tcp:80 -s tcp:listen | sudo xargs kill
7

Virtual Host configuration might cause this error

I solved this same problem by configuring my virtual host .conf files properly.

I created a virtual host & then removed the exapmle.conf file form /etc/apache2/sites-avalable/ but I didn't deleted the examle.conf file from /etc/apache2/sites-enabled/ for this reason i was getting this error.

Then I removed the example.conf file from both the folders( ../sites-enabled & ../sites-available ) and solved this issue.

If you tried to setup any virtual host recently, then try this solution.

Best of Luck

7

Kill the running process on the port. Hope it will work!

sudo apt-get install psmisc
sudo fuser 80/tcp
sudo lsof -i tcp:80
sudo lsof -i tcp:80 -s tcp:listen
sudo lsof -t -i tcp:80 -s tcp:listen | sudo xargs kill
2
  • I just did these two lines : sudo apt-get install psmisc sudo lsof -t -i tcp:80 -s tcp:listen | sudo xargs kill
    – Netwons
    Nov 2, 2020 at 18:13
  • Save my whole Day Thanks you so much !!!! Apr 5, 2022 at 17:04
2

Go

sudo nano /etc/apache2/apache2.conf

remove this line:

Include /etc/phpmyadmin/apache.conf

Then

service apache2 start/restart
2

This problem may be a result of some configuration files in apache missing. One of the solutions would be to purge the apache2 file. You can type:

sudo apt-get purge apache2

Then reinstall apache2 by typing:

sudo apt-get install apache2

0

As stated in the error message, we just have to execute :

systemctl status apache2.service

or

journalctl -xe

And you will have more detail about the error (line of the error, or command misspelled, or module not included in the configuration, ...) : for example you can have following detail Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration ==> you then need to execute a2enmod ssl, and then execute service apache2 restart

Also I notice a difference between service apache2 reload and service apache2 restart commands. In case of persisting errors you should execute service apache2 restart, and then execute journalctl -xe.

0

You type

sudo netstat -pant

You check are you using port 80. If used, `

sudo service 'service_name' stop

and

sudo service apache2 start
0

The problem is because some configuration files are deleted.

You can use the following command to replace configuration files that have been deleted, without purging the package:

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

execute sudo service apache2 status and check the result. it might be trying to bind to a port that is already in use

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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