如何在 FreeBSD 11.2 上安装 PHP 5.3

如何在 FreeBSD 11.2 上安装 PHP 5.3

我有一个用 PHP 5.3 编写的旧应用程序,它不需要升级,并且无法与 php56 及更高版本配合使用。我想在 FreeBSD 11.2 机上安装带有大多数扩展的 PHP 5.3。然后我想创建可以在另一台机器上使用的包。

不幸的是 PHP 5.3 不再包含在 ports 中。我获得了包含 PHP 5.3 的旧版本 ports。编译该 port 时出现问题,出现许多错误,无法成功。

有人可以显示在 FreeBSD 11.2 中将 php 5.3 编译为端口的路径吗?

先感谢您。

答案1

您的帖子的评论概述了这样一个事实:这项任务不仅尝试起来很棘手,而且很难成功,而且即使您成功了,也可能不安全。

也就是说,规范的方法可能是下载 ports 树的 SVN 存储库,确定哪个 SVN 修订号删除了您寻求的 PHP 5.3 支持,然后将 SVN 树回滚到该修订号之前的修订号。然后,您将遇到所有必要的问题,例如确定源 tarball 是否仍可下载,FreeBSD 11.2 中存在的支持库和其他 API 是否与旧版 PHP 版本兼容,等等。

答案2

我无法从端口安装 PHP 5.3,即使我通过 svn 检出了旧端口版本。

我成功地从源代码编译了它,并在 nginx 的帮助下运行https://shami.blog/2018/02/running-older-php-versions-on-freebsd-11/

简而言之,需要使用 FPM 编译 PHP 5.3。并非所有编译选项都有效。对我来说,以下配置有效:

# pkg install -y gcc6 patch libxml2 curl jpeg png freetype2 mcrypt mariadb100-client libxslt postgresql96-client 
# mkdir -p /home/php53
# cd /home/php53
# fetch --no-verify-peer https://museum.php.net/php5/php-5.3.29.tar.gz
# tar xvzf php-5.3.29.tar.gz
# cd php-5.3.29

下列的https://bugs.php.net/bug.php?id=63983

edit file sapi/fpm/fpm/fpm_sockets.c
just replace 
1)info.tcpi_sacked => info.__tcpi_sacked
2)info.tcpi_unacked => info.__tcpi_unacked

# ./configure --with-layout=GNU --with-regex=php --with-zend-vm=CALL --enable-zend-multibyte --build=FreeBSD-amd64 --prefix=/usr/local/php53 --exec-prefix=/usr/local/php53 --with-config-file-scan-dir=/usr/local/php53/etc/php --enable-cgi --with-libxml-dir=/usr/local/include/libxml2/libxml/ --enable-ftp --with-xsl=/usr/local/include/libxslt/ --enable-mbstring --with-curl --disable-short-tags --disable-ipv6 --with-curl=/usr/local/include/curl/ --enable-ftp --with-zlib-dir --with-freetype-dir --with-gettext --enable-mbstring --with-xmlrpc --enable-soap --enable-zip --enable-calendar --with-gmp --with-openssl --enable-wddx --with-pgsql=/usr/local/include/pgsql/ --enable-fpm
# make 
# make install

然后是 nginx 和 php_fpm 的一些配置

然后在 /etc/rc.conf 中启用服务

php_fpm_enable="YES"
nginx_enable="YES"

瞧瞧

相关内容