php 源码安装

1. 安装PHP 5.6.36

源码下载地址:

http://cn2.php.net/get/php-5.6.36.tar.gz/from/this/mirror

安装依赖包:

确保安装之前有安装gd,png,curl,xml等等lib开发库。如果不确定,执行以下命

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

  编译安装PHP 5.6

zabbix对PHP参数、PHP模块有特殊要求。

1.1 PHP安装参数
php具体安装方法参考上面的链接,不过如下模块要特别留意加上
bcmath        --enable-bcmath
mbstring    --enable-mbstring
sockets        --enable-sockets
gd            --with-gd
libxml        --with-libxml-dir=/usr/local
xmlwriter    同上
xmlreader    同上
ctype        默认支持
session        默认支持
gettext        默认支持

以下是我PHP的配置参数

./configure  --prefix=/usr/local/php-5.6.36 
--with-config-file-path=/usr/local/php-5.6.36/etc --with-bz2 --with-curl 
--enable-ftp --enable-sockets --disable-ipv6 --with-gd 
--with-jpeg-dir=/usr/local --with-png-dir=/usr/local 
--with-freetype-dir=/usr/local --enable-gd-native-ttf 
--with-iconv-dir=/usr/local --enable-mbstring --enable-calendar 
--with-gettext --with-libxml-dir=/usr/local --with-zlib 
--with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd 
--enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath

 安装 make&& make install

zabbix对php有一些要求

 max_execution_time = 300
 memory_limit = 128M
 post_max_size = 16M
 upload_max_filesize = 2M
 max_input_time = 300
 date.timezone PRC

  

nginx配置

在nginx.conf的http断中加上如下内容:

server {
listen 80;
server_name test.ttlsa.com;
access_log /data/logs/nginx/test.ttlsa.com.access.log main;
 
index index.php index.html index.html;
root /data/site/test.ttlsa.com;
 
location /
{
try_files $uri $uri/ /index.php?$args;
}
 
location ~ .*.(php)?$
{
expires -1s;
try_files $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;
 
}
}

  重启nginx

/usr/local/nginx-1.14.0/sbin/nginx -s reload

  测试

原文地址:https://www.cnblogs.com/heitaoq/p/9276346.html