CentOS 編譯安裝php5.6

提前安裝準備

yum groupinstall "development tools"

安裝 libevent

wget?https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz

安裝libmcrypt

wget?ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

繼續安裝一些依賴軟件

yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses curl curl-devel openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c xmlrpc-c-devel?openssl openssl-devel?bzip2 bzip2-devel ?curl curl-devel

Config 配置

./configure ?--prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --enable-fpm ?--with-curl ?--with-openssl ?--enable-mbregex ?--with-mysql ?--with-mysqli ?--with-mysql-sock ?--enable-pdo ?--with-pdo-mysql ?--with-pdo-sqlite ?--enable-mysqlnd ?--with-gd ?--enable-gd-native-ttf ?--enable-exif ?--with-jpeg-dir=/usr/local/jpeg ?--with-png-dir=/usr/local/png ?--with-freetype-dir=/usr/local/freetype ?--enable-gd-jis-conv ?--with-gettext ?--with-zlib ?--enable-zip ?--with-bz2 ?--disable-fileinfo ?--enable-xmlreader ?--enable-xmlwriter ?--with-xmlrpc ?--enable-mbstring ?--enable-inline-optimization?--enable-sockets ?--with-mcrypt --with-mhash --enable-pcntl

make && make install

復制配置文件

cp php.ini-development /usr/local/php/lib/php.ini

修改時區

date.timezone =Asia/Shanghai

?另行編譯擴展

cd ext/sockets

/usr/local/php/bin/phpize

./configure --prefix=/usr/local/php/lib --with-php-config=/usr/local/php/bin/php-config --enable-sockets

make && make install

將PHP加入系統環境變量

vim /etc/profile

在文件結束位置添加?

export PATH=$PATH:/usr/local/php/bin/:/usr/local/php/sbin/

保存文件

最后執行命令 : source /etc/profile 重新加載環境

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容