Skip to content

Beginning on the LAMP Journey

April 29, 2012

I’m hoping to learn more about LAMP – that’s Linux, Apache, Mysql and PHP. LAMP is generally used to setup a webserver. In an effort to understand what I am doing and to document my fails and successes, I will document what I do and how I go abouts doing it here. To be honest the easiest way to install Apache Webserver would be to do a “yum install httpd”, this would resolve all dependencies. But I have had a look at the httpd that would be installed from the repositories and it would install an older version of Apache, hence I’ve gone for installing the latest version as of April 2012 by source.

If you guys want to just go ahead and install apache without verifying the downloaded files then just go down to the heading “Installing Apache Requirements”


Apache HTTP Server ( # This is the main website of the Apache HTTPD Webserver

Download (

Download new Apache HTTP server from website and dependencies using: –

wget –v

wget –v

wget -v

wget -v

Verify (

Verify you have a complete and unmodified version of Apache by: –

#1 Check signature that came with the file in question: –

gpg *PGP.asc*

This will give you the Digital Signature Algorithm Identifier that you will need to query with a public key server to retrieve the public key. Note that GPG is a ‘generally pretty good’ encryption and decryption tool

#2 gpg –keyserver –recv-key *DSA KEY ID*

You should now have received a public key that has automatically been put in your trusted keys

#3 Verify the file again: –

gpg *PGP.asc*

At this stage the signature has been verified but we still cannot trust this public key. Generally a good signature represents a file that not been modified/altered with

What you really need to do is validate that the public key was really produced by an official developer/person from the project/company

#4 Validate the public key by looking at its fingerprint: –

gpg –fingerprint *DSA KEY ID*

This will give you the public key fingerprint that you will be able to confirm with the entity of the e-mail address if it is a valid public key or not.

Once you have obtained a verified trusted key from the entity of the e-mail address you should be able to verify the signature of the file again and find that as you have entered the “web of trust” that you can see that the public key is indeed a authorized trusted key

Installing Apache Requirements

Apache webserver has application dependencies that must be installed before you install Apache, and these are: –

pcre v.8.12-7 (Perl-Compatible Regular Expression Library) was already installed (you can check this by doing a rpm –q pcre)

pcre-devel 8.12 (development libraries for pcre) ; I installed this by doing a : –

prompt> yum -y install pcre-devel

gcc 4.6.3(GNU Compiler Collection) ; I installed this by doing a: –

prompt> yum install gcc

apr 1.4.6 (Apache Portable Runtime) ; I installed this from source by extracting the tarball, and then installing it: –

prompt> wget -v

prompt> gzip -dv apr-1.4.6.tar.gz

prompt> tar -xvf apr-1.4.6.tar

prompt> cd apr-1.4.6

prompt> ./configure

prompt> make

prompt> make install

apr-util 1.4.1 (Utilities for Apache Portable Runtime) ; I installed this from source too, by extracting the tarball just like above, and then doing: –

prompt> ./configure –with-apr=/usr/local/apr #the “-with-apr=/usr/local/apr” option tells the installer where the apr is already installed as it needs to know where this is so that it can proceed with the installation of the apr-util

prompt> make

prompt> make install

apr-util has now been installed. Keep an eye out for any error messages at the end of the output, unfortunately you do not get a big acknowledgement saying ‘this has now been completed’.

Install Apache

Now that we have installed all the dependencies for Apache Webserver (httpd) we can now go ahead and install the actual webserver itself: –

prompt> wget –v # this will download the apache source file

prompt> gzip –dv httpd-2.4.2.tar.gz # this will decrypt the contents of the file

prompt> tar –xvf httpd-2.4.2.tar # this will extract the contents of the archive into a directory)

prompt> cd httpd-2.4.2/ # this will change into the directory that you just extracted

prompt> ./configure –enable-so # note that you can tell the source file where to install the application, e.g. if I wanted to install it in /home/, I would do ./configure –prefix=/home/

This will install the webserver in the default location which is /usr/local/apache2/

prompt> make

prompt> make install

If you do not encounter any errors on the way then the webserver should be installed.

Customize (

Next thing we will be able to do is customize your Apache’s server settings by editing the configuration file (httpd.conf) with any extra configurations you would want to add by: –

prompt> vi /usr/local/apache2/conf/httpd.conf

Note that as for me I did not need to alter any information to the configuration file so I just left it as it was


As Apache has now been installed you can now start the service by: –

prompt> /usr/local/apache2/bin/apachectl -k start

You should be able to test that it works by typing the following in a web browser: –



This should take you to Apache’s default page, this will prove as acknowledgement that your Apache server has started and is running correctly. I got a simple webpage with bold print text saying “it works!”

You can stop the Apache server by : –

prompt> /usr/local/apache2/bin/apachectl -k stop

To be able to run apachectl from anywhere I made a link from where apachectl is located to one of the directories that is already in the environment variable called PATH.

prompt> ln -s /usr/local/apache2/bin/apachectl /usr/local/bin/apachectl

To make the webserver start at boot we have to make another link from the apachectl file to the init.d directory. This will make sure the service of the webserver apachectl will be able to be found when using the command chkconfig to set the webserver to start at boot. We will also need to amend the configuration of the file as a valid sysV init file so that it can be read by chkconfig.

prompt> ln -s /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd # as you can see I have renamed the linked file as httpd in the init directory, the purpose of this is for simplicity as most people look for httpd when trying to start or stop a apache web server

Now we need to edit the httpd file we have linked to the init directory to include some sysV init script to help chkconfig identify it as a valid service to start at boot: –

prompt> sudo vi /etc/rc.d/init.d/httpd # If you are not used to using vi to edit files, just use sudo gedit /etc/rc.d/init.d/httpd instead

make sure to add the script below just under the #!/bin/sh and save it: –



# Startup script for the Apache Web Server


# chkconfig: – 85 15

# description: Apache is a World Wide Web server. It is used to serve

# HTML files and CGI.

# processname: httpd

# pidfile: /usr/local/apache/logs/

# config: /usr/local/apache/conf/httpd.conf

Now all we need to do is tell the system to start the service at boot: –

prompt> chkconfig httpd on

You can make sure that httpd is added to the the startup boot sequence by: –

prompt> chkconfig | grep httpd

you should see something like: –

httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

The above line shows me that the service httpd will start at boot on run levels 2, 3, 4 and 5.

So that should be it now, make sure to reboot and test the webserver to make sure it is working by doing a http://localhost/

As the man pages was not installed automatically, you have to install this manually by creating a symbolic link from the man pages that have been installed in the apache directory to the directory that is purged for manual pages: –

prompt> sudo ln -s /usr/local/apache2/man/man8/httpd.8 /usr/share/man/man8/httpd.8

prompt> sudo ln -s /usr/local/apache2/man/man8/apachectl.8 /usr/share/man/man8/apachectl.8

So now you should be directed to the correct manual pages when you do: –

prompt> man httpd


prompt> man apachectl

#Thoughts, if I am going to be installing a lot of applications from source (tarball) it may be wise to learn how to properly make sysV init scripts as it seems we have to do this manually ourselves. If we were to install any applications through rpm or yum then gernerally the sysV init scripts will be added automatically and all you would really need to do is tell the system to turn the service on at boot (chkconfig service on).


From → Linux

One Comment
  1. I do not even know how I ended up here, but I thought this blog was nice. I don’t know who you are but definitely you’re going to a famous blogger if you are not already 😉 I suggest you add new articles related with “cheap web design” maybe could be a good idea but don’t worry you have a fantastic blog my bro. Thank you so much.

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

%d bloggers like this: