标签:php5.4
一.安装前的准备
cd /usr/local/src/
yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
二.安装PHP
下载PHP
wget http://cn2.php.net/distributions/php-5.4.38.tar.gz
tar -zxvf php-5.4.38.tar.gz
cd php-5.4.38
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli --with-gd --with-jpeg-dir
此时出现报错:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决方法:
rpm -ivh "http://www.lishiming.net/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm"
yum install -y libmcrypt-devel
再次
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli --with-gd --with-jpeg-dir
make all install
cd /usr/local/php
cp etc/php-fpm.conf.default etc/php-fpm.conf
vi /usr/local/php/etc/php-fpm.conf
修改后保存:
user = www-php
group = www-php
添加用户
groupadd www-php
useradd -g www-php www-php
编译nginx
在server段添加:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
创建php测试文件
vi /usr/local/nginx/html/index.php
添加以下内容:
<?php
echo phpinfo();
?>
~
启动nginx:
/usr/local/nginx/nginx
启动php
/usr/local/php/sbin/php-fpm
测试:
links 192.168.66.176/index.php 其中192.168.66.176为IP地址
测试结果显示PHP版本等信息为OK
centos6.5 nginx+php+mysql之php5.4安装
标签:php5.4
原文地址:http://huwei555.blog.51cto.com/1347480/1618742