Installing & Configuring HTTPD/Apache on CentOS 6.4

HTTPD/Apache is generally recognized as the world’s most popular Web server (HTTP server). Originally designed for Unix environments. The Apache Web server provides a full range of Web server features, including CGI, SSL, and virtual domains. Apache also supports plug-in modules for extensibility. Apache is free software, distributed by the Apache Software Foundation that promotes various free and open source advanced Web technologies.

This time we will divide this tutorial in two parts:

1. IP-based Virtual Hosts

a. One site per IP address

b.Host Header Names – multiple sites per IP address | port combination

2. Name-Based Virtual Hosts

a. NameVirtualHost

b. Then bind to each virtual host

So lets begin fir IP-Based Virtual Hosts

Apache by default, maintains 2 virtual hosts: TCP:80, TCP:443 determined by : /etc/httpd/conf/httpd.conf

So let’s begin by demonstration how to install and configure HTTPD/Apache

Pathfinder environment for HTTPD are :

“ /etc/httpd “ – this is primary config container

“ /etc/httpd/config/httpd.conf “ – this is primary config file under CentOS also RedHat.

yum install httpd

rpm –qa | grep –I httpd – this will enumerate package that have been installed and the man package is market with Red-X


When you install apache , you need to start from files that are located at httpd

Lets navigate to the file and see what we have there

cd /etc/httpd

ls –l  – here you will see the symlink of the httpd –Apache – the

run – directory simply contain a reference

logs – reference simple when you can find apache logs


enter command to see if the apache is running

ps –ef | grep –I httpd

pf –ef | grep httpd

service httpd status

Apache is not running yet


As mentioned before there are two directory for HTTPD-Apache

Conf – there are main configuration files

Conf.d – in Linux when ever you see .d suffix it means that is container of items that are included for larger configuration

Now  lets start HTTPD and see what will happen

Service httpd start

We have receive and error – this doesn’t mean that Apache is not running this is just DNS resolution problem but we will try to eliminate what kind of error we will receive , that is good for troubleshooting


let’s try to fix this:

vi /etc/sysconfig/network – change hostname to your hostname


vi /etc/hosts


Now type

Hostname yourhostname ( in my case is gnubizz.local) – as you see the error is gone


Now let’s continue where we left

netstat – ntl | grep 80 – you can see that the server has started

netstat –ntlp | grep 80 – the program is responsible is httpd

ps –aux | grep httpd – As you see primary apache process starts as root and subsequent processes run as apache(non-privileged users) and its defined on /etc/passwd


Now Apache is running lets tray to access the default page of Apache – open your browser and type either localhost or ip of your server


Let’s go a little bit deep , let’s change this default page and by default html file is stored on:

cd /var/www/html

vi index.html – close and check with browser


Note: Every changes that you made to HTTPD – Apache , issue reload and restart , and delete history and cookies for browser

Service httpd restart


!serv – this is a tip for shorts , Linux will remember last commands so than you can use ! and short names or by numbers  to restart the services or execute commands

An example of !

enter history command

ps –aux | grep httpd




Now check with browser , you should have the same  page as it showing here


Now we need to enable services for multi-user runlevels

chkconfig –list httpd – will show you the list

chkconfig httpd on  – this will enable runlevels

chkconfig –list httpd – do you see the difference


We need to check Apache logs, this is important when troubleshooting because apache traps messages between the client and servers and to see access and errors messages

cd /var/logs/httpd – this is default location

Check the access file first you can see how many time we have try to access our created website

watch tail access.log – main time refresh the browser and access again, do not close terminal you will see that again you changes in the terminal

My network has 254 available ip , so by  this l can assign to any pc or server within my house

So the CentOS that l am using has gateway

First ip that l will assign to virtual interface will be – l hope that is available 🙂

Ping – l did not receive any replay this is good because l can see that this ip is available

ifconfig eth0:0


To have our website files in one place we need to create folders and give a name of our website

In my case l called my website site1.gnubizz.local ( your site you  can call as you wish )

mkdir /home/site1

mkdir /home/site1/www

cd /home/site1/www

vi index.html


Save and close

