现在的位置: 首页 > 综合 > 正文

linux + apache 2.4.4 + php配置

2013年10月04日 ⁄ 综合 ⁄ 共 1843字 ⁄ 字号 评论关闭

1.下载httpd2.4.4,存放目录:/home/aaron/httpd-2.4.4.tar.gz,解压 tar -zxvf httpd-2.4.4.tar.gz

2.安装

进入解压后的/home/aaorn/httpd-2.4.4目录,执行./configure --prefix=/home/aaron/httpd,提示:

checking for APR... configure: WARNING: APR version 1.4.0 or later is required, found 1.3.9
configure: WARNING: skipped APR at apr-1-config, version not acceptable
no
configure: error: APR not found.  Please read the documentation.

查看apache安装文档:http://httpd.apache.org/docs/2.4/install.html   需要新的apr,按照向导下载apr-1.4.6.tar.gz,apr-util-1.5.1.tar.gz,按照说明,分别解压到:
httpd2.4.4/srclib/apr和httpd2.4.4/srclib/apr-util(绝对路径省略),

tar -zxvf apr-1.4.5.tar.gz -C /home/aaron/httpd-2.4.4/srclib/

tar -zxvf  apr-util-1.5.1.tar.gz -C /home/aaron/httpd-2.4.4/srclib/

注意解压后apr和apr-util目录是带版本号的,把目录分别重命名成apr和apr-util(不带版本号)      mv apr-1.4.5 apr ,mv apr-util-1.5.1 apr-util

再到httpd-2.4.4目录下./configure --prefix=/home/aaron/httpd --with-included-apr  

注意这一步,网上有很多人是把apr和apr-utils先编译安装,然后再用参数--with-apr=/xx/apr  --with-apr-util=/xx/apr-util/bin,我没有测试,应该效果是一样的

make && make install

执行成功!httpd安装成功!

3.下载php-5.4.12.tar.gz,解压到/home/aaron/php-5.4.12,进入解压后的目录

./configure --prefix=/home/aaron/php --with-apxs2=/home/aaron/httpd/bin/apxs --with-mysql

成功后:make && make install

执行成功,php安装成功!

参考:http://www.php.net/manual/en/install.unix.apache2.php

cp php.ini-development /usr/local/lib/php.ini  //   /usr/local/lib需要有权限,或者在安装前指定ini文件的目录 --with-config-file-path=/some/path

4.修改httpd配置

添加:

<FilesMatch "\.ph(p[2-6]?|tml)$">
        SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>

注释掉LoadModule中的rewrite_module

在上面的<FilesMathc/>后再添加:

RewriteEngine On
RewriteRule (.*\.php)s$ $1 [H=application/x-httpd-php-source]

5.配置完成,启动httpd:./bin/apachectl start

checking for APR... configure: WARNING: APR version 1.4.0 or later is required, found 1.3.9
configure: WARNING: skipped APR at apr-1-config, version not acceptable
no
configure: error: APR not found.  Please read the documentation.

抱歉!评论已关闭.