进入etc下面
去掉注释
pid = run/php-fpm.pid #指定pid文件存放位置
生成一下子配置文件
这些都是生成的fastcgi的配置文件
进入php中,然后复制模版,生成配置文件
然后编辑文件更改时区
改完之后可以生成启动脚本
这时候刷新之后,再启动会报错
root@Nginx ~]# cd /root/php-8.3.9/
[root@Nginx php-8.3.9]# cp sapi/fpm/php-fpm.service /lib/systemd/system/
# Mounts the /usr, /boot, and /etc directories read-only for processes invoked by
this unit.
#ProtectSystem=full
#注释该内容
最后启动成功
建议生成PHP的子配置文件的时候加到PHP主配置文件中本地主机之后就不会是本地主机失效
准备测试页面
[root@Nginx ~]# mkdir /data/php -p
[root@centos8 ~]# cat /data/php/index.php #php测试页面
<?php
phpinfo();
?>
nginx的配置转发
Nginx安装完成之后默认生成了与fastcgi的相关配置文件,一般保存在nginx的安装路径的conf目录当 中,比如/apps/nginx/conf/fastcgi.conf、/apps/nginx/conf/fastcgi_params。
在这里面把listen改成0.0.0.0:9000,不能用*
nginx中的配置转发
添加php环境变量
[root@Nginx ~]# vim .bash_profile
# .bash_profile # Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi # User specific environment and startup programs
PATH=$PATH:$HOME/bin:/apps/nginx/sbin:/usr/local/php/bin export PATH
[root@Nginx ~]# source .bash_profile