1.下载软件
进入http://php.net/get/php-7.2.12.tar.gz/from/a/mirror选择相应的镜像地址下载相应的版本
2.安装必要的依赖
yum install libxml2 libxml2-devel openssl openssl-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel -y
3.创建公共软件保存目录和软件安装目录
创建一个目录/soft,这个目录用来保存一些安装的软件包。
创建一个目录/data,这个目录用来具体安装的软件包
mkdir -p /soft
mkdir -p /data
4.解压下载的php软件包
上传下载到本地的php-7.2.12.tar.gz到/soft目录下面,并且解压
cd /soft
tar –zxvf php-7.2.12.tar.gz
5.编译安装参数
mkdir -p /data/php7.2
cd /soft/php-7.2.12
./configure --prefix=/data/php7.2/ --with-config-file-path=/data/php7.2/etc --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-simplexml --enable-xml --disable-rpath --enable-bcmath --enable-soap --enable-zip --with-curl --enable-fpm --with-fpm-user=nobody --with-fpm-group=nobody --enable-mbstring --enable-sockets --with-gd --with-openssl --with-mhash --enable-opcache --disable-fileinfo
以上的这些内容根据实际需要来组调整,更多参数可以通过./configure --help来查看
下面列出常用参数的具体意思:
configure –help说明
配置帮助表:
–help |
显示帮助信息 |
display this help and exit |
–version |
显示版本 |
display version information and exit |
–quiet, –silent |
不显示checking……信息 |
do not print`checking…’ messages |
–cache-file=FILE |
在指定文件中存储测试结果 |
cache test results in FILE [disabled] |
–no-create |
configure脚本运行结束后不输出结果文件,常用于正式编译前的测试。 |
do not create output files |
安装目录:
–srcdir=DIR |
源文件库所在目录 |
find the sources in DIR [configure dir or `..'] |
–prefix=PREFIX |
体系无关文件的顶级安装目录PREFIX ,也就PHP的安装目录 |
install architecture-independent files in PREFIX |
–exec-prefix=EPREFIX |
体系相关文件的顶级安装目录EPREFIX ,把体系相关的文件安装到不同的位置可以方便地在不同主机之间共享体系相关的文件 |
install architecture-dependent files in EPREFIX |
–bindir=DIR |
用户可执行目录DIR。用于存放PHP的支持程序 |
user executables [EPREFIX/bin] |
–sbindir=DIR |
系统管理员可执行目录DIR ,用于存放运行PHP服务器所必须的服务程序 |
system admin executables [EPREFIX/sbin] |
–libexecdir=DIR |
程序可执行目录DIR ,也就是动态加载模块目录 |
program executables [EPREFIX/libexec] |
–sysconfdir=DIR |
只读的单一机器数据目录DIR ,用于存放php.ini之类的服务器配置文件 |
read-only single-machine data [PREFIX/etc] |
–sharedstatedir=DIR |
可改写的体系无关数据目录DIR |
modifiable architecture-independent data [PREFIX/com] |
–localstatedir=DIR |
可改写的单一机器数据目录DIR |
modifiable single-machine data [PREFIX/var] |
–libdir=DIR |
对象代码库目录DIR |
object code libraries [EPREFIX/lib] |
–includedir=DIR |
PHP的C头文件目录DIR |
C header files [PREFIX/include] |
–oldincludedir=DIR |
非gcc的C头文件目录DIR |
C header files for non-gcc [/usr/include] |
–datadir=DIR |
PHP服务器只读的体系无关数据目录DIR |
read-only architecture-independent data [DATAROOTDIR] |
–infodir=DIR |
信息文档目录DIR |
info documentation [DATAROOTDIR/info] |
–localedir=DIR |
地区相关数据DIR |
locale-dependent data [DATAROOTDIR/locale] |
–mandir=DIR |
手册文档目录DIR |
man documentation [DATAROOTDIR/man] |
–program-prefix =PREFIX |
在安装的程序名前面加上前缀 |
prepend PREFIX to installed program names |
–program-suffix =SUFFIX |
在安装的程序名前面加上后缀 |
append SUFFIX to installed program names |
-program-transform-name =PROGRAM |
在运行的时候要运行sed程序脚本 |
run sed PROGRAM on installed program names |
交叉编译选项:
–build=BUILD |
指定编译工具所在系统的系统类型BUILD |
configure for building on BUILD [guessed] |
–host=HOST |
指定Apache HTTP服务器将要进行交叉编译时运行的目标系统类型HOST |
cross-compile to build programs to run on HOST [BUILD] |
–target=TARGET |
指定交叉编译所产生的目标代码类型 |
configure for building compilers for TARGET [HOST] |
特征选项:
–disable-FEATURE |
do not include FEATURE (same as –enable-FEATURE=no) |
关闭特征选项 |
–enable-FEATURE[=ARG] |
include FEATURE [ARG=yes] |
启用特征选项 |
–with-PACKAGE[=ARG] |
use PACKAGE [ARG=yes] |
使用封装 |
–without-PACKAGE |
do not use PACKAGE (same as –with-PACKAGE=no) |
禁用封装 |
–x-includes=DIR |
X include files are in DIR |
在目录中包含X头文件 |
–x-libraries=DIR |
X library files are in DIR |
在目录中包含X库文件 |
–with-libdir=NAME |
Look for libraries in …/NAME rather than …/lib |
库文件查找路径设置…/XXX/lib/ |
–disable-rpath |
Disable passing additional runtime library search paths |
禁用传递其他运行库搜索路径 |
SAPI modules(SAPI模块设置):
–with-aolserver=DIR |
Specify path to the installed AOLserver |
指定AOLserver网站服务器的安装路径 |
–with-apxs[=FILE] |
Build shared Apache 1.x module. FILE is the optional pathname to the Apache apxs tool [apxs] |
编译出共享的apache 1.x版本的共享模块所存放的路径 |
–with-apache[=DIR] |
Build Apache 1.x module. DIR is the top-level Apache build directory [/usr/local/apache] |
编译Apache1.x版本的模块,目录是apache的软件根目录。 |
–enable-mod-charset |
APACHE: Enable transfer tables for mod_charset (Rus Apache) |
为apache的mod_charset模块启用传输表模式。(俄文的apache使用) |
–with-apxs2filter[=FILE] |
EXPERIMENTAL: Build shared Apache 2.0 Filter module. FILE is the optional pathname to the Apache apxs tool [apxs] |
实验性:编译apache2.0的共享过滤模块。参数是apache apxs工具的路径文件 |
–with-apxs2[=FILE] |
Build shared Apache 2.0 Handler module. FILE is the optional pathname to the Apache apxs tool [apxs] |
编译共享的apache2.0处理程序的模块。参数是apache apxs工具的路径文件 |
–with-apache-hooks[=FILE] |
EXPERIMENTAL: Build shared Apache 1.x module. FILE is the optional pathname to the Apache apxs tool [apxs] |
实验性:编译共享的apache1.0的hooks模块。参数是apache apxs工具的路径文件 |
–with-apache-hooks-static[=DIR] |
EXPERIMENTAL: Build Apache 1.x module. DIR is the top-level Apache build directory [/usr/local/apache] |
实验性:编译apache1.0的hooks模块。参数是apache apxs工具的路径文件 |
–enable-mod-charset |
APACHE (hooks): Enable transfer tables for mod_charset (Rus Apache)apache(hooks) |
为apache的mod_charset模块启用传输表模式。 |
–with-caudium[=DIR] |
Build PHP as a Pike module for use with Caudium. DIR is the Caudium server dir [/usr/local/caudium/server] |
为Caudium服务器编译Pick模块。参数为Caudium软件的目录。 |
–d |