1 把php安装包上传到服务器
2 安装php所需要的扩展 yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel gd gd-devel
3 安装php tar -jxvf php-5.6.12.tar.bz2 cd php-5.6.12 ./configure --prefix=/usr/local/php5.6 --enable-shared --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-libxml-dir --with-curl --with-zlib-dir -with-gettext --with-jpeg-dir --with-png-dir --with-bz2 --with-freetype-dir --with-iconv --with-config-file-path=/usr/local/php5.6/etc --enable-mbstring --with-gd --disable-debug --enable-short-tags --disable-posix --enable-exif --enable-ftp --enable-sockets --with-mhash --enable-zip --enable-opcache --enable-inline-optimization make make install cp php.ini-production /usr/local/php5.6/etc/php.ini
4 更改php配置文件 编辑 php.ini文件 设置如下 short_open_tag = On disable_functions = "dl,exec,passthru,pcntl_exec,popen,posix_kill,posix_mkfifo,posix_setuid,proc_close,proc_open,proc_terminate,shell_exec,system,leak,posix_setpgid,posix_setsid,proc_get_status,proc_nice,show_source" cgi.fix_pathinfo=0 date.timezone = Asia/Shanghai expose_php = Off
5 编辑php-fpm配置文件 cp php-fpm.conf.default php-fpm.conf 编辑 php-fpm.conf 设置如下 pid = /usr/local/php5.6/var/run/php-fpm.pid error_log = log/php-fpm.log log_level = notice process_control_timeout = 30 events.mechanism = epoll listen = 127.0.0.1:9056 listen.backlog = -1 pm.max_children = 1024 pm.start_servers = 80 pm.min_spare_servers = 20 pm.max_spare_servers = 80 pm.max_requests = 2000 pm.status_path = /status ping.path = /ping ping.response = pong slowlog = var/log/phpslow_$pool.log request_slowlog_timeout = 5s request_terminate_timeout = 60s rlimit_files = 65534 php_admin_value[open_basedir] = "/tmp/" php_admin_value[disable_functions] = dl,exec,leak,passthru,pcntl_exec,popen,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,system
6 测试 #测试php-fpm配置 /usr/local/php5.6/sbin/php-fpm -t /usr/local/php5.6/sbin/php-fpm -c /usr/local/php5.6/etc/php.ini -y /usr/local/php5.6/etc/php-fpm.conf -t #启动php-fpm /usr/local/php5.6/sbin/php-fpm /usr/local/php5.6/sbin/php-fpm -c /usr/local/php5.6/etc/php.ini -y /usr/local/php5.6/etc/php-fpm.conf #关闭php-fpm kill -INT `cat /usr/local/php5.6/var/run/php-fpm.pid` #重启php-fpm kill -USR2 `cat /usr/local/php5.6/var/run/php-fpm.pid`
7 设置开机启动 vi /etc/init.d/php5.6-fpm 写入如下内容 根据实际情况修改 #!/bin/bash # chkconfig: 2345 10 90 # description: php-fpm is a FastCGI web server. # processname: php5.6-fpm # config: /usr/local/php5.6/etc/php-fpm.conf # pidfile: /usr/local/php5.6/var/run/php-fpm.pid #======================================================================================= PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin BINFILE="/usr/local/php5.6/sbin/php-fpm" CFGFILE="/usr/local/php5.6/etc/php-fpm.conf" PIDFILE="/usr/local/php5.6/var/run/php-fpm.pid" LOCKFILE="/usr/local/php5.6/var/run/php-fpm.lock" RETVAL=0 start() { [[ -x $BINFILE ]] || exit 5 [[ -f $CFGFILE ]] || exit 6 if [[ `ps aux | grep php-fpm: | grep -v grep | wc -l` -gt 0 ]]; then echo "The php-fpm is already running." return 1 fi $BINFILE -t >/dev/null 2>&1 if [[ $? -ne 0 ]]; then echo "The php-fpm configure has error." return 1 fi echo -n "Starting php-fpm......" $BINFILE -y $CFGFILE -g ${PIDFILE} RETVAL=$? echo [[ $RETVAL -eq 0 ]] && touch $LOCKFILE return $RETVAL } stop() { if [[ `ps aux | grep php-fpm: | grep -v grep | wc -l` -eq 0 ]]; then echo "The php-fpm is not running." return 1 fi echo -n "Shutting down php-fpm......" if [[ -f $PIDFILE ]]; then kill -QUIT `cat ${PIDFILE}` else kill -QUIT `ps aux | grep php-fpm | awk '/master/{print $2}'` fi RETVAL=$? echo [[ $RETVAL -eq 0 ]] && rm -f $LOCKFILE $PIDFILE return $RETVAL } restart() { stop sleep 1 while true do if [[ `ps aux | grep php-fpm: | grep -v grep | wc -l` -eq 0 ]]; then start break fi sleep 1 done RETVAL=$? echo return $RETVAL } reload() { if [[ `ps aux | grep php-fpm: | grep -v grep | wc -l` -eq 0 ]]; then echo "The php-fpm is not running." return 1 fi echo -n $"Reloading php-fpm......" if [[ -f $PIDFILE ]]; then kill -USR2 `cat ${PIDFILE}` else kill -USR2 `ps aux | grep php-fpm | awk '/master/{print $2}'` fi RETVAL=$? echo return $RETVAL } case "$1" in start) start ;; stop) stop ;; restart) restart ;; reload) reload ;; *) echo "Usage: service php-fpm {start|stop|restart|reload}" RETVAL=1 esac exit $RETVAL
8 配置开机自动 chmod 755 /etc/init.d/php5.6-fpm chkconfig --add php5.6-fpm chkconfig php5.6-fpm on /etc/init.d/php5.6-fpm start
标签:LTS,12,5.6,fpm,--,usr,php,local,php5.6 From: https://www.cnblogs.com/jackspider/p/18143994