本篇文章给大家介绍一下centOS安装PHP后,php-fpm启动失败的解决方法。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

在centOS6.8上安装php,出各种问题,光是gcc的版本太低,升级gccU Q %这个,就让我气了两天,翻遍了几乎所有相关博客总算解决了p H H。还有7 N b ; 8 J F : Vmysql安装也没少踩坑,所以大家还是尽量用centOS7吧,少生气能多活几年呢N V F 9。。。

现在说一下cent} t 7 # D l . sOS6.8上编译安装php7.2.1吧。

1,安装扩展包并更新系统(我在根目录下开始的):

yum install epel-releaK b P i * # 9 6se -y
yum update

2,安装php依赖组件(一段全复制上去,其实掠过也A * =可能没关系):

yum\ S n f U c k b -y install wget vim pcre pcre6 N W & Y ^-devel openssl openssl-devel libicu-devel gcc gc^ S 9c-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncu0 3 _ b 8 arses ncurses-devel curl curl-devel krb5-devel libiy 9 E +dn libid= } Q ? F ! \ O Wn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-dC I d 7evel libtool* libmcrypt libmcrypt-devel mcrypt mg m S l a mhash libxslt~ m C s e ` H ~ libxslt-devel readline readline-devel gmp gmp-devel libcurlV 2 ; ( S G libcurl7 y 1 \ \-devP , k vel openjpeg-devel

3,下载p@ A 6 n { / / 8 zhp安装包并解压:

wget http://am1.[ i I [ M L Jphp.net/distributions/php-7.2.1.tar.gz
tar xvf php-7.2.1.tar.gz

4,进入解压目录并开始编译(编译千C m u G万不能省,运行出错了就不能make了,这是我选出来的最靠谱可行的编m . l 2译了):

cd /php-7.2.1

./configure –prefix=/usr/local/php7 –with-config-file-pathw – ` 0 t Z d k ~=/usr/locak 4 e V ( l 2 u pl/php7/etc –wA n – v x o ^ ? [ith-mcry| k & ! # 0 7 ppt=/usr/include –with-mysql=mysqlnd –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –with-gd –with-iconv –with-zlib –enable-xml –enable-bcmaM c A b s 9 u Dth –enable-shmop –enable-sysvsem –enable-inlb * ( J k Tine-optimization –enable-mbregex –enable-fpm@ u \ j –enable-mbstring –enable-ftp –enable-gd-nativeD 1 ? G = B x ;-ttf –with-openssl –enable-pcntl –enable-sockets –with-xG E {mlrpc –\ ) L A ` * g g-enable-zip –enable-soap –without-pear –with-gettext –enable-session –with-curl –with-jpeg-dir –wiB w q ` yth-freetype-dir –ena_ x q V 1 Dble-opcache

5,为了安全保险的给make出来,先更新依赖库以防万一:

yum -y install libjpeg libjpeT v Z U ^ { x Q Sg-devel libpng libpng-devel freetype freetB g @ @ I S `ype-devel libxml2 libxml2-devel mysql pcre-devel

6,安装:

make
make install

7,关于配置:

cp php.ini] W n + ^-development /usr/local/php7/etc/php.ini
cp /usr/local/php7/etc/php-fpm.cm ~ 0on~ + p A 7 Wf.default /usr/locaJ 2 [ a + il/php7/etc/php-fpm.coF E I r j ) inf
cp /usr/local/p/ Z } H 3 g ,hp7/etc/php-fpm.d/www.conf.dL ~ Vefault /usr/local/php7/etc/php-fpm.d/www.conf

8,加个权限:

chmod +x /etc/init.d/php-fpm

现在试一下,/etc/init.d/php-fpm start

如果php启动成功了,那你很幸福;如果失败了,接着往下看。

大概出现的是2 # o C下图这个情况吧– D ? K 4 p E * H

再试一下运行提示的命令,出的问题是ERROR:FPM initializatioh k q ^ Sn faileY 9 X + C Vd.如下图:

所以出问题的是php-fpm,机智如我,把我另一个虚拟机(centOS7)上的php-fpm给换, Q q F上去了,2 p , 5 S 0 ] J .只需要把php的安装根目录按^ c J V – H +照自己的情况改一下就成了(就是这一行:prefix=/usr/local/php)。现在我就无私的把我的php-fpm文件奉献出来。

#! /bin/sh
### BEGIN INIT INFO
# Provides:          php-fpm
# Required-Start:    $remote_3 B \ n zfs $network
# Required-Stop:     $remote_fs $network
# DefauH J ! ^ ` [ M cltC Q o 6 W 5 i !-Start:     2 3 4 5
# Default-Stop:( \ + s      0 1 6
#0 1 S Short-Description: s2 K G 0 m : h @ Otarts php-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO
prefixW T C=/usr/local/php
exec_prefix=${prefix}
php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm.conf
php_fpm_PID=${prefix}/var/run/phpr [ K ,-fpm.pid
php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"
wait_for_pid () {
try=0
while test $try| J ( ! 5 & ) Y -lt 35 ; do
case "$1" in
'created')
if [ -f "$2" ] ; then
try=''
break
fi
;;
'rs q eemoved')
if [ ! -f "$2" ] ; then
try=''
break
fi
;;
esac
echo -n .
try3 p # U Q / U I M=`expr $try + 1`
sleep 1
donY f Q j Y [ {e
}
case "$1" in
start)
echo -n "Starting php-fpm "
$phpp 9 o \ q 3 Y ;_fpm_BIN --daemonize $php_opts
if [ "$?" != 0 ] ; then
echo " failed"
exit 1         fi
wait_for_pid created $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echE Z 9 } no " done"
fi
;;
stop)
echo -n "Graa a d ! e TcefullW 7 ny shutting down php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"V | t 1 O q Y Z
exit 1
fi
kill -QUIT `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed. Use force-quit"
exit 1
else
echo6 Z } m " done"
fi
;;
status)Q i ] * h 2 K k
if [ ! -r $php_fpm_PID ] ; then
echo "php-6 I afpm is stopped"
exit 0
fiv + G P
PID=`cat $php_fpm_PID`
if ps -p $PID | gre& & k hp -q $PID; th, n N { R C I {en
echo "php-fpm (pid $PID) is running..."
elsJ P N \e
echo "phn 9 dp-fpm dead but pid file exists"
fi
;;
force-quit)
echo -n "Terminating php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warni) E 7 Z - = / 4ng, no pid file found - php-fpm is not running ?) 1 Q 0 ] V X P ."
exit 1         fi
kill -TERM `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reload service php-fpm "I n ~ r
if [ ! -r $php_fpm_PID ] ; thenr 5 H S q W 2 @
echo "warning, no pid file found - php-fpm is not run: ^ , v ening ?"
exit 1         fi
kill -USR2 `cat $php_fpm_PID`
echo " done"
;;
configtest)
$php_fpm_BIN -t
;;
*)
echo "Usage: $0 {start|stop|forc\ 7 e I L Qe-quit|restart\ A V } 7 A|reload|status|c9 t [ s D f 4 3onfigtest}"
exit 1
;;
esac

以上就是centOS安装PHP后,php-fpm启动失败怎么办的详细内容,更多请关注php中文网其它相关文章!

php中文网最新课程二维码

声明:本文转载于:CSDN,如有侵犯,请联系admin@php.cn删除

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注