一、下载安装包
官网:PHP:下载https://www.php.net/downloads
二、解压安装包并生成编译文件
1.解压安装包
解压:tar -zxvf
2.安装依赖包
yum install -y libxml2-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libxslt-devel libzip-devel sqlite sqlite-devel epel-release oniguruma-deve
3.生成编译文件
./configure --prefix=/home/ops/php --with-fpm-user=nginx --with-fpm-group=nginx --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm
注:此图为生成编译文件成功;
3.编译及安装
make && make install
4.配置建立目录
cp php.ini-production /home/ops/php/lib/php.ini cp /home/ops/php/etc/php-fpm.conf.default /home/ops/php/etc/php-fpm.conf ln -s /home/ops/php/sbin/php-fpm /usr/local/bin/php-fpm cd /home/ops/php/etc/php-fpm.d vim www.conf [www] listen = 127.0.0.1:9000 listen.mode = 0666 user = nginx group = nginx pm = dynamic pm.max_children = 128 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 10000 rlimit_files = 1024 slowlog = log/$pool.log.slow
cd /home/ops/php-8.2.21/sapi/fpm
cp php-fpm.service /usr/lib/systemd/system/
systemctl start php-fpm systemctl daemon-reload
systemctl start php-fpm systemctl status php-fpm
报错一:缺少依赖包
configure: error: Package requirements (sqlite3 >= 3.7.7) were not met:
No package 'sqlite3' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables SQLITE_CFLAGS
and SQLITE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
解决方法:
安装:yum install sqlite sqlite-devel -y
报错二:缺少依赖包
configure: error: Package requirements (oniguruma) were not met: No package 'oniguruma' found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables ONIG_CFLAGS and ONIG_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.
解决方法:
安装:yum install epel-release -y
安装:yum install oniguruma-deve -y
报错三:未找到日志
php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 三 2024-07-24 14:41:08 CST; 1min 36s ago
Process: 100148 ExecStart=/home/ops/php/sbin/php-fpm --nodaemonize --fpm-config /home/ops/php/etc/php-fpm.conf (code=exited, status=78)
Main PID: 100148 (code=exited, status=78)7月 24 14:41:08 localhost.localdomain systemd[1]: Started The PHP FastCGI Process Manager.
7月 24 14:41:08 localhost.localdomain php-fpm[100148]: [24-Jul-2024 14:41:08] ERROR: [...'
7月 24 14:41:08 localhost.localdomain php-fpm[100148]: [24-Jul-2024 14:41:08] ERROR: F...d
7月 24 14:41:08 localhost.localdomain systemd[1]: php-fpm.service: main process exited...a
7月 24 14:41:08 localhost.localdomain systemd[1]: Unit php-fpm.service entered failed ....
7月 24 14:41:08 localhost.localdomain systemd[1]: php-fpm.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
解决方法:
重新指定错误日志路径:error_log = /home/ops/php/var/log/php-fpm.log
报错四:未找到关联的nginx用户id
[24-Jul-2024 16:53:34] ERROR: [pool www] cannot get uid for user 'nginx' [24-Jul-2024 16:53:34] ERROR: FPM initialization failed
解决方法:
查看:id nginx
创建:useradd -m nginx
修改用户密码:passwd nginx
修改nginx配置文件vim /usr/local/nginx/conf/nginx.conf
user nginx;
worker_processes auto;
修改php-EPM配置文件:vim /home/ops/php/etc/php-fpm.d/www.conf
user与group配置项是否与nginx一致;
报错五:占用了9000端口号
[24-Jul-2024 17:00:52] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98) [24-Jul-2024 17:00:52] ERROR: FPM initialization failed
解决方法:
安装:yum install lsof -y
查看进程id:lsof -i :9000
杀死进程id号:sudo kill -9 PID
重启服务并查看服务状态:
systemctl restart php-fpm
systemctl status php-fpm
此图为服务正在运行;