下载
wget https://www.php.net/distributions/php-7.4.1.tar.gz
详细配置地址:
https://www.php.net/manual/zh/configure.about.php
编译:
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
make && make install
错误信息文档
https://www.cnblogs.com/architectforest/p/12433541.html
找不到php.ini文件
将编译安装包中的php.ini-development复制到php配置文件所在目录修改为php.ini
nginx配置文件没有问题时运行php文件出现file not found
修改php-fpm.conf中的user和group为固定用户
将php-fpm添加到systemctl
vi /usr/lib/systemd/system/php-fpm.service
将下面的代码添加到php-fpm.server中
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/var/run/php-fpm.pid #打开php-fpm.conf找到 pid的配置路径
ExecStart=/usr/local/php/sbin/php-fpm #php-fpm的启动路径
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
添加完成后执行 systemctl daemon-reload 重新加载就可以使用了
编译安装php扩展
进入php编译的安装包 进入到ext目录中选择所需要扩展 进入目录
执行phpize 会生成configure文件
找到php-config文件
执行 ./configure --with-php-config=文件地址 --with-所需扩展名
nginx文件解析漏洞
1.将php.ini文件中的cgi.fix_pathinfo的值设置为0
2.php-fpm.conf中的security.limit_extensions后面的值设置为.php