如何将php安装位apache的模块



获取安装文件: http://www.php.net/downloads.php php-5.3.8.tar.gz

tar xf php-5.4.13-C /usr/local

cd /usr/local/php-5.4.13

./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache2/bin/apxs --with-mcrypt --with-config-file-path=/etc/ --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts(最后一项如果是per类型不用加 如果是work或者event就加 httpd -M 可以查看)

注意:要想使用--with-mcrypt加密功能需要安装四个包:

mhash-0.9.2-6.el5.i386.rpm

mhash-devel-0.9.2-6.el5.i386.rpm

libmcrypt-2.5.7-5...

libmcrypt-devel....

注意:rpmfind.net 可以下载各种rpm包 rpm -ivh *.rpm就可以安装

注意:将:--with-apxs2=/usr/local/apache2/bin/apxs改为--enable-fpm 表示启用fpm功能

即fastcgi格式

5.cd /usr/local/php...

cp php.ini-production 服务器端 /etc/php.ini

6.找到httpd的配置文件 找到AddType 添加两行

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

7.再找到DirectoryIndex目录主页面

改为DirectoryIndex index.php index.html

8../apachectl -f /usr/local/apache2/conf/httpd.conf -k start启动起来

9.cd /usr/local/apache2/htdocs mv index.html index.php

10.vim index.php

<?php

$conn=mysql_connect('localhost','root','');

if ($conn)

echo "Success...";

else

echo "Failure...";

?>

service iptables stop

测试成功