Miralem Cebic
Miralem Cebic

Reputation: 1286

$ service apache2 restart [fail]

I have installed Apache on my Ubuntu Server. For a special reason I have to enable mod_rewrite on it. So I have done this.

And in every Tutorial on the internet the last command is to restart apache. But when I do this the console prints [fail].

Can anyone help me here?

$ service apache2 restart 
 * Restarting web server apache2      [fail] 

Upvotes: 44

Views: 104154

Answers (6)

I face this issue when I was adding new web site to my web server which is hosted in Digital Ocean Cloud service. So what happened was, when I using sudo commands to restart or reload apache2 server its restring with following error messages.

For me everything worked well despite these two error messages.

  1. Error 1 - Unable to resolve host 'YOUR HOST NAME' .
  2. Error 2 - sum_functio_error() //I don't remember this function name I'll update this later.

So the fix was very simple.

First open your hotsts file.

sudo nano /etc/hosts

Output File

127.0.1.1 hostname 127.0.0.1 localhost

sudo nano /etc/hostname

Output File

hostnamexxx

Upvotes: 1

Dilip Hirapara
Dilip Hirapara

Reputation: 15296

Try below command to restart.

# /etc/init.d/apache2 restart

OR

$ sudo /etc/init.d/apache2 restart

OR

$ sudo service apache2 restart

To stop Apache 2 web server, enter:

# /etc/init.d/apache2 stop

OR

$ sudo /etc/init.d/apache2 stop

OR

$ sudo service apache2 stop

To start Apache 2 web server, enter:

# /etc/init.d/apache2 start

OR

$ sudo /etc/init.d/apache2 start

OR

$ sudo service apache2 start

Upvotes: 0

hardik beladiya
hardik beladiya

Reputation: 287

There are various reason for this one .

  1. could be the privilege problem if you have privilege problem then please use sudo for the same .
  2. could be the apache already running in your system then please check the status of the service by running command service apache2 status if they said that [FAIL] apache2 is not running ... failed! it mean it is not running you can start by the command service apache2 start or sudo service apache2 start
  3. if you having not above problem please look at the PID file of apache2 by following command cat /var/run/apache2/apache2.pid which will give you the process ID of the apache it means you system accidentally shutdown without deleting the PID file so delete by following command rm - rf/var/run/apache2/apache2.pid or sudo rm -rf/var/run/apache2/apache2.pid and start again the server by following command service apache2 start or sudo service apache2 start

Upvotes: 4

GAD3R
GAD3R

Reputation: 4625

Using the systemd features ( starting from Ubuntu 15) , you can restart apache service as follow :

sudo systemctl restart apache2.service

Check the status:

sudo systemctl status apache2.service

Upvotes: 4

Sudarshan
Sudarshan

Reputation: 8664

I had a similar problem, and for me it was about the logged in user not having privileges so instead of

service apache2 restart

I had to do

sudo service apache2 restart

Upvotes: 81

s4suryapal
s4suryapal

Reputation: 1960

It's telling you some other service is already on port 80, perhaps it's apache

try Code:

sudo /etc/init.d/apache2 stop

followed by Code:

sudo killall apache2

then make sure no services are running on port 80 Code:

sudo netstat -l|grep www

then (re)start apache Code:

sudo /etc/init.d/apache2 restart

Upvotes: 47

Related Questions