-fpm \
--enable-mysqlnd \
--with-mysqli \
--with-pdo-mysql \
--enable-opcache \
--with-pcre-jit \
--enable-gd \
--with-jpeg \
--with-freetype \
--with-gettext \
--with-curl \
--with-openssl \
--enable-sockets \
--enable-mbstring \
--enable-xml \
--with-zip \
--with-zlib \
--with-snmp \
--with-mhash \
--enable-ftp \
--enable-bcmath \
--enable-soap \
--enable-shmop \
--enable-sysvsem \
--enable-pcntl \
--with-gmp
//显示这个表示没问题了
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
[root@php php-8.1.11]# make && make install
//配置环境变量
[root@php ~]# echo 'export PATH=/usr/local/php8/bin:$PATH' > /etc/profile.d/php8.sh
[root@php ~]# source /etc/profile.d/php8.sh
//配置php-fpm
[root@php ~]# cd php-8.1.11
[root@php php-8.1.11]# cp php.ini-production /etc/php.ini
cp: overwrite '/etc/php.ini'? y
[root@php php-8.1.11]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@php php-8.1.11]# chmod +x /etc/rc.d/init.d/php-fpm
[root@php php-8.1.11]# cp /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf
[root@php php-8.1.11]# cp /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf
//启动php-fpm
[root@php ~]# service php-fpm start
Starting php-fpm done
[root@php ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
安装后配置
php端配置
//修改配置文件
[root@php ~]# vim /usr/local/php8/etc/php-fpm.d/www.conf
listen = 192.168.111.143:9000 //修改为php本机IP
listen.allowed_clients = 192.168.111.141 //允许指定ip访问
//在php端上配置网站
[root@php ~]# mkdir -p /var/www/html
[root@php ~]# vim /var/www/html/index.php
<?php
phpinfo();
?>
//重启php-fpm服务
[root@php ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@php ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 192.168.111.143:9000 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
nginx服务器端
//创建一个.php结尾的文件,用于匹配
[root@nginx ~]# touch /usr/local/nginx/html/index.php
//修改配置文件
[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
#查找index
location / {
root html;
index index.php index.html index.htm; //添加index.php
}
#大概65-71行,取消注释
location ~ \.php$ {
root /var/www/html; //指向php端index.php文件位置
fastcgi_pass 192.168.111.143:9000; //ip地址为php服务器地址
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; //将/scripts更改为$document_root
include fastcgi_params;
}
//重启服务
[root@nginx ~]# systemctl restart nginx
浏览器访问