Virtual Domain Configuration

Virtual domains, alias, hidden directories, configurations and logs etc..
fabiodelorenzo
Posts: 65
Joined: Thu Oct 03, 2013 5:54 pm

Virtual Domain Configuration

Postby fabiodelorenzo » Sat May 30, 2015 12:41 pm

Apache Virtual Hosts on Ubuntu 14.04 LTS

Virtual host files are the files that specify the actual configuration of our virtual hosts and dictate how the Apache web server will respond to various domain requests.

Apache comes with a default virtual host file called 000-default.conf that we can use as a jumping off point.
We are going to copy it over to create a virtual host file for each of our domains.

We will start with one domain, configure it, copy it for our second domain, and then make the few further adjustments needed.
The default Ubuntu configuration requires that each virtual host file end in .conf.

Start by copying the file for the first domain:

Code: Select all

sudo su
cd  /etc/apache2/sites-available/
cp 000-default.conf example.com.conf


edit the file to something like:

Code: Select all

<VirtualHost *:80>
    ServerName mydomain.com
    ServerName http://www.mydomain.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>



Enable the New Virtual Host Files

Code: Select all

cd  ../sites-enabled
ln -s ../sites-available/example.com.conf .


Restart Apache

Code: Select all

sudo service apache2 restart

Return to “apache http server”

Who is online

Users browsing this forum: No registered users and 1 guest