I have a Ubuntu
LAMP
site hosted at vps.net
.
I have a directory called john
that is accessible via mysite.com/john
I would like it instead to be accessed via john.mysite.com
My site root is /var/www
and this directory is at /var/www/john
What do I need to do to make this happen?
Create a new site file at
/etc/apache2/sites-available/john.mysite.com
Set up the site something like this:
Enable the site with
a2ensite john.mysite.com
Reload apache to enable the site:
service apache2 restart
Apart from configuring Apache, don't forget also the DNS part: you will need a record for
john.mysite.com
, pointing to the same IP addressmysite.com
points to (if using an A record), or tomysite.com
itself (if using a CNAME record).These steps worked for me in Ubuntu 12.04 LTS x86_64:
You need to create a new site file at
/etc/apache2/sites-available/john.mysite.com.conf
The extension
.conf
is very important, without it, the rest won't work!!Then set up the site something like this:
Save the changes and enable the site with the command:
Reload apache to enable the site with:
Restart apache service:
sudo service apache2 restart
After that, you need to set up DNS to point to the site as well (as a Subdomain), DNS will take some time but in my experience it only takes a few minutes (15).
Hope this helps!! :)
you need to create a vhost for your webserver (assuming apache) that has at least the following info
this is not a definitive vhost file but is a starting point, it should go in the bottom of your httpd.conf file or wherever your system manages vhosts