您的位置:首页 > 运维架构 > Nginx

Nginx和php安装及配置第二篇:安装和配置php-fpm

2018-04-08 16:05 411 查看
一、编译安装php
1、创建放置安装包的目录及下载解压:
    php下载地址:http://www.php.net/downloads.php



2、指定安装目录和运行时用的属主和属组,并启用状态监控模块等,在/soft/php/php-5.6.27下:
./configure--prefix=/usr/local/php --with-config-file-path=/etc--enable-inline-optimization --disable-debug --disable-rpath --enable-shared--enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd--with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring--with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath--enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg--enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib--enable-zip --with-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite--with-pear--------可能出现的错误:
出现错误: congigure error:xml2-config not found.解决办法:执行命令: sudo yum installlibxml2-devel查看是否成功: find / -name"xml2-config" --------出现错误: congigure error: Cannotfind OpenSSL's <evp.h>解决办法:yum install opensslopenssl-develln -s/usr/lib64/libssl.so /usr/lib/ --------出现错误: configure: error:Please reinstall the BZip2 distribution解决办法:yum install bzip2 bzip2-devel --------出现错误: configure: error:Please reinstall the libcurl distribution -easy.h should be in<curl-dir>/include/curl/解决办法:yum -y install curl-devel --------出现错误: configure: error:mcrypt.h not found. Please reinstall libmcrypt.解决办法:sudo yum installlibmcrypt libmcrypt-devel mcrypt mhash --------出现错误: configure: error:Please reinstall readline - I cannot find readline.h
解决办法:sudo yum install readline-devel

3、安装:
make
make install 

4、启动添加 PHP 命令到环境变量
vim /etc/profile在末尾加入PATH=$PATH:/usr/local/php/binexport PATH要使改动立即生效执行. /etc/profile 或source /etc/profile



5、配置php-fpm
cd /usr/local/php/etccp php-fpm.conf.defaultphp-fpm.conf6、启动php-fpm
sudo /usr/local/php/sbin/php-fpm -c/etc/php.ini -y /usr/local/php/etc/php-fpm.conf(需要手动引入php.ini文件)
注意:如果启动php-fpm出现错误: cannot get uid for www,修改php-fpm.conf中user为nginx group为nginx
ERROR: unable to bind listening socket for address ‘127.0.0.1:9000’
解决办法:
kill all php-fpm
然后重启即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php-fpm