LAMP Customized Installation

LAMP stands for Linux, Apache, Mysql and PHP.

To install LAMP from source based packages you need to remove the rpm packages from your system if it is RedHat Based system. For Debian based system you first need to remove .deb packages.

1) Remove RPM packages.

#rpm –e httpd

In Fedora you will get following error

#httpd >= 2.2.0 is needed by (installed) gnome-user-share-0.40-3.fc10.i386

so you first need to remove gnome-user-share

#rpm –e gnome-user-share and then
#rpm –e httpd
#rpm –e php
#rpm –e mysql and rpm –e mysql-server
if these are already not installed then you will get messages “error: package mysql is not installed” like this. The other way you can check via

#rpm –qa | grep package-name

Now your system is ready to get start with source based installation of LAMP.

You will need to install wget for downloading source packages so if not installed then execute.

#yum install wget

Now go to /usr/src/

Donwload Latest source code By executing the following command.


it will download php version 5.3.2 which is the latest version at the time of writing this tutorial.

You can download the newer version of mysql from the mysql site after free registration and download the community edition but the problem is that now they have a new policy when download the mysql source tarball, what they are doing first they review your information like username and address etc and then in three official days they will send the download link to your email, so I have find below link to download source package directly.


To download apache you can use the following link.

if you want to download the newest version then go to

Now untar three packages. By executing

#tar xvf php-5.3.2.tar.gz
#tar xvf mysql-5.0.89.tar.gz
#tar xvf httpd-2.2.15.tar.gz

Now first of all we will compile Mysql so go to mysql version directory.

cd /usr/src/mysql-5.0.89

Now first we need to execute the ./configure to check environment.
But when I execute ./configure command it give me the following error.

configure: error: no acceptable C compiler found in $PATH

so it mean we did not install C compiler so first we need to install c compiler by executing.

#yum install gcc-c++

it gives me a long list of packages about 50Mb so it will take some time to download if you have low internet connection.

After intalling gcc, I executed again the ./configure command and it gives me the following error.

checking for termcap functions library… configure: error: No curses/termcap library found

I have installed ncurses but I need to install ncurses-devel so execute the following command.
#yum install ncurses-devel

Now executing ./configure with the following options and it will work, these options will install default mysql so you can add and delete from it.

#./configure \
–prefix=/usr/local/mysql \
–without-debug \
–with-client-Idflags=-all-static \
–localstatedir=/usr/local/mysql/data \
–disable-maintainer-mode \
–with-extra-charsets=none \
–with-mysqld-user=mysql \
–with-unix-socket-path=/tmp/mysql.sock \
–without-comment \

#make install

I am on new Fedora installation so I don’t have make installed so if you want to install make run the following command.

#yum install make

Now your mysql is installed in /usr/local/mysql directory but if try to run it you will get the following error.


“nohup: ignoring input and redirecting stderr to stdout
touch: cannot touch `/usr/local/mysql/data/localhost.localdomain.err’: No such file or directory
chown: invalid user: `mysql’
Starting mysqld daemon with databases from /usr/local/mysql/data
./mysqld_safe: line 394: /usr/local/mysql/data/localhost.localdomain.err: No such file or directory
./mysqld_safe: line 400: /usr/local/mysql/data/localhost.localdomain.err: No such file or directory
STOPPING server from pid file /usr/local/mysql/data/
tee: /usr/local/mysql/data/localhost.localdomain.err: No such file or directory
100710 08:32:58 mysqld ended
tee: /usr/local/mysql/data/localhost.localdomain.err: No such file or directory”

so first you need to create the default DB of mysql by executing.

#cd /usr/src/mysql-5.0.89/scripts

Now this script will create a directory /usr/local/mysql/data and install test and mysql dbs there. As we mentioned this at the time of ./configure command. Now you can start your mysql server.

But when I try to start mysql via command /usr/local/mysql/bin/mysqld_safe & it stops the server. When I see the log file /usr/local/mysql/data/localhost.localdomain.err it shows following error.

“100710 08:44:28 mysqld started
nohup: ignoring input
100710 8:44:28 [ERROR] Fatal error: Can’t change to run as user ‘mysql’ ; Please check that the user exists!

100710 8:44:28 [ERROR] Aborting

100710 8:44:28 [Note] /usr/local/mysql/libexec/mysqld: Shutdown complete

100710 08:44:28 mysqld ended”

It means we did not create the mysql user yet and mentioned in the ./configure script that start mysql server with mysql user. So we need to create mysql user first by executing following command.

#useradd mysql

Now again if you want start mysql server with mysqld_safe command you will get the following error.

“100710 08:51:17 mysqld started
nohup: ignoring input
100710 8:51:17 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: ‘create’.
InnoDB: Cannot continue operation.
100710 08:51:17 mysqld ended”

it means first we need to change owner ship of mysql to root:mysql and then give 775 permission to mysql directory so you can do this by executing the following commands.

# chown root:mysql /usr/local/mysql/ -R
#chown 775 /usr/local/mysql/ -R

Now the final steps before start the service. Copy configuration file from the source package to /etc/my.cnf. The configuration file will depend on the size of your database in the future. So I am going to copy
#cp /usr/src/mysql/mysql-5.0.89/support-files/my-midium.cnf /etc/my.cnf
#chown root:sys /etc/my.cnf
#chmod 644 /etc/my.cnf

Now there is another feature of dynamic libraries that we need to configure so mysql find libraries dynamically when it needs. So below command will add the path of mysql libraries in file.

#echo “/usr/local/mysql/lib/mysql” >> /etc/

At the moment as you have seen, we are starting the service via /usr/local/mysql/bin/mysqld_safe command, so we want to start mysql service as normal RedHat based command for example “service mysqld start” , do the following.

#cp /usr/src/mysql-5.0.89/support-files/mysql.server /etc/rc.d/init.d/mysql
#chmod +x /etc/rc.d/init.d/mysqld

You can execute the following command to start mysql server by default when the system starts.
#chkconfig mysqld on

Now start the service by executing

#/service mysqld start

Mysql service should listen on port 3306 if you want to stop it you can stop by uncomment skip-networking line in the /etc/my.cnf file. This should be done when application and mysql is running on the same server.

Build and Install Apache (with DSO support)
The advantage to building Apache with support for dynamically loaded modules is that in the future, you can add functionality to your webserver by just compiling and installing modules, and restarting the webserver. If the features were compiled into Apache, you would need to rebuild Apache from scratch every time you wanted to add or update a module (like PHP). Your Apache binary is also smaller, which means more efficient memory usage.
The downside to dynamic modules is a slight performance hit compared to having the modules compiled in.
#cd /usr/src/httpd-2.2.15

#./configure \
–prefix=/usr/local/apache \
–enable-shared=max \
–enable-module=rewrite \

#make && make install
Installing PHP

Prerequisite knowledge and software for compiling:

* Basic Unix skills (being able to operate “make” and a C compiler)
* An ANSI C compiler
* flex: Version 2.5.4
* bison: Version 1.28 (preferred), 1.35, or 1.75
* A web server
* Any module specific components (such as gd, pdf libs, etc.)

This how to is in Progress

Leave a Reply

Your email address will not be published. Required fields are marked *