ls -l /home/site1 – to see who own the file , is owned by root , no need to owned by Apache , just read and write by apache that’s good


Now add a site1 and we need to be sure that Apache listens to

cd /etc/httpd/conf

vi site1.gnubizz.local.conf


save and close

Now navigate to :

vi /etc/httpd/conf/httpd.conf

As you can see here it’s already listen to port 80 , it tells here that it bind to all ip address


So we don’t want to bind to all ip addresses , we want to bind only to a specified ip address so that’s why we need to change


make symlink for site1

cd /etc/httpd/conf.d

ln –s ../conf site1.gnubizz.local.conf

service httpd restart

Note: incase you are facing problem accessing webpage you might check SElinux , pose problem when serving web content from: $HOME – so for temporary we need to disable

sestatus – check is Selinux is enabled

setenforce permissive

now point the browser with ip – you should see this


So that’s it , you can add another site if you want just follow same steps ( site2, site3 )

cp site1.gnubizz.local.conf site2.gnubizz.local.conf

vi site2.gnubizz.local replace 1 with 2

cp -apvf /home/site1/www/index.html  /home/site2/www/index.html

ls -l /home/site2

modify vi /home/site2/www/index.html

than modify the /httpd.conf and add ip address ( 192.168.x.x )

cd /etc/httpd/conf.d

ln -s ../conf/site2.gnubizz.local.conf

browse new site called site2

So that’s it IP-Based Virtual Host


Now lets begin with:

2. Name-Based Virtual Hosts

a. NameVirtualHost – we have already configured

b. Then bind to each virtual host –  we have already configured

Add a second Virtual interface


We need to modify httpd.conf file

vi /etc/httpd/conf/httpd.conf – this time we will allow  to bind and listen in port 80


Save and close

Go to site1

vi /etc/httpd/conf.d/site1.gnubizz.local.conf – make the following changes


Save and close

Modify site2

vi /etc/httpd/conf.d/site2.gnubizz.local.conf


Save and close

Add this two virtual host to :

vi /etc/hosts


Check the status/names of virtualhosts

httpd –S – you can see that is NameVirtualHost


Now try to access on browser by site name





Apache SSL | TLS with Self-Signet Certs – is ideal for intranet usage and default configuration includes self-signet certificates

yum install mod_ssl

yum install crypto-utils – check

we will generate a genkey for the host not for the website , l think is more appropriate for the defaults_:433   SSL site

type in terminal:

genkey gnubizz.local

click next


Select  2048 than Next – you have to wait sometime till the process finish


Click NO


We will not select this because every time any process that apache uses will require always  to be there and provide the password , it’s very secure of protecting your private key


Add information according your requirement


enter command to check who own the site1 directory

ls –l /home/site1


enter command to check site’s name and ssl.conf certificate


Make the changes on:

vi /etc/httpd/conf.d/ssl.conf


Now open the browser and check – you should have similar as shows in the pic

Select “ l Understand the Risks


Click on view


certificate has been issued


Note: The real key for this tutorial is  that you can issue your own self-cert or generate request via CA

So this is all , see you next time 🙂


Installing GNS3 0.8.5 on Ubuntu 13.10

There are two ways to install GNS3 on Ubuntu :

First one is by Synaptic Package  Manager , it will install GNS3 in the way he want , we will not have full control of GNS3

Second we can install manually by creating folders and having  a full access on files , than we will have full control of GNS3

So in this tutorial we will do the second one :

Lets first get the latest update 

sudo apt-get update

Than install the following dependencies:

sudo apt-get install python
sudo apt-get install qt4-dev-tools
sudo apt-get install pyqt4-dev-tools
sudo apt-get install libncurses5-dev zlib1g-dev libsdl-dev libpcap-dev

Now create folder and change  access permissions for GNS3 

cd /opt

sudo mkdir GNS3_Folder && sudo chmod 777 GNS3_Folder

cd GNS3_Folder
mkdir projects && chmod 777 projects
mkdir images && chmod 777 images
mkdir temp && chmod 777 temp
mkdir cache && chmod 777 cache
mkdir qemu && chmod 777 qemu
mkdir captures && chmod 777 captures
mkdir dynamips && chmod 777 dynamips

