這篇文章將為大家詳細(xì)講解有關(guān)centOS安裝PHP后php-fpm啟動(dòng)失敗,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
白河網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)公司,白河網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為白河數(shù)千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站制作要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的白河做網(wǎng)站的公司定做!
在centOS6.8上安裝php,出各種問題,光是gcc的版本太低,升級(jí)gcc這個(gè),就讓我氣了兩天,翻遍了幾乎所有相關(guān)博客總算解決了。還有MySQL安裝也沒少踩坑,所以大家還是盡量用centOS7吧,少生氣能多活幾年呢。。。
現(xiàn)在說一下centOS6.8上編譯安裝php7.2.1吧。
1,安裝擴(kuò)展包并更新系統(tǒng)(我在根目錄下開始的):
yum install epel-release -y yum update
2,安裝php依賴組件(一段全復(fù)制上去,其實(shí)掠過也可能沒關(guān)系):
yum -y install wget vim pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel
3,下載php安裝包并解壓:
wget http://am1.php.net/distributions/php-7.2.1.tar.gz tar xvf php-7.2.1.tar.gz
4,進(jìn)入解壓目錄并開始編譯(編譯千萬不能省,運(yùn)行出錯(cuò)了就不能make了,這是我選出來的最靠譜可行的編譯了):
cd /php-7.2.1
./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-mcrypt=/usr/include --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache
5,為了安全保險(xiǎn)的給make出來,先更新依賴庫以防萬一:
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel
6,安裝:
make make install
7,關(guān)于配置:
cp php.ini-development /usr/local/php7/etc/php.ini cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
8,加個(gè)權(quán)限:
chmod +x /etc/init.d/php-fpm
現(xiàn)在試一下,/etc/init.d/php-fpm start
如果php啟動(dòng)成功了,那你很幸福;如果失敗了,接著往下看。
大概出現(xiàn)的是下圖這個(gè)情況吧?
再試一下運(yùn)行提示的命令,出的問題是ERROR:FPM initialization failed.如下圖:
所以出問題的是php-fpm,機(jī)智如我,把我另一個(gè)虛擬機(jī)(centOS7)上的php-fpm給換上去了,只需要把php的安裝根目錄按照自己的情況改一下就成了(就是這一行:prefix=/usr/local/php)?,F(xiàn)在我就無私的把我的php-fpm文件奉獻(xiàn)出來。
#! /bin/sh ### BEGIN INIT INFO # Provides: php-fpm # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts php-fpm # Description: starts the PHP FastCGI Process Manager daemon ### END INIT INFO prefix=/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/php-fpm.pid php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID" wait_for_pid () { try=0 while test $try -lt 35 ; do case "$1" in 'created') if [ -f "$2" ] ; then try='' break fi ;; 'removed') if [ ! -f "$2" ] ; then try='' break fi ;; esac echo -n . try=`expr $try + 1` sleep 1 done } case "$1" in start) echo -n "Starting php-fpm " $php_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 echo " done" fi ;; stop) echo -n "Gracefully shutting down php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" 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 echo " done" fi ;; status) if [ ! -r $php_fpm_PID ] ; then echo "php-fpm is stopped" exit 0 fi PID=`cat $php_fpm_PID` if ps -p $PID | grep -q $PID; then echo "php-fpm (pid $PID) is running..." else echo "php-fpm dead but pid file exists" fi ;; force-quit) echo -n "Terminating php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" 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 " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -USR2 `cat $php_fpm_PID` echo " done" ;; configtest) $php_fpm_BIN -t ;; *) echo "Usage: $0 {start|stop|force-quit|restart|reload|status|configtest}" exit 1 ;; esac
關(guān)于“centOS安裝PHP后php-fpm啟動(dòng)失敗”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。
網(wǎng)頁標(biāo)題:centOS安裝PHP后php-fpm啟動(dòng)失敗
URL鏈接:http://m.rwnh.cn/article48/jdgcep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、ChatGPT、全網(wǎng)營銷推廣、網(wǎng)站策劃、網(wǎng)站收錄、網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)