标签 php5.3 下的文章

在 Debian 9 里安装 php5.3 fpm

Debian 9 仓库里默认的php版本是7.0,如果网站程序一定需要php5.3,那可以尝试编译安装php5.3。

测试机是阿里云公共镜像Debian 9 64位。

过程:

  1. 先安装好 nginx + php7-fpm + MariaDB
  2. apt install libfcgi-dev libfcgi0ldbl libjpeg62-turbo-dev libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng-dev libkrb5-dev libxml2-dev libxslt1-dev libltdl-dev libmariadbclient-dev-compat # 安装好相应的开发包,编译安装时要用到
  3. 因为Debian9里的OpenSSL版本相对较高,所以需要先安装低版本的:

    cd /tmp
    wget "https://www.openssl.org/source/old/1.0.1/openssl-1.0.1t.tar.gz"
    tar xzf openssl-1.0.1t.tar.gz 
    cd openssl-1.0.1t
    ./config shared --prefix=/opt/openssl
    make -j $(nproc) && make install
    ln -s /opt/openssl/lib /opt/openssl/lib/x86_64-linux-gnu
    wget -O /opt/openssl/ssl/cert.pem "http://curl.haxx.se/ca/cacert.pem"
  4. 做一些符号链接,让php5.3在编译安装时能找到

    ln -s /opt/openssl/lib/libcrypto.so.1.0.0 /usr/lib/x86_64-linux-gnu/
    ln -s /opt/openssl/lib/libssl.so.1.0.0 /usr/lib/x86_64-linux-gnu/
    ln -fs /opt/openssl /usr/local/ssl
    ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a
    cd /usr/include && ln -s x86_64-linux-gnu/curl
  5. 下载php5.3.29源码包,保存解压到 /usr/local/src/php5.3-build

    mkdir -p /opt/php-5.3
    mkdir /usr/local/src/php5.3-build
    cd /usr/local/src/php5.3-build
    wget -c http://php.net/get/php-5.3.29.tar.bz2/from/this/mirror -O php-5.3.29.tar.bz2
    tar jxf php-5.3.29.tar.bz2
    cd /usr/local/src/php5.3-build/php-5.3.29
  6. ./configure --prefix=/opt/php-5.3 --enable-mbstring --with-libxml-dir=/usr --enable-soap --with-curl --with-mcrypt --with-zlib --disable-rpath --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysql --with-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-openssl=/opt/openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm # 配置
    php5.3-6.png
  7. make && make install # 编译安装
    php5.3-8.png
  8. 复制默认的php.ini及fpm配置文件

    cp /usr/local/src/php5.3-build/php-5.3.29/php.ini-production /opt/php-5.3/lib/php.ini
    cp /opt/php-5.3/etc/php-fpm.conf.default /opt/php-5.3/etc/php-fpm.conf
  9. vi /lib/systemd/system/php-5.3-fpm.service # 配置php5.3-fpm服务

    [Unit]
    Description=The PHP 5.3 FastCGI Process Manager
    After=network.target
    
    [Service]
    Type=simple
    PIDFile=/opt/php-5.3/var/run/php-fpm.pid
    ExecStart=/opt/php-5.3/sbin/php-fpm --nodaemonize --fpm-config /opt/php-5.3/etc/php-fpm.conf
    ExecReload=/bin/kill -USR2 $MAINPID
    
    [Install]
    WantedBy=multi-user.target
  10. systemctl start php-5.3-fpm.service # 启动php5.3-fpm
    php5.3-9.png
  11. 在相应的站点配置内容中,将php交由 php5.3 处理
    php5.3-10.png
  12. phpinfo输出及phpmyadmin操作,基本正常
    php5.3-11.png

参考: