继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

centos6.5 nginx+php+mysql之php5.4安装

慕码人2483693
关注TA
已关注
手记 197
粉丝 9
获赞 24

一.安装前的准备

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

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP