1.解决依赖包
命令:
yum -y install libicu-devel libxslt-devel
2.解决编译出现错误:configure: error: Cannot find ldap libraries in /usr/lib
操作:cp -frp /usr/lib64/libldap* /usr/lib/
3.php 7.3.7需要libzip的版本在1.2.0及以上,重新编译安装libzip
命令:
yum remove -y libzip
cd /usr/local/src
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
4.解决编译出现报错:php安装执行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 # 使之生效
5.解决编译出现报错:安装php7.3.7 解决报错 /usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or dire
命令:
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
6.下载php7.37到/usr/local/src目录,或者直接下载再上传到/usr/local/src也行
命令:
cd /usr/local/src
wget https://www.php.net/distributions/php-7.3.7.tar.gz #下载比较慢,建议直接下载上传
7.预编译php7.3.7
命令:
cd php7.3.7
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc --enable-mysqlnd \
--with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--enable-mysqlnd-compression-support --with-iconv-dir \
--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 --enable-intl \
--with-gd --enable-gd-jis-conv --with-openssl \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc \
--enable-zip --enable-soap --with-gettext --disable-fileinfo \
--enable-opcache --with-pear --enable-maintainer-zts \
--with-ldap=shared --without-gdbm --enable-fpm
8.编译安装php
命令:make &&make install
9.复制php.ini
命令:cp php.ini-production /usr/local/php/etc/php.ini
10.复制配置文件php-fpm.conf
命令:mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
11.复制
命令:
cd /usr/local/php/etc/php-fpm.d/
mv www.conf.default www.conf
12.添加环境变量
命令:
vi /etc/profile.d/php-fpm.sh
export PATH=$PATH:/usr/local/php/sbin/:/usr/local/php/bin/
重启环境变量让其立即生效
13.检查配置文件是否有误
命令:
php-fpm -t
14.添加systemctl脚本启动文件
命令:
vi /usr/lib/systemd/system/php-rpm.service
[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
[Install]
WantedBy=multi-user.target
15.添加开机自启,启动php-fpm服务
命令:
systemctl enable php-fpm
systemctl start php-fpm
16.查看php-fpm进程
命令:
ps aux | grep php-fpm
17.验证php文件是否正常访问
在nginx的html目录下创建一个test.php文件,并输入如下内容
echo "zabbix 4.X";
?>
配置nginx的配置文件nginx.conf,找到location /下添加index.php
命令:
vi /usr/local/nginx/conf/nginx.conf
启用fastcgi,默认是被注释掉,并把/scripts$fastcgi_script_name修改为$document_root$fastcgi_script_name
重启下nginx进程
命令:
systemctl restart nginx