Restarting Apache Server - Ubuntu

February 11, 2015 56.2k views

I tried to restart

It says "Could not reliably determine the server's fully qualified domain name. Using Set the 'Servername' directive globally to suppress this message ".

I haven't pointed any domain to my IP yet. I am trying to restart apache is because of minor changes in php.ini file.

How can I restart apache2 successfully ? or How to make php.ini changes to work.

  • service apache2 restart will restart apache successfully on the majority of operating systems.

  • this seemed to worked for me:

    sudo nano /etc/apache2/conf-available/localhost.conf

    and then add this line:

    ServerName localhost

    save, exit, and then enable the conf

    sudo a2enconf localhost
    sudo service apache2 restart
  • Thank you for this @enok

6 Answers

Just had the same issue, resolved it by following sierracircle's instructions except that I edited this file:

sudo nano /etc/apache2/apache2.conf

To fix that problem, you need to create an httpd.conf file.

From the terminal:
sudo nano /etc/apache2/httpd.conf
the file will be blank...add the following line:

ServerName localhost

Save the file and exit nano.(I think it is crtrl X in nano)

Finally restart the server.:
sudo service apache2 restart

Hmm, that did not work for me. I tried localhost, the IP address of my server, and the domain for that server. No luck.

  • echo "ServerName YOUR SEVER IP" | sudo tee /etc/apache2/conf-available/fqdn.conf && sudo a2enconf fqdn

I'm wondering if sierracircle isn't being specif enough about the apache directive ServerName. Does it need to be in some sort of xml block or something?

Have another answer? Share your knowledge.