This How-To guides you through the steps to install and configure the most popular and powerful Apache-2.2.8 web server with PHP-5.2.5 and Mysql-5.0.45.
This How-To can be used either on Linux with Kernel version 2.4 and higher or on FreeBSD-6.x systems.
From wikipedia, the definition of a web server is as follows:
A computer program that is responsible for accepting HTTP requests from clients, which are known as web browsers (e.g. Firefox, Internet Explorer), and serving them HTTP responses along with optional data contents, which usually are web pages such as HTML documents and linked objects (images, etc.).
Without Web servers, the Internet would just be as dull as sending and receiving emails.
It is the web server which provides the content and information that we are used to seeing these days. It’s the web server’s job to deliver both static and dynamic contents to end-users via browsers such as Mozilla Firefox and Internet Explorer.
Apache is to web servers what Bind is to DNS servers. Apache is a high performance and scalable web server notable for playing a key role in the initial growth of the World Wide Web. According to the data provided by news.netcraft.com, 50% of all web sites are running on Apache web servers.
In this guide, we will install and configure a simple Apache-2.2.8 web server with PHP-5.2.4 and Mysql-5.0.45.
MySQL is a robust Relational Database Management System (RDBMS) that relies on Structured Query Language (SQL) for processing the data in the database.
MySQL is most commonly used for Web applications and for embedded applications and has become a popular alternative to proprietary database systems such as Oracle and Sybase because of its speed and reliability.
PHP is a reflective programming language originally designed for producing dynamic web pages.PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications.
PHP generally runs on a web server, taking PHP code as its input and creating Web pages as output.
The following guide details the installation and configuration of this 3 powerful components.
Installing Mysql-5.0.45
(1.) Create the necessary mysql user and mysql group
groupadd mysql
useradd -g mysql mysql
(2.) Download Mysql
cd /usr/local/src
wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.45.tar.gz/from/http://mirror.trouble-free.net/mysql_mirror/
(3.) Unzip the sources
tar zxvf mysql-5.0.45.tar.gz
(4.) Got to source directory and run configure
cd mysql-5.0.45
./configure –prefix=/usr/local/mysql
(5.) Make and Install
make
make install
(6.) Copy the main my.cnf file and change the necessary permissions and run Mysql
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .
bin/mysql_install_db –user=mysql
chown -R root .
chown -R mysql var
bin/mysqld_safe –user=mysql &
If all goes well, Mysql is now installed and should be running!!
Note: If you face problems such as getting configuration and compilation errors, check your permissions. 95% of all problems can be solved either by installing dependencies and development libraries. Google is your friend as always.
Installing and configuring Apache-2.2.8
(1.) Download Apache
cd /usr/local/src
wget http://veritris.com/mirrors/apache/httpd/httpd-2.2.8.tar.gz
(2.) unzip the sources
tar zxvf httpd-2.2.8.tar.gz
(3.) Configure Apache
cd httpd-2.2.8
./configure
–prefix=/usr/local/httpd \
–enable-cache \
–enable-disk-cache \
–enable-mem-cache \
–enable-proxy \
–enable-proxy-http \
–enable-proxy-ftp \
–enable-proxy-connect \
–enable-so \
–enable-cgi \
–enable-info \
–enable-rewrite \
–enable-speling \
–enable-usertrack \
–enable-deflate \
–enable-mime-magic
(4.) Make and Install
make
make install
That’s it. Apache should now be installed in /usr/local/httpd ! Note: If you face problems such as getting compilation errors, check your permissions. 95% of all problems can be solved either by installing dependencies and development libraries. Google is your friend as always.
Installing and Configuring PHP
(1.) Download PHP
cd /usr/local/src
wget http://www.php.net/get/php-5.2.5.tar.gz/from/au2.php.net/mirror
(2.) Unzip the sources
tar zxvf php-5.2.5.tar.gz
(3.) Configure PHP for Apache and Mysql support
./configure
–with-apxs2=/usr/local/httpd/bin/apxs \
–with-mysql=/usr/local/mysql \
–prefix=/usr/local/httpd/php \
–with-config-file-path=/usr/local/httpd/php \
–enable-force-cgi-redirect \
–disable-cgi \
–with-zlib \
–with-gettext \
–with-gdbm
(4.) Make and Install
make
make install
(5.) Configure PHP configuration
cp php.ini-dist /usr/local/lib/php.ini
(6.) Edit your httpd.conf to load the PHP module
vi /usr/local/httpd/conf/httpd.conf
#Added the following in the relevant section
LoadModule php5_module modules/libphp5.so
(7.) Tell Apache to parse certain extensions as PHP and also to parse .phtml and phps extensions
vi /usr/local/httpd/conf/httpd.conf
#Added the following in the relevant sections
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
(8.) Start your Apache-2.2.6 server
/usr/local/httpd/bin/apachectl start
Note: If you face problems such as getting configuration and compilation errors, check your permissions. 95% of all problems can be solved either by installing dependencies and development libraries. Google is your friend as always.
Testing PHP installation
(1.) Create the following info.php file in the default htdocs directory
vi /usr/local/httpd/htdocs/info.php
##Copy and paste the following text
<?php
phpinfo();
?>
(2.) Save the file and start your web browser to point to your local web server. If this server is a remote server, simply enter it’s IP address in place of localhost
http://localhost/info.php
You should be able to see detailed information about your PHP installation, Apache environment and PHP extensions loaded, etc.
You should see something like the following:

