1. 依赖参考
http://www.linuxfromscratch.org/lfs/view/stable/chapter03/packages.html
2. 安装方法参考
https://www.php.net/manual/zh/install.unix.apache2.php
3. 安装依赖:
yum -y install gcc gcc-c++ libxml2-devel bzip2-devel libmcrypt-devel \ openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel readline-devel \ libxslt-devel perl-devel psmisc.x86_64 recode-devel libtidy-devel expat-devel curl-devel \
4. 下载:
apr-util-1.6.1.tar.gz apr-1.6.5.tar.gz httpd-2.4.39.tar.gz php-7.2.16.tar.gz 解压 并将 apr apr-util 并 复制到 /usr/local/httpd-2.4.39/srclib 并改名apr、apr-util
6. 编译httpd 并安装
./configure --prefix=/usr/local/http-2.4.41 --sysconfdir=/usr/local/http-2.4.41/etc\ --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all\ --with-mpm=prefork --with-zlib --with-pcre --with-apr=/usr/local/apr-1.6.5 --with-apr-util=/usr/local/apr-util-1.6.1 make&&make install
7. 进入PHP 目录,编译并安装
./configure --prefix=/usr/local/php-7.2.16 --with-config-file-path=/usr/local/php-7.2.16/etc \ --enable-fpm --with-fpm-user=php --with-fpm-group=php --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr \ --enable-xml --disable-rpath --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-gd --with-openssl \ --with-mhash --enable-pcntl --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-opcache --with-xsl
8. 生成PHP.ini
cp php.ini-development /usr/local/php-7.2.16/etc
9.启用 php-fpm.conf 文件
cp php-fpm.conf.default php-fpm.conf
10.启用引用的conf文件
cp www.conf.default www.conf
11.启动PHP 命令
/usr/local/php-7.2.16/sbin/php-fpm
12. 配置开机启动
cp /usr/local/php-7.2.16/sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm chmod a+x /etc/init.d/php-fpm chkconfig --add php-fpm