1.基础依赖包
yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel -y
yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y
2 安装模块
2.1 libiconv
mkdir -p /home/wcp/tools
cd /home/wcp/tools
#wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install
cd ../
2.2 安装libzip
wget https://nih.at/libzip/libzip-1.5.2.tar.gz
tar xf libzip-1.5.2.tar.gz
cd libzip-1.5.2
mkdir build
cd build
cmake ..
make
make install
#升级cmake
wget https://cmake.org/files/v3.9/cmake-3.9.2.tar.gz
tar xf cmake-3.9.2.tar.gz
cd cmake-3.9.2
./configure
make
make install
3.php 相关扩展库的epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
wget http://cn2.php.net/distributions/php-5.6.38.tar.gz
wget http://cn2.php.net/distributions/php-7.3.8.tar.gz
4.安装依赖进入目录
yum -y install libmcrypt-devel mhash mcrypt
rpm -qa libmcrypt-devel mhash mcrypt
cd /home/oldboy/tools/
tar xf php-5.6.28.tar.gz
cd php-5.6.28
5.指定安装
./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc --with-fpm-user=www --with-fpm-group=www --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-pgsql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --with-ldap=shared --with-gdbm --with-pear --with-gettext --with-curl --with-xmlrpc --with-openssl --with-mhash --with-gd --enable-fpm --enable-mysqlnd --enable-mysqlnd-compression-support --enable-xml --enable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-intl --enable-ftp --enable-gd-jis-conv --enable-pcntl --enable-sockets --enable-zip --enable-soap --enable-fileinfo --enable-opcache --enable-maintainer-zts
5.1 编译
make && make install
6. 安装报错:
configure: error: mcrypt.h not found. Please reinstall libmcrypt
解决方法:
yum install -y epel-release
yum install -y libmcrypt-devel
两个不能一起安装,因为CentOs6默认的yum源没有 libmcrypt-devel这个包,只能借助epel的yum源,所以先安装epel,再安装
libmcrypt
6.1 报错:
./stdio.h:1010:2: error: invalid preprocessing directive #_GL_WARN_ON_USE
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
make[2]: *** [progname.o] Error 1font
make[2]: Leaving directory `/home/chen/tools/libiconv-1.14/srclib'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/chen/tools/libiconv-1.14/srclib'
make: *** [all] Error 2
解决:
编辑/home/chen/tools/libiconv-1.14/srclib下的stdio.in.h,找到如下代码:
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
改为如下代码:
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16) _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif
#endif
6.2
报错信息
configure: error: DBA: Could not find necessary header file(s).
解决
yum install gdbm-devel
6.3
报错信息
configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
解决
yum install libicu-devel
6.4
报错信息
configure: error: Cannot find ldap.h
解决:
yum install openldap openldap-devel -y
6.5
报错信息
configure: error: Cannot find ldap libraries in /usr/lib.
解决:
cp -frp /usr/lib64/libldap* /usr/lib/
6.6
error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
解决:
yum -y install postgresql-devel
6.7
报错信息
configure: error: off_t undefined; check your library configuration
解决:
vim /etc/ld.so.conf
#添加如下几行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
#保存退出
:wq
ldconfig -v # 使之生效
6.8
报错信
解决
7.1防错
ln -s /user/mysql/lib/libmysqlclient.so.18 /usr/lib64/
touch ext/phar/phar.phar
make
make install
7.2 创建软连接
ln -s /application/php-5.6.28/ /application/php
7.3配置php解析文件
cd /home/tools/php-7.3.8
cp php.ini-production /usr/local/php/etc/php.ini
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
cd php-fpm.d
cp www.conf.default www.conf
7.4 启动php-fpm
/usr/local/php/sbin/php-fpm
lsof -i :9000
ps -ef|grep php-fpm
ls -lrt /usr/lib64/
编译信息详解
./configure \
--prefix=/application/php-5.6.28 \ #指定安装位置
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \ #打开对freetype字体库的支持
--with-jpeg-dir \ #打开jpeg 图片支持
--with-png-dir \ #打开png 图片支持
--with-zlib \ #打开zlib库的支持,用于http压缩传输
--with-libxml-dir=/usr \ #打开libxml2库的支持
--enable-xml \ #
--disable-rpath \ #关闭额外的运行库文件
--enable-bcmath \ #打开图片大小调整,用到zabbix监控的时候用到了这个模块
--enable-shmop \ #
--enable-sysvsem \ #可以让php处理相关的ipc函数
--enable-inline-optimization \ # 优化线程
--with-curl \ #打开curl浏览工具的支持
--enable-mbregex \ #
--enable-fpm \ #打开php-fpm补丁后才有这个参数,CGI方式安装启动程序
--enable-mbstring \ #多字节多字符的支持
--with-mcrypt \ #mcrypt算法扩展
--with-gd \ #打开gd库的支持
--enable-gd-native-ttf \ #支持TrueType字符串函数库
--with-openssl \ #openssl的支持,加密传输https时用到的
--with-mhash \ #mhash算法扩展
--enable-pcntl \ #freeTDS需要用到的,可能是链接mssql 才用到
--enable-sockets \ #打开 sockets 支持
--with-xmlrpc \ #打开xml-rpc的c语言
--enable-soap \ #
--enable-short-tags \ #
--enable-static \ #
--with-xsl \ #打开XSLT 文件支持,扩展了libXML2库 ,需要libxslt软件
--with-fpm-user=www \ #
--with-fpm-group=www \ #
--enable-ftp \ #打开ftp的支持
--enable-opcache=no #
8.添加模块
8.1 imagick
wget http://pecl.php.net/get/imagick-3.4.3.tgz
tar xf imagick-3.4.3
cd imagick-3.4.3
yum install ImageMagick-devel
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
8.2 readline
yum install -y readline-devel
cd /home/tools/php-7.3.8/ext/openssl
cp ./config0.m4 ./config.m4
cd /home/tools/php-7.3.8/ext/readline
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
8.3 redis
wget https://github.com/phpredis/phpredis/archive/4.3.0.tar.gz
tar xf 4.3.0.tar.gz
cd phpredis-4.3.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
8.4 sodium
yum -y groupinstall "Development Tools"
wget https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz
tar xf libsodium-1.0.11.tar.gz && cd libsodium-1.0.11
./configure && make -j2 && make install
echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig
cd /home/tools/php-7.3.8/ext/sodium
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
8.5 Zend OPcache
cd /home/tools/php-7.3.8/ext/opcache
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
8.6 配置php.ini文件
vim /usr/local/php/etc/php.ini
extension=/usr/local/php/lib/php/extensions/no-debug-zts-20180731/readline.so
extension=/usr/local/php/lib/php/extensions/no-debug-zts-20180731/pdo_pgsql.so
extension=/usr/local/php/lib/php/extensions/no-debug-zts-20180731/sodium.so
extension=/usr/local/php/lib/php/extensions/no-debug-zts-20180731/imagick.so
extension=/usr/local/php/lib/php/extensions/no-debug-zts-20180731/redis.so
zend_extension=/usr/local/php/lib/php/extensions/no-debug-zts-20180731/opcache.so