#下载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();
?>