Linux 下编译安装低版本 PHP5

Ubuntu 在编译安装低版本 PHP5 时可能发生的错误

  • checking for cURL in default path… not found
ln -s /usr/include/x86_64-linux-gnu/curl /usr/local/include/curl
  • make: *** [Makefile:636:ext/openssl/openssl.lo]
# 当前系统 openssl 版本不兼容 php5,需要降级 openssl 版本
# 进入下载目录
cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.0.2k.tar.gz
# 解压
tar zxvf openssl-1.0.2k.tar.gz
# 编译
./config
make && make install 
# 配置
which ssl 	# 显示 /usr/bin/openssl
mv /usr/bin/openssl /usr/local/bin/openssl_bak
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl

开始编译 PHP5(只列出关键步骤,详情看 https://blog.csdn.net/hualaoshuan/article/details/90708525

# 部分依赖安装
# Ubuntu
apt-get libtool libdbd-mysql

# 安装到 /usr/local/php5 目录
# 注意 --with-openssl 配置
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc \
--with-mysqli --with-pdo-mysql \
--with-mysql-sock=/tmp/mysql.sock --enable-sockets --enable-zip \
--with-fpm-user=www --with-fpm-group=www --enable-fpm --enable-gd-native-ttf \
--with-jpeg-dir --with-freetype-dir --with-gd --with-mcrypt --with-curl --with-openssl=/usr/local/ssl \
--with-xmlrpc --enable-bcmath --enable-shmop --enable-sysvsem --enable-soap \
--enable-inline-optimization --enable-mbregex --enable-mbstring --enable-pcntl \
--enable-gd-jis-conv --enable-ftp --with-zlib --with-mhash 
make
make install

# 配置文件
cp php.ini-production /usr/local/php5/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php5-fpm
cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf
chmod +x /etc/init.d/php5-fpm

# 如果本机安装过 PHP7,需要关闭 PHP7 后再运行 PHP5
/etc/init.d/php-fpm stop
systemctl restart nginx
/etc/init.d/php5-fpm restart
发布了119 篇原创文章 · 获赞 12 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/hualaoshuan/article/details/103271688