PHP

1.    下载地址

http://cn2.php.net/distributions/php-5.4.45.tar.bz2

2.    依赖包

要求版本在5.4以上(zabbix 3.0.1)

依赖包

yum -y install libxml2-devel bzip2-devel libidn-devel gd gd-devel libmcrypt libmcrypt-devel php-gd openssl openssl-devel libcurl libcurl-devel
ln -sv /usr/include/gd.h /usr/lib64/

'gdIOCtx' has no member named 'data'

 修改--with-gd=/usr/lib64 成--with-gd

3.    编译安装

./configure 
--prefix=/usr/local/php  
--enable-fpm   
--with-mcrypt=/usr/lib64  
--with-zlib  
--enable-mbstring  
--with-openssl  
--with-mysql  
--with-mysqli  
--with-mysql-sock   
--with-jpeg-dir=/usr/lib  
--enable-pdo  
--with-pdo-mysql  
--with-gettext  
--with-curl  
--with-pdo-mysql  
--enable-sockets  
--enable-bcmath  
--enable-xml  
--with-bz2  
--enable-zip  
--with-freetype-dir=/usr/lib64  
--with-gd  
--enable-gd-native-ttf

make ZEND_EXTRA_LIBS='-liconv'
make install

4.    fpm启动脚本

#!/bin/sh 
# DateTime: 2013-09-16
# Author: lianbaikai
# site:http://www.ttlsa.com/html/3039.html
# chkconfig:   - 84 16  
# Source function library. 
. /etc/rc.d/init.d/functions 
# Source networking configuration. 
. /etc/sysconfig/network 
# Check that networking is up. 
[ "$NETWORKING" = "no" ] && exit 0 
 
phpfpm="/usr/local/php/sbin/php-fpm" 
prog=$(basename ${phpfpm}) 
lockfile=/var/lock/subsys/phpfpm

start() { 

    [ -x ${phpfpm} ] || exit 5 
    echo -n $"Starting $prog: " 
    daemon ${phpfpm}
    retval=$? 
    echo 
    [ $retval -eq 0 ] && touch $lockfile 
    return $retval 
} 

stop() { 
    echo -n $"Stopping $prog: " 
    killproc $prog -QUIT 
    retval=$? 
    echo 
    [ $retval -eq 0 ] && rm -f $lockfile 
    return $retval 
} 

restart() { 
    configtest || return $? 
    stop 
    start 
} 

reload() { 
    configtest || return $? 
    echo -n $"Reloading $prog: " 
    killproc ${phpfpm} -HUP 
    RETVAL=$? 
    echo 
} 

force_reload() { 
    restart
} 

configtest() { 
  ${phpfpm} -t
} 

rh_status() { 
    status $prog 
} 

rh_status_q() { 
    rh_status >/dev/null 2>&1 
} 

case "$1" in 
    start) 
        rh_status_q && exit 0 
        $1 
        ;; 
    stop) 
        rh_status_q || exit 0 
        $1 
        ;; 
    restart|configtest) 
        $1 
        ;; 
    reload) 
        rh_status_q || exit 7 
        $1 
        ;; 
    status) 
        rh_status 
        ;; 
    *) 
        echo $"Usage: $0 {start|stop|status|restart|reload|configtest}" 
        exit 2 
esac

5.    php测试页

<?php

phpinfo();

?>

6.    Nginx连接PHP

location ~ .*.(php)?${
  expires -ls;
  try_file $uri=404;
  fastcgi_split_path_info ~(.+.php)(/.+)$;
  include fastcgi_params;
  fastcgi_param PATH_INFO $fastcgi_path_info;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_pass 127.0.0.1:9000;
  #fastcgi_pass unix:/var/run/phpfpm.sock;
}

7.    Nginx和PHP分离

需要使用nfs使php服务器和nginx服务器web目录一致

原文地址:https://www.cnblogs.com/djoker/p/6396865.html