您的位置 首页 php

Zabbix4.0企业级搭建实战(2)LNMP之PHP源码编译安装

LNMP 之PHP源码编译安装

1、为什么需要安装php

1)、 Zabbix 的网页后端语言使用PHP

2)、PHP的安装相对复杂,需要解决很多依赖

2、Php官网

3、php编译安装脚本

yum -y install epel-release

yum -y install gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel libmcrypt libmcrypt-devel

cd /usr/local/src/

wget ‘

tar -zxf php-5.6.40.tar.gz

cd php-5.6.40

./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –enable-ctype –with-mysql=mysqlnd –with-mysqli=mysqlnd –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –enable-mbregex –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap-sasl –with-xmlrpc –enable-zip –enable-soap –with-gettext –enable-fpm

make && make install

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

4、php编译安装说明

–prefix指定php的安装目录

–with-config-file-path指定php的配置文件位置

–with-mysql、–with-mysqli让php可以操作mysql

–enable-fpm主要是 nginx 要来调用php语言得使用php-fpm

5、启动php-fpm

1)、环境变量:export PATH=$PATH:/usr/local/php/sbin/:/usr/local/php/bin/

vim /etc/profile

增加如下内容:

export PATH=$PATH:/usr/local/php/sbin/:/usr/local/php/bin/

使环境变量生效:

source /etc/profile

检查php版本:

php -version

2)、检查配置文件

php-fpm -t

报错:

这是由于没有”/usr/local/php/etc/php-fpm.conf”这个文件的原因,通过ls命令可以看到这个文件是不存在的。

解决办法:

使用默认配置文件

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

问题解决:

3)、 查看php-fpm的listen配置

6、验证php-fpm的启动

1)、进程

ps aux | grep php-fpm

2)、端口

netstat -lnutp | grep php-fpm

3)、日志

tailf /usr/local/php/ var /log/php-fpm.log

7、使用systemctl管理php-fpm

vim /usr/lib/systemd/system/php-fpm.service

[Unit]

Description=php-fpm

After=network.target

[Service]

Type=forking

ExecStart=/usr/local/php/sbin/php-fpm

[Install]

WantedBy=multi-user.target

8、修改nginx配置,开启php连接

nginx的默认配置无法处理php程序

vim /usr/local/nginx/html/test.php

输入如下内容:

<?php

echo “taobao zabbix”;

?>

访问测试:

只能下载该test.html

nginx+php-fpm结合的配置

vim /usr/local/nginx/conf/nginx.conf

修改如下标红配置:

location / {

root html;

index index.html index.htm index.php;

}

location ~ \.php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

9、PHP访问测试

nginx -t

nginx -s reload

访问

文章来源:智云一二三科技

文章标题:Zabbix4.0企业级搭建实战(2)LNMP之PHP源码编译安装

文章地址:https://www.zhihuclub.com/79021.shtml

关于作者: 智云科技

热门文章

网站地图