Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to restart apache2 server on ubuntu 14.04

I am trying to install PHP and apache2 in my ubuntu 14.04. I installed PHP and apache2 through the following commands

  $sudo apt-get install php5-cli
  $sudo apt-get install apache2-bin

Now I just want to restart apache2 server on ubuntu system. But I am getting the "failed" error while restarting apache2. I mentioned the error below

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1.

Set the 'ServerName' directive globally to suppress this message

Can anyone help me to solve this error?

I need to restart my apache2 server on ubuntu 14.04.

like image 445
Python Team Avatar asked Jun 24 '14 09:06

Python Team


3 Answers

The problem has nothing to do with the notice you are getting Try

tail -f  /var/log/apache2/error.log

Or similar location on you system to check the Apache error log. This will clearly tell you where the error is. The most frequent one I get is that the log directory that I specified in the vhost configuration is missing

As of the notice, add

ServerName localhost

to your configuration and it will be gone. In case your hostname is not localhost run

hostname

to learn what it is and then update ServerName directive with the proper value

On ubuntu the Apache conf file is in

/etc/apache2/apache2.conf

like image 60
Vladimir Hraban Avatar answered Oct 21 '22 13:10

Vladimir Hraban


The following two lines in terminal worked for me.

1.echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/fqdn.conf

2.sudo ln -s /etc/apache2/conf-available/fqdn.conf /etc/apache2/conf-enabled/fqdn.conf 

Hope this fixes your problem too.

like image 20
Sumit Nautiyal Avatar answered Oct 21 '22 12:10

Sumit Nautiyal


You need to set a global Apache setting that stores ServerName localhost (assuming localhost is your hostname - if you are unsure, you can simply run hostname to see).

Whilst a lot of people will say to add this to the end of /etc/apache2/httpd.conf or /etc/apache2/apache2.conf (depending on your version), this file will be overwritten if you update Apache at any point.

Apache allows you to have multiple configuration files enabled, and so I prefer to create a standalone file that stores this information, and to load it as well.

# Create a new config file, writing `ServerName localhost` to it
echo "ServerName localhost" | tee /etc/apache2/conf-available/servername.conf
# Enable the new config file
a2enconf servername
# restart the server
service apache2 restart

Note that you may need sudo for each of those commands if you are not using a root user. This should work on Debian / Ubuntu and you'll notice the message has disappeared on reboot.

like image 1
Warren Sergent Avatar answered Oct 21 '22 12:10

Warren Sergent