How to Install Apache on Ubuntu 14.04

This is first tutorial of this series , In this series I will showing you how to setup Apache PHP and MySQL Database on ubuntu 14.04 trusty step by step . this is just beginner level series .



The Apache HTTP Server, Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation. Most commonly used on a Unix-like system . is most used web server and has many features like virtual-hosting and ssl support etc.


sudo apt-get update 
sudo apt-get install apache2

Configuration File Info

Config FileINFO
/etc/apache2/apache2.confmain config files , global settings
/etc/apache2/conf-availabledirectory of available configuration files
/etc/apache2/conf-enableddirectory of enabled configuration files
/etc/apache2/mods-availabledirectory of available mods ( modules ) files
/etc/apache2/mods-enableddirectory of enable mods ( modules ) files
/etc/apache2/sites-availableavailable site based configuration files
/etc/apache2/sites-enabledenabled site configuration
/etc/apache2/ports.conflistening port configuration
/etc/apache2/envvarsApache2 environment variables
/etc/apache2/magicinstruction for MIME Types


lets create sample site

lets remove default availble site and copy default avaible site info to our new site

sudo rm -rf /etc/apache2/sites-enabled/000-default.conf
sudo cp /etc/apache2/sites-available/000-default.conf  /etc/apache2/sites-available/

open /etc/apache2/sites-enabled/ with your favorite editor , I am going to use nano

sudo nano /etc/apache2/sites-available/

Sample Config :

<VirtualHost *:80>
 # The ServerName directive sets the request scheme, hostname and port that
 # the server uses to identify itself. This is used when creating
 # redirection URLs. In the context of virtual hosts, the ServerName
 # specifies what hostname must appear in the request's Host: header to
 # match this virtual host. For the default virtual host (this file) this
 # value is not decisive as it is used as a last resort host regardless.
 # However, you must set it for any further virtual host explicitly.
 DocumentRoot /var/www/html
 # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
 # error, crit, alert, emerg.
 # It is also possible to configure the loglevel for particular
 # modules, e.g.
 #LogLevel info ssl:warn
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
 # For most configuration files from conf-available/, which are
 # enabled or disabled at a global level, it is possible to
 # include a line for only one particular virtual host. For example the
 # following line enables the CGI configuration for this host only
 # after it has been globally disabled with "a2disconf".
 #Include conf-available/serve-cgi-bin.conf

Apache Sample Config

lets enable and restart apache server to take effect

#Now let's make that site available 

sudo ln -s  /etc/apache2/sites-available/  /etc/apache2/sites-enabled/

# or use 
sudo a2ensite 

# restart apache 

sudo service apache2 restart

Now put some html files in /var/www/html and browse to ( setup /etc/hosts for that or use IP address instead )


How to install apache in ubuntu

useful links

Tagged With : -
Add Comment