1.php安装依赖
yum -y install epel-release
yum -y install gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers sqlite-devel oniguruma-devel
2.下载php源码包
yum -y install wget //安装wget用来下载源码包
wget https://www.php.net/distributions/php-7.4.13.tar.gz
tar xzf php-7.4.13.tar.gz //解压源码包
cd php-7.4.13
3.编译并安装
./configure --prefix=/srv/php --with-config-file-path=/srv/php --enable-mbstring --enable-ftp --enable-gd --enable-gd-jis-conv --enable-mysqlnd --enable-pdo --enable-sockets --enable-fpm --enable-xml --enable-soap --enable-pcntl --enable-cli --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pear --with-zlib --with-iconv --with-curl
开始安装
make && make install
4.修改php配置文件
在之前编译的源码包中,找到 php.ini-production,复制到/srv/php下,并改名为php.ini
cp php.ini-production /srv/php/php.ini
修改php.ini 设置让PHP错误信息打印在页面上
vi /srv/php/php.ini
display_errors = On //原来是display_errors = off
修改php-fpm配置文件:
cd /srv/php/etc
cp php-fpm.conf.default php-fpm.conf
vi php-fpm.conf
去掉 pid = run/php-fpm.pid 前面的分号
cd /srv/php/etc/php-fpm.d/
cp www.conf.default www.conf
启动php
/srv/php/sbin/php-fpm
查看进程
ps -axu | grep php
配合源码安装nginx始nginx支持php
nginx源码安装