Now we need to download the packages :

cd /opt/GNS3_Folder


cd /opt/GNS3_Folder/dynamips


cd /opt/GNS3_Folder/qemu


Now let’s go back to GNS3_Folder and untar files

cd /opt/GNS3_Folder

sudo tar jxvf GNS3-0.8.5-src.tar.bz2

sudo chmod 777 GNS3-0.8.5-src

cd /opt/GNS3_Folder/GNS3-0.8.5-src

sudo chmod 777 *.*   – this will set full permission to files inside GNS3-0.8.5-src

cd /opt/GNS3_Folder/dynamips

sudo chmod 777 dynamips-0.2.8-RC2-x86.bin

cd /opt/GNS3_Folder/qemu

sudo tar -xvzf QEMU-0.14.1b-GNS3-Ubuntu-Linux.tgz

cd QEMU-0.14.1b-GNS3

./Qinstall  – this will install qemu for GNS3

Now open GNS3 through CLI via Terminal

sudo /opt/GNS3_Folder/GNS3-0.8.5-src/gns3



we will configure some setting – the setting should be as they appearing on the picture



After changing setting click on ” Test Settings ”



This will save all network traffic when you will use wireshark



After you done changes to your setting click on ” Test Settings ”


If you want to create shortcut or launcher on desktop than try the following

sudo apt-get install gnome-panel

gnome-desktop-item-edit –create-new ~/Desktop

gksu python “/opt/GNS3_root/GNS3-0.8.5-src/gns3”


So this was installing GNS3 on Ubuntu 13.10 – do not hesitate to contact me if you are facing any problems



Installing LAMP on Debian Wheezy

This tutorial will show you have you can install a LAMP on Debain Wheezy , an setup of Debian that can act as a LAMP server.

LAMP server stands for Linux, Apache, MySQL and PHP

For this tutorial, l have been using Debian Wheezy 7.2 net-install and used minimal installation , so in one words no GUI , and used VirtualBox 4.2

Download Link for Debian:

Download Link for VirtualBox :

To confirm this 🙂 here is the first picture


For this tutorial l use vi editor , but if you prefer other editors such as nano or pico  you can freely use

For those that they want to use vi editor

apt-get install vim-nox

Lets begin first by installing ntp because need our system to have time synchronized

Installing NTP

apt-get install ntp

invoke-rc.d ntp restart – this will restart ntp


/etc/init.d/ntp restart


service ntp restart

l prefer first one 🙂

Now we will change ip address from dhcp to static, because servers always need to have a static ip


vi /etc/network/interfaces


restart network int – invoke-rc.d networking restart

See if you can ping google

Is everything good now – ok lets begine other installation process 🙂

Installing MySQL

apt-get install mysql-server mysql-client

you will be asked to provide a password for MySQL , the password is for root users, see the pic below



Restart MySQL – invoke-rc.d mysql restart

Installing Apache2

apt-get install apache2

Restart apache – invoke-rc.d apache2 restart

Now to check if the apache works , open the browser and give ip of your server , if you get the similar page like this one you see here , this mean that apache is on ( working )


If you happen to recieve this kind of warning “Could not reliably determine the server’s fully qualified domain name, using for ServerName” than follow this steps

vi /etc/apache2/conf.d/httpd.conf and add lines
ServerName localhost

Remember you must always restart apache to apply this changes
invoke-rc.d apache2 restart

Installing PHP5

apt-get install php5 libapache2-mod-php5

The document root of the default web site is /var/www. We will now create a PHP file “info.php” in that directory and try to access it from browser. The file will display of useful details about our PHP installation, such as the installed PHP version.

vi /var/www/info.php – add the following lines


invoke-rc.d apache2 restart

try to access from browser –

” ipaddofserver/info.php ”

To get MySQL support in PHP, we need to  install the php5-mysql package

apt-get install php5-mysql

Install phpMyAdmin – is a web interface through which you can manage your MySQL databases

apt-get install phpmyadmin


that’s it , your server is up and running now ….

You can ask and write comments below , l will be happy to answer you