安装php并使用nginx连接PHP

安装前需要安装的包:

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

编译如下:

./configure –prefix=/usr/local/php-5.6.31 \
–with-config-file-path=/usr/local/php-5.6.31/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 –with-xpm-dir=/usr

make

make install

安装完成后需要配置Php,打开php.ini配置文件,修改如下参数为如下值,否则zabbix安装不了

把安装源文件中的php.ini-production复制到/usr/local/php-5.6.31/etc下面,改名为php.ini

修改如下参数:

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

然后:cp /usr/local/php-5.6.31/etc/php-fpm.conf.default /usr/local/php-5.6.31/etc/php-fpm.conf

启动php-fpm
[root@zabbixserver sbin]# ./php-fpm
[root@zabbixserver sbin]# netstat -lnt|grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN

配置nginx连接php

mkdir -p /data/logs/nginx/ # 用于存放nginx日志

mkdir -p /data/site/zabbixserver.com/ # 站点根目录
vim /data/site/zabbixserver.com/info.php

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

server {
listen 80;
server_name zabbixserver.com;
access_log /data/logs/nginx/zabbixserver.com.access.log main;

index index.php index.html index.html;
root /data/site/zabbixserver.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;

}
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值