centos 安装php

1.yum安装

yum install php php-fpm php-common php-gd php-mcrypt php-pear php-pecl-memcache php-mhash php-mysql php-xml

 

2.下载编译安装php 5.3.6:

http://php.net/downloads.php

yum install libxml2 libxml2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel libmcrypt libmcrypt-devel libtool-ltdl-devel

tar -jxvf php-5.3.6.tar.bz2

cd php-5.3.6

./configure --prefix=/opt/php -with-apxs2=/opt/httpd/bin/apxs --with-curl --with-mcrypt --enable-mbstring --with-iconv --with-gd -with-jpeg-dir=/usr/local/lib --enable-pdo --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd

make

make install

cp php.ini-development /opt/php/lib/php.ini

ln -s /opt/php/bin/php /usr/bin/php

vi /opt/php/lib/php.ini



把include_path前面的分号删除,改成include_path = "/opt/php/lib/php"

sudo vi /opt/httpd/conf/httpd.conf

在最下面加入一行AddHandler application/x-httpd-php .php

sudo /opt/httpd/bin/httpd -k restart

sudo vi /opt/httpd/htdocs/phpinfo.php

phpinfo.php的内容如下:

<?php

phpinfo();

?>

安装完php,重启apache,用浏览器访问http://localhost/phpinfo.php,能正常显示说明php装好了。

 

查看php版本: php -v

参考:http://www.jb51.net/article/24775.htm

你可能感兴趣的:(centos)