Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am attempting to set up the LAMP environment for the first time. I normally use Windows and just install XAMPP.

I have followed the instructions on Ubuntu forums and have duplicated the file in sites-available.

Currently I can access my site via localhost, but not via either the ServerName or ServerAlias directive.

Here is the file in sites-avialable:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DirectoryIndex index.php
    DocumentRoot /home/username/example
    <Directory /home/username/example>
        Options FollowSymLinks
        AllowOverride None

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
    ServerSignature On
share|improve this question

you should enter to your /etc/hosts file and reload apache. You should also enable the virtual host with sudo a2ensite.


  • Add NameVirtualHost *:80 to you apache configuration. I add this in top of default in /etc/apache2/sites-available
  • Create a virtual host configuration file say example in /etc/apache2/sites-available
  • Enable it with sudo a2ensite example
  • Enter your ServerName to your /etc/hosts mapping it to
  • Restart/Reload apache2 with sudo service apache2 restart/reload

I think that ServerAlias is not that necessary

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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