0

I just updated from Ubuntu 8.04 to the newest version and all of a sudden my virtual hosts don't work anymore. I'm not sure what changed, but I know when I type in localhost it doesn't go to the directory that I would expect (probably the default /var/www/ but that's not where I keep my projects) and typing in the name of one of my virtual hosts takes me to the same place. How do I get it working again?

4 Answers 4

1

You may have added your virtual hosts to /etc/apache2/httpd.conf or something like this, and the file was overwritten on update (you were prompted!). Check if you still have your virtual hosts in /etc/apache2/sites-available (one host per file) and that have valid resolvable symlinks in /etc/apache2/sites-enabled: this is the right way to add them in Ubuntu (I believe, in all Unix systems that's common: a great idea to have them separate rather than piling in a single file!).

1

Turns out the update sort of reset things back to default. Here's what I did to get it to work (This worked for me on Ubuntu 9.10 Karmic Koala):

  1. The localhost directory was set to /var/www so to change that you will need to edit the default virtual host config file in /etc/apache2/sites-available. Make sure to change both the DocumentRoot and <Directory > values.

    sudo nano /etc/apache2/sites-available/default
    
  2. To create a virtual host, create a file in /etc/apache2/sites-available

    sudo nano /etc/apache2/sites-available/mysite
    

    Here's an example of what you should put in the virtual host file:

    <VirtualHost *:80>
        ServerName myvirtualhostname
        ErrorLog /var/log/apache2/myvirtualhostname-error.log
        CustomLog /var/log/apache2/myvirtualhostname-access.log combined
        DocumentRoot /home/name/Projects/myvirtualhostname/public
        <Directory /home/name/Projects/myvirtualhostname/public>
            Options FollowSymLinks
         AllowOverride All
        </Directory>
    </VirtualHost>
    
  3. Next you will want to enable your virtual host. You can do so by running the "Apache 2 Enable Site" command with the name of the file you created in sites-available:

    sudo a2ensite mysite
    
  4. You may also need to add your virtual host name to your /etc/hosts file.

  5. Now restart Apache for it to take affect:

    sudo /etc/init.d/apache2 restart
    

Bonus! If you want to get rid of that message that says "Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName" you can create a config file in /etc/apache2/conf.d/ called fqdn with the value of ServerName localhost. You can do this in a single command like this:

echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn

For more information, check out setting up Apache, PHP, and MySQL on Ubuntu.

0

I don't have an Ubuntu-specific answer for you, but you just need to check your httpd.conf for the DocumentRoot and set it as needed. Unless your vhost configs got wiped, then you'd need to recreate them.

0

This could be DNS related as well.

So what does it say when you say specifically http://localhost://

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .