189 8069 5689

centos6.5安装php5.6-创新互联

安装php

乌尔禾网站建设公司创新互联公司,乌尔禾网站设计制作,有大型网站制作公司丰富经验。已为乌尔禾上1000+提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的乌尔禾做网站的公司定做!

安装依赖包

yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel –y

安装epel源

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

yum -y install libmcrypt-devel mcytpt mhash libxslt-devel

安装libiconv

tar -zxvf libiconv-1.14.tar.gz

cd libiconv-1.14

./configure –prefix=/usr/lcoal/libiconv

Make && make install

解压安装包

tar -zxvf php-5.6.20.tar.gz

配置编译安装

cd php-5.6.20

./configure  \

–prefix=/usr/local/php-5.6.20 \

–with-config-file-path=/usr/local/php-5.6.20/etc \

–with-fpm-user=nginx \

–with-fpm-group=nginx \

–with-bz2 \

–with-curl \

–with-gd \

–with-mcrypt \

–with-openssl \

–with-mhash \

–with-jpeg-dir \

–with-png-dir \

–with-freetype-dir \

–with-iconv-dir=/usr/local/libiconv \

–with-gettext \

–with-libxml-dir=/usr/local \

–with-zlib \

–with-xsl \

–with-pdo-mysql=mysqlnd \

–with-mysql=mysqlnd \

–with-mysqli=mysqlnd \

–with-libdir=lib64 \

–enable-dom \

–enable-xml \

–enable-fpm \

–enable-bcmath \

–enable-ftp \

–enable-sockets \

–disable-ipv6 \

–enable-mbregex \

–enable-mbstring \

–enable-calendar \

–enable-gd-native-ttf \

–enable-static \

make

make install

cp php.ini-production /usr/local/php/lib/php.ini

cp /usr/local/php/etc/php-fpm.conf.default  /usr/local/php/etc/php-fpm.conf

cd /usr/local/php/

mkdir log

编辑配置文件

pid = /var/log/php-fpm.pid

error_log = log/php-fpm.log

log_level = error

rlimit_files = 32768

events.mechanism = epoll

[www]

user = nginx

group = nginx

listen = 127.0.0.1:9000

pm = dynamic

pm.max_children = 1024

pm.start_servers = 16

pm.min_spare_servers = 5

pm.max_spare_servers = 20

pm.process_idle_timeout = 15s;

pm.max_requests = 2048

slowlog = log/$pool.log.slow

request_slowlog_timeout = 10

创建启动停止脚本:

vim /etc/init.d/php-fpm

#! /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

赋予权限

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

启动

[root@zabbix-server php-5.6.20]# service php-fpm start

Starting php-fpm  done

[root@zabbix-server php-5.6.20]# netstat -anpt |grep php-fpm

tcp      0    0 127.0.0.1:9000          0.0.0.0:*            LISTEN    16070/php-fpm

配置nginx 支持php

打开配置文件在server区块加入下面内容(这里是虚拟主机,网站根目录也在cj下面)

server {

    listen    80;

      server_name  www.cj.com cj.com;

      charset utf-8;

      #access_log      logs/access_cj.log main;

      access_log  logs/access_cj.log;

      location / {

        root  html/cj;

        index  index.html index.htm;

      }

      error_page  500 502 503 504  /50x.html;

      location = /50x.html {

        root  html;

      }

      location ~ \.php$ {

        root        html;

        fastcgi_pass  127.0.0.1:9000;

        fastcgi_index  index.php;

        fastcgi_param SCRIPT_FILENAME  /usr/local/nginx/html/cj$fastcgi_script_name;

        include      fastcgi_params;

      }

}

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


本文名称:centos6.5安装php5.6-创新互联
浏览路径:http://cdxtjz.cn/article/dscgdo.html

其他资讯