Apache(http) installation & configuration on Red Hat @ Ubuntu
magnet November 26th, 2008
Apache on Red Hat Linux
Intoduction Of Apache
Apache is the name of the software that allows you to run a web service.Apache is very popular and provides access to most web sites on the internet.Apache complies with the Hypertext Transport Protocol (HTTP).
Apache is a Application which works on HTTP protocol.
Configuration of Apache(HTTP) on Red Hat
First install http package with the help of yum.
# yum install http*
Then go on configuration file
# vi /etc/httpd/conf/httpd.conf
here come to bottom of file & edit these lines to create a web site
#NameVirtualHost *
#
#<virtual hosts *>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</virtual hosts>
In first line at the place of * add the IP Address of your machine on which you are creating apache.
In second line ServerAdmin give Email ID, this will help you when http will give any problem.
Here http will send message on this Email ID.It will be help full for system admin to solve the
problem.
Now DocumentRoot:-
DocumentRoot is a (folder) that is stored on your host’s servers and that is designated for holding web pages. When someone else looks at your web site, this is the location they will be accessing.
Default DocumentRoot is /var/www/html
Now we come to the ServerName:-
ServerName specifies a hostname and port number (matching the Listen directive) for the server. The ServerName does not need to match the machine’s actual hostname. For example, the Web server may be www.example.com, but the server’s hostname is actually foo.example.com. The value specified in ServerName must be a valid Domain Name Service (DNS) name that can be resolved by the system.
Example:- ServerName www.suraj.com
ErrorLog:- Log will be generated here regarding http adversities.
CustomLog:-
CustomLog identifies the log file and the log file format. In your Web server’s default configuration, CustomLog defines the log file in which accesses to your Web server are recorded: /var/log/httpd/access_log. You will need to know the location of this file if you want to generate any access-based server performance statistics for your Web server.
CustomLog also sets the log file format to common.
Note:- To edit these all line you will have to remove # to enables the lines.because lines are commented by hash(#).
By doing this editing & configuration in this file we can
host any web site.
Note:- if http is already installed you can omit the first line. Your web files will now be found in /var/www/
Consept Of Virtual Hosting
Virtual Hosting:- Virtual hosting means we can create two or more then two web sites on single server.
To enable virtual host enable the <NameVirtualHost *> line by removing the commenet hash(#).And give your ystem IP at the place of star(*).
Now you can create more web sites on single server.
Ubuntu
Installation and configuration of apache(http) in Red Hat & Ubuntu is some thing different,like commands,configuration files etc.
Installation of apache in ubuntu
Installing package of Ubuntu is .deb
apt-get:-
# apt-get install apache2
# apt-get install php5
# apt-get install libapache2-mod-php5
Configure apache2
Apache2 configuration file in Ubuntu is usually found in this location /etc/apache2/apache2.conf.
Apache is configured by placing directives in plain text configuration files. Apache2 ships with a virtual-host-friendly default configuration. It is configured with a single default virtual host.
If you wish to configure a new virtual host or site, copy /etc/apache2/sites-available/default file into the same directory with a new name. For example,
“sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mynewsite”
Edit the new file to configure the new site:
To start using New Virutal Host we have to modify at least two directives.
1. ServerName (Put your domain name here)
2. DocumentRoot (path to website)
The /etc/apache2/sites-available directory is not parsed by Apache2. Symbolic links in /etc/apache2/sites-enabled point to “available” sites. Use the a2ensite (Apache2 Enable Site) utility to create those symbolic links.
Change the directory to
“cd /etc/apache2/sites-enabled”
“sudo a2ensite mynewsite”
Similarly, the a2dissite utility should be used to disable sites.
We should be all set to run apache2 server in Ubuntu.
The above configuration will work only if certain modules are enabled. Usually the required modules are available in the default apache2 configuration file.
After do the configuration in file we will have to restart service to save configuration.
Restart apache service:
#/etc/init.d/apache2 restart
Note:- if apache is already installed you can omit the first line. Your web files will now be found in /var/www/

