Reputation: 1286
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
Reputation: 466
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.
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
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
Reputation: 287
There are various reason for this one .
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
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
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
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
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