Apache2 is the most popular Web Server Implementation for Ubuntu Server 14.04. In This Tutorial we are going to learn how to install Apache on Ubuntu Server 14.04. In Addition to installing Apache on Ubuntu Linux, we will also learn how to create and configure Apache Virtual Host and host a simple static website on Ubuntu Server.
Apache web server for Ubuntu Linux provides by the apache2 package. We can install Apache2 on Ubuntu using apt-get install command.
sudo apt-get update
sudo apt-get install apache2
Then start the Apache web server using service command.
sudo service apache2 start
Now if you type your server IP address on the web browser you should get the Ubuntu Apache2 default web page.
So now let’s see how to host a static website on Ubuntu Apache Server. For this tutorial I am going to use the domain name www.example.com. And I am going to host www.example.com in /var/www/example folder.
First, create the folder /var/www/example using the mkdir command.
sudo mkdir /var/www/example
Then we need to make apache group www-data as the group owner of the /var/www/example folder and also give write permission to the group.
sudo chgrp www-data /var/www/example/
sudo chmod g+rwX /var/www/example/
sudo chmod g+s /var/www/example/
We configured document root for the our domain name www.example.com, now we need to create the apache virtualhost for the www.example.con domain.
Ubuntu Apache Virtual Host Configuration file should be create inside the /var/www/site-availe directory using .cong extension.
touch /etc/apache2/sites-available/example.conf
Now open example.conf file we created, using a text editor and add the following virtual host configuration.
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/example/
ErrorLog /var/log/apache2/example.com.error
CustomLog /var/log/apache2/example.com.access combined
Now we need to enable the virtual host using a2ensite command. Then restart the apache server using service command.
sudo a2ensite example.conf
sudo service apache2 restart
Ok, now we have configured the apache virtual host for our domain name www.example.com. Now all we have to do is put content of the Website to /var/www/example folder and point www.example.com to our server IP address using DNS.
Just like that you can create as many virtual hosts as you want and host multiple website on your Ubuntu server.
In this tutorial learned how to install and configure a basic Web server on Ubuntu Linux 14.04 using Apache Web Server.
First, we Installed Apache on Ubuntu 14.04 using apt-get install command. Then we learned to configure Apache Virtual Host on Ubuntu Linux to host multiple Web sites.
At Canonical, the work of our teams is strongly embedded in the open source principles…
Welcome to the Ubuntu Weekly Newsletter, Issue 873 for the week of December 29, 2024…
Have WiFi troubles on your Ubuntu 24.04 system? Don’t worry, you’re not alone. WiFi problems…
The following is a post from Mark Shuttleworth on the Ubuntu Discourse instance. For more…
I don’t like my prompt, i want to change it. it has my username and…
Introduction: A Fragile Trust The Ruby ecosystem relies heavily on RubyGems.org as the central platform…