centos6.5 nginx+php+mysql之php5.4安装-阿里云开发者社区

开发者社区> 开发与运维> 正文
登录阅读全文

centos6.5 nginx+php+mysql之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



本文转自 yawei555 51CTO博客,原文链接:http://blog.51cto.com/huwei555/1618742,如需转载请自行联系原作者

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享: