本篇文章给大家分享的内容是关于Nginx和php安装及配置二之安装和配置php-fpm,有着一定的参考价值,有需要的朋友可以参考一下
一、编译安装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 035d136d3952718cf434d86b1ed537d0
解决办法:
yum install opensslopenssl-devel
ln -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 in2f45ce73fb053e7f9a9c072faeb0bf27/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/bin
export PATH
要使改动立即生效执行
. /etc/profile 或source /etc/profile
5、配置php-fpm
cd /usr/local/php/etc
cp php-fpm.conf.defaultphp-fpm.conf
6、启动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
然后重启即可。
相关推荐:
Nginx和php安装及配置一之编译安装nginx-1.8.0
以上是Nginx和php安装及配置二之安装和配置php-fpm的详细内容。更多信息请关注PHP中文网其他相关文章!