1.安装依赖
yum install -y gcc gcc-c++ make zlib libzip* 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
2.下载解压
cd /data/soft
wget https://www.oaroad.com/files/php-7.2.32.tar.gz
tar -xzf php-7.2.32.tar.gz
3.编译php
cd php-7.2.32
./configure --prefix=/data/php7.2 \
--with-config-file-path=/data/php7.2/etc \
--with-config-file-scan-dir=/data/php7.2/etc/php.d \
--with-mcrypt=/data/php7.2/include \
--enable-mysqlnd \
--with-mysqli \
--with-pdo-mysql \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-gd \
--with-iconv \
--with-zlib \
--enable-xml \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache
4.新增交换分区
#已有交换分区可跳过这一步
关闭交互分区
swapoff -a
创建一个交换区文件
dd if=/dev/zero of=/opt/swap bs=1024 count=1M
将目的文件设置为swap分区文件
mkswap /opt/swap
激活swap,立即启用交换分区文件
swapon /opt/swap
把交换区记录到系统里边
echo "/opt/swap swap swap defaults 0 0" >> /etc/fstab
查看交互分区大小
swapon
5.安装PHP
make
make test
make install
6.配置fpm
cp php.ini-production /data/php7.2/etc/php.ini
cp /data/php7.2/etc/php-fpm.conf.default /data/php7.2/etc/php-fpm.conf
cp /data/php7.2/etc/php-fpm.d/www.conf.default /data/php7.2/etc/php-fpm.d/www.conf
ln -s /data/php7.2/sbin/php-fpm /usr/local/sbin/php-fpm
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
useradd www
vim /data/php7.2/etc/php-fpm.d/www.conf
user = www
group = www
vim /data/php7.2/etc/php.ini
cgi.fix_pathinfo=0
7.启动php-fpm
php-fpm
ps -aux |grep ph[p]
评论