[Wolves] I'm having a few difficulties setting up an Apache virtual host

James Turner james at turnersoft.co.uk
Fri Jan 10 02:29:46 UTC 2014


On 10/01/14 01:55, Mike Hingley wrote:
> I'm running Ubuntu 13.10 - which ships with Apache 2.4.6.
> 
> I've set up a virtual named host - localtuxsters.com - but it seems that
> apache is ignoring the host header and directing all traffic to the
> default host - 
> 
> anyone experienced that before?
> 
> Mike

Not specifically that I can recall, but perhaps the vhost isn't enabled?
(done with command "a2ensite" on Ubuntu/Debian systems) Full procedure
outlined below FYI

First create a file called
/etc/apache2/sites-available/localtuxsters.com (the exact choice of
filename being at your disgression, but I tend to match the name of the
web site for ease of keeping track), with contents along the lines of:

<VirtualHost *:80>
        DocumentRoot /srv/www/localtuxsters.com
        ServerAdmin webmaster at localtuxsters.com
        ServerName localtuxsters.com

        ServerSignature email
        DirectoryIndex index.html index.php index.htm index.shtml

        LogFormat "combined"
        TransferLog /var/log/apache2/localtuxsters.com-access_log
        ErrorLog /var/log/apache2/localtuxsters.com-error_log
</VirtualHost>

Create a directory to hold the web site files:

sudo mkdir /srv/www/localtuxsters.com

Now enable the web site:

sudo a2ensite localtuxsters.com

(Where localtuxsters.com is the name of the file you created earlier.)

...then instruct Apache to start using your updated configuration...

sudo invoke-rc.d apache2 reload

Finally make the name localtuxsters.com accessible by either:

 - setting up a record for it in /etc/hosts (will allow access just from
he machine that you modify the file on, typically used during
development and/or initial testing)

 - setting up a DNS record for it (e.g. once you've done the above to
confirm it's working)

At this point you should be able to place files in
/srv/www/localtuxsters.com, load up your web browser, navigate to
http://localtuxsters.com/ and see them.

Hope this helps,

James




More information about the Wolves mailing list