[Zabbix+Grafana]系列之二:PHP安装

#下载PHP
1、https://www.php.net/downloads.php

#安装依赖库
2、```
yum -y install epel-release
yum -y install gcc gcc-c++ make pcre pcre-devel libzip libzip-devel zlib zlib-devel openssl openssl-devel libxml2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel libmcrypt libmcrypt-devel


#编译安装

3、./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-ctype --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-freetype-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-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-fpm --with-jpeg-dir --with-png-dir

echo $?
make && make install


        #错误解决
        错误1:checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11
        解:----------
    yum remove -y libzip #先删除旧版本
    #下载编译安装
    wget https://nih.at/libzip/libzip-1.2.0.tar.gz
    tar -zxvf libzip-1.2.0.tar.gz
    cd libzip-1.2.0
    ./configure

        make && make install

        错误2:configure: error: off_t undefined; check your library configuration
        解决:----------

vim /etc/ld.so.conf
#添加如下几行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
#保存退出
:wq
ldconfig -v # 使之生效


        错误3:/usr/local/include/zip.h:59:21: 致命错误:zipconf.h    make: *** [ext/zip/php_zip.lo] 错误 1
        解决:-------
    cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

#配置环境变量和systemctl
4、vim /etc/profile
export PATH=$PATH:/usr/local/php/sbin:/usr/local/php/bin

vim /usr/lib/systemd/system/php-fpm.service
[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/php/sbin:/sur/local/php/bin
[install]
WantedBy=multi-user.target

systemctl daemon-reload 加载一下,告诉systemd系统。


#启动

5、sytemctl start php-fpm


#调试PHP与nginx环境,修改配置nginx.conf

6、vim nginx.conf
增加一个index.php
index index.html index.htm index.php;
取消注释:
location ~ .php$ {
root /data/nginx/web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#并把/scripts替换$document_root这个

#测试:
vim 1.php
<?php
phpinfo();
?>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值