建立文件夹存储源码文件

mkdir /usr/local/script
cd /usr/local/scirpt 

下载php源文件

wget http://101.96.10.64/cn2.php.net/distributions/php-5.6.37.tar.gz 

安装相关依赖包

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel curl curl-devel gd gd-devel vpx vpx-devel gmp gmp-devel libc-client-devel libc-client-devel.x86_64 mysql libxslt libxslt-devel openldap openldap-devel pam pam-devel libmcrypt-devel libc-client-devel  libjpeg-devel
cp -frp /usr/lib64/libldap* /usr/lib/ 

在centos7的环境中 有2个依赖包需源码安装

wget https://fossies.org/linux/misc/old/imap-2007f.tar.gz
tar zxf imap-2007f.tar.gz
cd imap-2007f/
make lr5 PASSWDTYPE=std SSLTYPE=unix.nopwd EXTRACFLAGS=-fPIC IP=4
mkdir -p /usr/local/imap-2007f/{include,lib}
cp c-client/*.h /usr/local/imap-2007f/include/
cp c-client/*.c /usr/local/imap-2007f/lib/
cp c-client/c-client.a /usr/local/imap-2007f/lib/libc-client.a

解压文件

tar zxf php-5.6.37.tar.gz 
cd php-5.6.37

## 编译文件
./configure --prefix=/usr/local/php --with-bz2  --with-mysql --enable-calendar  config=/usr/local/php/bin/php-config --enable-mbstring --enable-embedded-mysqli=shared --enable-pdo --with-pdo-mysql --with-pdo_sqlite  --with-mysqli=/usr/lib64/mysql/mysql_config --with-config-file-path=/etc  --enable-fpm   --enable-sockets --with-gd --with-jpeg-dir --with-openssl --with-freetype-dir --enable-gd-native-ttf --enable-simplexml --enable-bcmath --with-gettext -with-pdo-mysql  --enable-xml --enable-zip --with-zlib --enable-session  --enable-tokenizer --enable-ctype  --enable-ftp --with-gmp --enable-hash --with-iconv  --with-imap --enable-json --with-ldap  --with-kerberos --with-imap-ssl  --enable-dom  --enable-exif --enable-fileinfo --enable-filter  --enable-phar  --enable-wddx  --enable-pcntl --enable-soap  --with-sqlite3  --enable-xmlreader --enable-xmlwriter --with-xsl --with-libxml-dir=/usr/include/libxml2 --with-apxs2=/usr/sbin/apxs --with-curl=/usr/local/curl/ --with-mcrypt --with-mhash
#编译文件后,需要手动编辑Makefile,在 EXTRA_LIBS 后面加 -llber 
 
## 安装
make && make install 

配置PHP

cd /usr/local/php/etc
cp php-fpm.conf.default  php-fpm.conf
sed -i "s/user = nobody/user = www/g" /usr/local/php/etc/php-fpm.conf
sed -i "s/group = nobody/group = www/g" /usr/local/php/etc/php-fpm.conf

cp /usr/local/script/php-5.6.37/php.ini-production  /etc/php.ini
cp /usr/local/script/php-5.6.37/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm 

/etc/init.d/php-fpm start
暂无评论