系统centos7.5 php版本 7.4.9
安装依赖:
yum install -y gcc gcc-c++
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
下载:php-7.4.9.tar.gz
tar -xvf php-7.4.9.tar.gz
cd php-7.4.9
groupadd www
useradd -M -s /sbin/nologin www -g www
./configure --prefix=/usr/local/php74 --with-freetype-dir --with-gd --with-curl --with-openssl --with-zlib --enable-libxml --enable-xml --enable-zip --enable-opcache --enable-sysvsem --enable-mbstring --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-config-file-path=/usr/local/php74/etc/ --enable-sockets --with-xmlrpc --with-gettext --enable-fileinfo
make && make install
如果不想编译sqlite3 增加:--without-sqlite3
如果不想编译fileinfo 这增加:--disable-fileinfo
注意:建议如果没有用到的扩展建议不编译,因为在php启动的过程中会加载这些扩展浪费内存。
配置配置文件:
mv php.ini-production /usr/local/php74/etc/php.ini
mv /usr/local/php74/etc/php-fpm.d/www.conf.default /usr/local/php74/etc/php-fpm.d/www.conf
mv /usr/local/php74/etc/php-fpm.conf.default /usr/local/php74/etc/php-fpm.conf
启动php-fpm:
/usr/local/php74/sbin/php-fpm -c /usr/local/php74/etc/php.ini -y /usr/local/php74/etc/php-fpm.conf
遇到问题:
1:找不到sqlite安装包
yum install sqlite-devel
2:No package ‘oniguruma‘ found
yum -y install autoconf automake libtool
wget https://github.com/kkos/oniguruma/archive/v6.9.5_rev1.tar.gz
tar -xvf oniguruma-6.9.4.tar.gz
cd oniguruma-6.9.4/
./autogen.sh
./configure --prefix=/usr --libdir=/lib64
make && make install