源码安装php

下载php源码

1
wget https://www.php.net/distributions/php-7.4.21.tar.gz

安装

安装依赖

1
yum install -y epel-release && yum -y install gcc oniguruma-devel libzip-devel make gd-devel openssl-devel libicu-devel gcc-c++ sqlite-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel

解压并进入解压目录

1
2
tar zxvf php-7.4.21.tar.gz
cd php-7.4.21

编译安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
./configure  \
--with-config-file-path=/etc/php7 \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-fpm \
--enable-opcache \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
-enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-mysqlnd-compression-support \
--with-iconv-dir \
--with-zlib \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--enable-intl \
--enable-ftp \
--enable-gd \
--enable-gd-jis-conv \
--with-jpeg \
--with-freetype \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--with-zip \
--enable-soap \
--with-gettext \
--disable-fileinfo \
--with-pear \
--enable-maintainer-zts \
--without-gdbm

make
make install

拷贝配置文件

1
2
3
4
5
6
7
8
9
cp php.ini-production /etc/php.ini
cd sapi/fpm
cp init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
#进入安装目录操作
cp /etc/php-fpm.d/www.conf.default php-fpm.d/www.conf
cp /etc/php-fpm.conf.default /etc/php-fpm.conf