环境准备:
操作系统: Red Hat Enterprise Linux 8.8 (Ootpa)
内核版本: Linux 4.18.0-477.10.1.el8_8.x86_64
1. 下载/解压软件包
[root@php-server ~]# wget https://www.php.net/distributions/php-8.4.1.tar.gz
[root@php-server ~]# tar -xf php-8.4.1.tar.gz -C /usr/local/
[root@php-server php84]# ln -s php-8.4.1 php84
2. 安装依赖
[root@php-server php84]# dnf -y install libjpeg libjpeg-devel libpng libpng-devel oniguruma freetype freetype-devel libxml2 libxml2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn openssl openssl-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2-devel openldap-devel automake autoconf libtool make openldap-devel gcc gcc-c++ sqlite-devel libxslt-devel wget vim
3. 检查环境
./configure --prefix=/usr/local/php8/ --with-config-file-path=/usr/local/php8/etc/ --with-curl --with-freetype-dir --with-gd --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg --with-xmlrpc --with-xsl --with-zlib --with-bz2 --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --with-pdo-mysql --enable-gd --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-zip --with-ldap
4. 编译过程
[root@php-server php84]# make
5. 编译安装(出现以下表示编译成功)
[root@php-server php84]# make install
Installing shared extensions: /usr/local/php8/lib/php/extensions/no-debug-non-zts-20240924/
Installing PHP CLI binary: /usr/local/php8/bin/
Installing PHP CLI man page: /usr/local/php8/php/man/man1/
Installing PHP FPM binary: /usr/local/php8/sbin/
Installing PHP FPM defconfig: /usr/local/php8/etc/
Installing PHP FPM man page: /usr/local/php8/php/man/man8/
Installing PHP FPM status page: /usr/local/php8/php/php/fpm/
Installing phpdbg binary: /usr/local/php8/bin/
Installing phpdbg man page: /usr/local/php8/php/man/man1/
Installing PHP CGI binary: /usr/local/php8/bin/
Installing PHP CGI man page: /usr/local/php8/php/man/man1/
Installing build environment: /usr/local/php8/lib/php/build/
Installing header files: /usr/local/php8/include/php/
Installing helper programs: /usr/local/php8/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php8/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php8/lib/php/
6. 需要安装依赖
<font color=red>获取方式:
RPM resource oniguruma
[root@php-server ~ ]# wget https://www.rpmfind.net/linux/almalinux/8.10/AppStream/x86_64/os/Packages/oniguruma-6.8.2-3.el8.x86_64.rpm
[root@php-server ~ ]# wget https://www.rpmfind.net/linux/almalinux/8.10/PowerTools/x86_64/os/Packages/oniguruma-devel-6.8.2-3.el8.x86_64.rpm
[root@php-server ~ ]# dnf -y install oniguruma-6.8.2-3.el8.x86_64.rpm oniguruma-devel-6.8.2-3.el8.x86_64.rpm
7. 启动PHP
- Copy PHP的配置文件
[root@php-server php8]# cp ../php84/php.ini-development etc/php.ini
[root@php-server php8]# cp etc/php
php-fpm.conf.default php-fpm.d/ php.ini-development
[root@php-server php8]# cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf
[root@php-server php8]# cp etc/php-fpm.conf.default etc/php-fpm.conf
启动
[root@php-server php8]# sbin/php-fpm
查看进程
[root@php-server php8]# ss -luntp
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=790,fd=3))
tcp LISTEN 0 2048 127.0.0.1:9000 0.0.0.0:* users:(("php-fpm",pid=150797,fd=5),("php-fpm",pid=150796,fd=5),("php-fpm",pid=150795,fd=7))
tcp LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=790,fd=4))
[root@php-server php8]# lsof -i:9000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 150795 root 7u IPv4 265939 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 150796 nobody 5u IPv4 265939 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 150797 nobody 5u IPv4 265939 0t0 TCP localhost:cslistener (LISTEN)
修改PHP服务监听的IP地址;(默认是监听127.0.0.1)
修改监听地址
[root@php-server php8]# cat etc/php-fpm.d/www.conf | grep listen
; - 'listen' (unixsocket)
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; 'port' - to listen on a TCP socket to all addresses
; '/path/to/unix/socket' - to listen on a unix socket.
;listen = 127.0.0.1:9000
;listen = 0.0.0.0:9000 #监听本机的所有网卡
listen = 192.168.107.119:9000
重启
[root@php-server php8]# pkill php-fpm
[root@php-server php8]# ss -luntp
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=790,fd=3))
tcp LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=790,fd=4))
[root@php-server php8]# sbin/php-fpm
[root@php-server php8]# ss -lutnp
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=790,fd=3))
tcp LISTEN 0 2048 192.168.107.119:9000 0.0.0.0:* users:(("php-fpm",pid=150815,fd=5),("php-fpm",pid=150814,fd=5),("php-fpm",pid=150813,fd=7))
tcp LISTEN 0 128 [::]:22
评论 (0)