info.php showing the versions of Apache, PHP, Mysql installed.
Well that’s it. Now you have a brand new working installation of Apache-2.2.6 with PHP-5.2.4 and Mysql-5.0.45.
It’s up to you to decide what you want to do with this powerful combination and configuration. Only the sky is the limits!
Happy Web serving !!!!
Pingback: Monitoring your Linux/Unix servers and network devices using MRTG and SNMP « Teklimbu’s Weblog
Hi teklimbu,
I am trying your this configaration. When I giving the command to run Apache getting this error-
httpd: Syntax error on line 55 of /usr/local/httpd/conf/httpd.conf: Cannot load /usr/local/httpd/modules/libphp5.so into server: /usr/local/httpd/modules/libphp5.so: cannot open shared object file: No such file or directory
Hi Sumon,
Did you install PHP after the installation of Apache?
If not, then simply install it following the guide (top to bottom) and I am sure that things will work out smoothly.
I am reinstall PHP. then I got another new error.
as, Cannot load /usr/local/httpd/modules/libphp5.so into server: /usr/local/httpd/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
So I give the permission as,
cd /usr/local/httpd/modules
setenforce 0
chmod 777 libphp5.so
Now its works…………
Thank you again.
I got a new problem when I restart my linux box apache not automaticaly. After typing manualy this command
cd /usr/local/httpd/modules
setenforce 0
chmod 777 libphp5.so
I can start apache….
May I need to do this regularly.
Thank you.
Hi Sumon,
I think that you are getting this error due to SELinux being enabled in your Linux box. I guess you are running Fedora?
So typing: “setenforce 0″ disables it until the next reboot.
If you don’t want to disable SELinux completely, why don’t you just run SELinux in permissive mode?
(1.) vi /etc/selinux/config
#Set policy to permissive
SELINUX=permissive
This way, the SELinux settings will be saved and rebooting won’t make a difference.
Hope it helps.
Yes I am running Fedora.
Every thing is ok now.
Thank you.
hi teklimbu ,
when i type this command:
bin/mysql_install_db –user=mysql
Getting this problem:
Installing MySQL system tables…
/usr/local/mysql/libexec/mysqld: Too many arguments (first extra is ‘–user=mysql’).
Use –help to get a list of available options
Installation of system tables failed!
Examine the logs in /usr/local/mysql/var for more information.
You can try to start the mysqld daemon with:
/usr/local/mysql/libexec/mysqld –skip-grant &
and use the command line tool
/usr/local/mysql/bin/mysql to connect to the mysql
database and look at the grant tables:
shell> /usr/local/mysql/bin/mysql -u root mysql
mysql> show tables
Try ‘mysqld –help’ if you have problems with paths. Using –log
gives you a log in /usr/local/mysql/var that may be helpful.
The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: ‘Problems running mysql_install_db’,
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/local/mysql/bin/mysqlbug script!
[root@localhost mysql]# bin/mysql_install_db -user=mysql
Installing MySQL system tables…
071226 21:33:20 [ERROR] Fatal error: Can’t change to run as user ‘ser=mysql’ ; Please check that the user exists!
071226 21:33:20 [ERROR] Aborting
071226 21:33:20 [Note] /usr/local/mysql/libexec/mysqld: Shutdown complete
Installation of system tables failed!
Examine the logs in /usr/local/mysql/var for more information.
You can try to start the mysqld daemon with:
/usr/local/mysql/libexec/mysqld –skip-grant &
and use the command line tool
/usr/local/mysql/bin/mysql to connect to the mysql
database and look at the grant tables:
shell> /usr/local/mysql/bin/mysql -u root mysql
mysql> show tables
Try ‘mysqld –help’ if you have problems with paths. Using –log
gives you a log in /usr/local/mysql/var that may be helpful.
The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: ‘Problems running mysql_install_db’,
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/local/mysql/bin/mysqlbug script!
Pingback: webforstudent.com » Monitoring your Linux/Unix servers and network devices using MRTG and SNMP
I can’t make a command .
(3.) Configure PHP for Apache and Mysql support
./configure
–with-apxs2=/usr/local/httpd/bin/apxs \
–with-mysql=/usr/local/mysql \
–prefix=/usr/local/httpd/php \
–with-config-file-path=/usr/local/httpd/php \
–enable-force-cgi-redirect \
–disable-cgi \
–with-zlib \
–with-gettext \
–with-gdbm
as u mention in 3.0 of PHP installation. the server generatess the following error..
No such file or directory .
what is the problem??
any help would be appreciated.
thank you.
Hi,
I have installed the mysql 5.0.45, then apache 1.3.41, then PHP 5.2.5.
Now, After installation, I have made the necessary changes in httpd.conf, php.ini., and created the index.php.
Now, I have run the Localhost page so, I am able to see the home page of Apache. but not the full info of PHP.
It means PHP is not installed properly.
Can you suggest me hw to solve this issue.
When i finished my install with PHP5.2.5 and Apache 2.2.8 and opened the phpinfo page, it shows PHP as 5.1.6. Why is this happening? Your help is much appreciated.
Jala S : Maybe you downloaded a wrong version (infact, filename or achive file tells that its version 5.2.5) Its impossible if you download the achive from the official site.
Amol: Those issues probably can caused by a lots of problem. First thing, Apache below version 2.x wont works properly for PHP 5.x (including latest MySQL version).
anunay: Did you ./configure from the same directory?
hi teklimbu
I ‘ve got in trouble with this combo installation on AIX system for week , After done serveral thing on configuration ,there’s some errors occur that .
The phpinfo page is still display on browser full path and thingz ,with mysql i can login with root privileges and use some command request to databases
But the phpmyadmin index files did not show up on the browser anyway , it doesnt matter how many time i try to config and set the permission 775 for all of files and fodler inside .
it only hang up with black page on browser i also restart httpd and mysqld service .
I configured apache webserver on windows 2003 and i need to configure the clients so they can be able to use a software called ericom which is used for publishing applications so i need help in configuring my clients to work with the webserver