Install Apache + PHP

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

./configure --with-apr=/usr/local/apr

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.




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值