Set Up Apache Virtual Host on Ubuntu 14.04 LTS

We have to install apache2 for own server

# sudo apt-get update
# sudo apt-get install apache2

Create new folder for site

# sudo mkdir -p /var/www/

If you would like change permission you do that

# sudo chown -R $USER:$USER /var/www/

 Add read access www folder

# sudo chmod -R 755 /var/www

Create a page

# sudo nano /var/www/

Insert this text into index.html file:

<title>Welcome to!</title>
<h1>Success! The virtual host is working!</h1>

You need create a Virtual Host file (in older version 000-default.conf was simple default file, but in the new version we have to use the new, and *.conf extension)

# sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/

Edit config file

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

In the simple config file we can see like this


Apache2 default config file

Add new lines to config file, and if you want, delete comments.
“ServerName” is usually your domain name like in IIS hostheader
“ServerAlies” this is a alternative name, this help matching for example www a record
“DocumentRoot” is a place where you going to store your website (in this example index.html)

<VirtualHost *:80>

DocumentRoot /var/www/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined


We have to enable site

# sudo a2ensite

Restart service

# sudo service apache2 restart

After restart you will see something like this

* Restarting web server apache2
AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using Set the ‘ServerName’ directive globally to suppress this message

Don’t worry, this is OK.

I checked my site on server

Edit host file, add you server’s ip address into host file

# sudo nano /etc/hosts


Check: ping, and if you getting answer, your host file settings are ready

# w3m (w3m is a command line browser, i checked my site by this tool)

press “q” to quit from w3m browser

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.