一、检查php是否已经安装,使用php -v,是否能够看到版本号,或者使用rpm -qa | grep php查看是否安装过。
二、依赖包安装
- Linux软件编译安装都需要依赖两个安装包 gcc gcc-c++ make 可使用yum在线安装
- # yum -y install gcc gcc-c++ make
- 大部分依赖包这里使用下载的源码进行编译安装,出错的则可以使用网络yum源在线安装,也可以图省事,全都yum在线安装
- 安装yasm
下载地址:http://www.tortall.net/projects/yasm/releases/http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
# cd yasm-1.3.0
# ./configure
# make&& make install
- 安装libmcrypt
下载地址:https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
# cd libmcrypt-2.5.8
# ./configure
# make&& make install
- 安装tiff
下载地址: http://download.osgeo.org/libtiff/tiff-4.0.9.tar.gz# cd tiff-4.0.9
#./configure --prefix=/usr/local/tiff --enable-shared
# make
# make install
- 安装libpng
下载地址:http://www.libpng.org/pub/png/libpng.htmlhttps://nchc.dl.sourceforge.net/project/libpng/libpng16/1.6.35/libpng-1.6.35.tar.gz
# cd libpng-1.6.35
#./configure --prefix=/usr/local/libpng --enable-shared
# make&& make install
- 安装freetype
下载地址:http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/
http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/freetype-2.7.1.tar.gz
# cd freetype-2.7.1
#./configure --prefix=/usr/local/freetype --enable-shared
# make&& make install
- 安装jpeg
下载地址:http://www.ijg.org/files/http://www.ijg.org/files/jpegsrc.v9a.tar.gz
# cd jpeg-9a
#./configure --prefix=/usr/local/jpeg --enable-shared
# make&& make install
- 安装libgd
下载地址:https://github.com/libgd/libgd/releaseshttps://github-production-release-asset-2e65be.s3.amazonaws.com/29669711/cb5172f2-8d93-11e7-9615-92822f694ebf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20181003%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20181003T090125Z&X-Amz-Expires=300&X-Amz-Signature=0d2408ac593ecefea66b1ed8435a5cb05ec0743c2bd1369c0c3b88faf8e9fa2d&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dlibgd-2.2.5.tar.gz&response-content-type=application%2Foctet-stream
# cd libgd-2.2.5
#./configure --prefix=/usr/local/libgd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-webp=/usr/local/libwebp/
# make&& make install
- 提示警告:unrecognized options: --enable-gd-native-ttf
php7.2是2017年11月底发布的版本,在编译安装时,提示unrecognized options: –with-mcrypt, –enable-gd-native-ttf ,表示php7.2不支持这两个选项,把上面两个编译选项删除就可以了。 - 补充,因为不同的操作系统环境,系统安装开发环境包的完整程度也不相同,由于博主的系统是最小安装(minimal installation),所以需补充yum在线安装一些开发包
- # yum -y install libXpm-devel libvpx t1lib libxslt-devel* libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel openssl openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel readline readline-devel libxslt-devel perl perl-devel psmisc.x86_64 recode recode-devel libtidy libtidy-devel
- # yum -y install php-mbstring (自行选择安装)
三、下载PHP安装包
- 首先打开php官网http://php.net/点击导航栏的Downloads进入下载页面:http://php.net/downloads.php,选择合适的版本并选择对应国家镜像进行下载wget http://php.net/get/php-7.2.10.tar.gz/from/a/mirror,我下载的是php-7.2.10.tar.gz
- tar -zxvf php-7.2.10.tar.gz
- cd php-7.2.10
- 创建用户useradd -s /sbin/nologin php-fpm
- 编译安装,实际上这里的配置项比上述还多,可以使用 ./configure --help 命令查看所有选项,以上这些选项在正常的php开发中完全够用了,后期如果需要,可以选择手动开启相应的模块
- 注意:编译的配置项是根据前面源码安装的依赖包的安装路径配置的路径,如果改为yum安装的依赖包,则无须写路每期
-
./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip
原文地址:https://www.cnblogs.com/Anwar/p/9744576.html