1. Setup Apache
download httpd-2.4.10.tar.bz2, unzip to /opt/httpd-2.4.10, from http://httpd.apache.org/download.cgi
unzip to /opt/httpd-2.4.10
If not installed APR, do step 2
If not installed PCRE do step 3
2. download the latest versions of both APR and APR-Util from Apache APR: apr-1.5.1.tar.gz, apr-util1.5.3.tar.gz
(a) unpack apr-1.5.1.tar.gz into ./srclib/apr
(remove version number in folder)
cd /opt/httppd-2.4.10/srclib/
apr
./configure
make
sudo make install
it will installed :
/usr/local/apr
(b) umpack apr-util1.5.3.tar.gz into ./srclib/apr-util
(remove version number in folder)
cd /opt/httppd-2.4.10/srclib/
apr-util
make
sudo make install
3. Install PCRE (Perl-Compatible Regular Expressions Library)
download pcre-8.35 from http://www.pcre.org/
unzip to /opt/
httppd-2.4.10
/srclib/pcre/
./configure
make
sudo make install
it will install pcretest, pcregrep to /usr/local/bin
4 make httpd
cd /opt/
httppd-2.4.10
sudo ./configure --with-apr=/usr/local/apr - --with-pcre=/usr/local
-with-apr-util=PATH
sudo make
sudo make install
it defaults to /usr/local/apache2
5.test it
/usr/local/apache2
/bin/apachectl -k start
I have this error :
/usr/local/apache2/bin/httpd: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
I don't know which step I missed. I just add this command for temp solution
sudo ln -s /usr/local/lib/libpcre.so.1 /usr/lib/libpcre.so.1
go firefox and type http://127.0.0.1, the web page shows "It works!"
/usr/local/apache2
/bin/apachectl -k stop
6. Now install php
download php-5.5.16 and unpack into /opt/
php-5.5.16
cd
/opt/
php-5.5.16
## install libxml2 if not installed before
sudo apt-get install libxml2 libxml2-dev
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
make
sudo make install
## setup your php.ini
cp php.ini-development /usr/local/lib/php.ini
7. Edit your httpd.conf to load the PHP module
vi /usr/local/apache2/conf/httpd.conf
LoadModule php5_module modules/libphp5.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
DocumentRoot "/www_root"
<Directory "/www_root">
8. write a php test file
vi /www_root/helo.php
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
8. restart httpd
/usr/local/apache2
/bin/apachectl stop
/usr/local/apache2
/bin/apachectl start
Test it in firefox
http://127.0.0.1/helo.php
you will see "Hello world" in the web.