I am looking to create links on my website like support.mydomain.com or management.mydomain.com rather than mydomain.com/support etc. I have heard you can do it with apache virtual hosts but I am not sure how I would set it up.
I am on apache 2.4 and ubuntu 16.04
Best Answer
The Apache2 distribution comes with a very easy to use modular configuration.
Copy your
000-default.conf
in/etc/apache2/sites-available
to a file by then name you will call your virtual site. Use the configuraton file000-default.conf
as a template.In this case you have indicated
mydomain.com
. You also indicatedmanagement.mydomain.com
. You can use both to refer to access the same site. In these steps I'll usemydomain.com
.You can use any name for the configuration file. Using a name that includes the name you'll for your virtual host will make it easier to manage your sites if you make a number of them.
Run these steps. I numbered them to make it easy for you to point out which step, if any, you get stuck or don't understand. The
$
is there to represent the terminal prompt where you type your command. The command is the text you see after the$
prompt.Change from:
Change to:
Continue the following commands to activate the changes:
With those steps, you can now access your new virtual host by typing the name you have given it into the web browser.
Place your webcontent (your html files) into the directory you created for your virtual host. In this example it's:
/home/web/www
. Your web directory can be placed anywhere on your system. You just need to configure your virtual host config file with the information.Anytime you make a change to your Apache2 configuration files be sure to reload it to make the changes become effective.