源码编译安装PHP7.4
- LNMP环境搭建
- 时间:2020-11-23
- 168人已阅读
1:下载php7.4源码
wget https://www.php.net/distributions/php-7.4.12.tar.gz
2:解压
tar zxvf php-7.4.12.tar.gz
3:安装php依赖包
cd php-7.4.12
yum install libxml2-devel sqlite-devel libcurl-devel oniguruma-devel libpng-devel libjpeg-devel freetype-devel libzip-devel openssl-devel -y
4:编译
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv --with-zlib --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-bcmath --enable-shmop --enable-sysvsem --enable-gd --with-jpeg --with-freetype --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-sockets --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-opcache --enable-fpm --with-fpm-user=php --with-fpm-group=php --without-gdbm --enable-fast-install --disable-fileinfo
5:编译没问题就开始make &make install 。有问题根据错误提示自行百度解决。
6.复制相关文件到php安装目录
cp php.ini-production /usr/local/php/etc/php.ini 复制配置文件到etc目录
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
cd /usr/local/php/etc/php-fpm.d
cp www.conf.default www.conf
7:添加用户和用户组
groupadd www
useradd -g www www
8.修改www.conf文件 将user和group改成www
9.将php添加到系统环境变量中
vim /etc/profile.d/php.sh
export PATH=$PATH:/usr/local/php/bin
编辑完后保存(esc shift+: wq),然后重新加载source
source /etc/profile.d/php.sh
10.启动php-fpm
/usr/local/php/sbin/php-fpm
11.查看php版本以及安装的扩展