brew维护着自己的一套软件仓库, 根据官方的说法, 对于多版本软件, 基本只维护最新稳定版本, 所以现在搜索的答案, 只要是通过brew本身命令进行安装老版本old version的, 直接就可以pass了, 本文就教大家如何通过brew安装老版本软件
一 brew安装原理
执行brew search, brew info, brew install时候 brew实际是从clone到本地的软件仓库找寻对应的安装文件的
brew本地软件仓库默认位置是在 /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula 这个文件夹, 执行brew install xxx@1.2.7等这种命令时候, 实际是从此仓库找寻文件名为xxx@1.2.7.rb的文件, 这是一个ruby文件, 下面以php@7.2.rb为例 看一下文件的具体内容和格式
class PhpAT72 < Formula
desc "General-purpose scripting language"
homepage "https://www.php.net/"
# Should only be updated if the new version is announced on the homepage, https://www.php.net/
url "https://www.php.net/distributions/php-7.2.29.tar.xz"
sha256 "b117de74136bf4b439d663be9cf0c8e06a260c1f340f6b75ccadb609153a7fe8"
bottle do
sha256 "1af2da199898a98788f89bcf0f83fce354bda950bec306504d294406dfec9129" => :catalina
sha256 "33c0b62d6d2fdcf8d0d7931901e28dc01a22b5742f21c680e1a9d4946ed2525d" => :mojave
sha256 "1d4b566b54212cf0257d14c9e228e3854a1946971b126ddaa0dc322c2c6d93ad" => :high_sierra
end
keg_only :versioned_formula
depends_on "httpd" => [:build, :test]
depends_on "pkg-config" => :build
depends_on "apr"
depends_on "apr-util"
depends_on "argon2"
depends_on "aspell"
depends_on "autoconf"
depends_on "curl-openssl"
depends_on "freetds"
depends_on "freetype"
depends_on "gettext"
depends_on "glib"
depends_on "gmp"
depends_on "icu4c"
depends_on "jpeg"
depends_on "libpng"
depends_on "libpq"
depends_on "libsodium"
depends_on "libzip"
depends_on "openldap"
depends_on "openssl@1.1"
depends_on "sqlite"
depends_on "tidy-html5"
depends_on "unixodbc"
depends_on "webp"
uses_from_macos "bzip2"
uses_from_macos "libxml2"
uses_from_macos "libxslt"
uses_from_macos "zlib"
# PHP build system incorrectly links system libraries
# see https://github.com/php/php-src/pull/3472
patch :DATA
def install
# Ensure that libxml2 will be detected correctly in older MacOS
ENV["SDKROOT"] = MacOS.sdk_path if MacOS.version == :el_capitan || MacOS.version == :sierra
# buildconf required due to system library linking bug patch
system "./buildconf", "--force"
inreplace "configure" do |s|
s.gsub! "APACHE_THREADED_MPM=`$APXS_HTTPD -V | grep 'threaded:.*yes'`",
"APACHE_THREADED_MPM="
s.gsub! "APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR`",
"APXS_LIBEXECDIR='$(INSTALL_ROOT)#{lib}/httpd/modules'"
s.gsub! "-z `$APXS -q SYSCONFDIR`",
"-z ''"
# apxs will interpolate the @ in the versioned prefix: https://bz.apache.org/bugzilla/show_bug.cgi?id=61944
s.gsub! "LIBEXECDIR='$APXS_LIBEXECDIR'",
"LIBEXECDIR='" + "#{lib}/httpd/modules".gsub("@", "\\@") + "'"
end
# Update error message in apache sapi to better explain the requirements
# of using Apache http in combination with php if the non-compatible MPM
# has been selected. Homebrew has chosen not to support being able to
# compile a thread safe version of PHP and therefore it is not
# possible to recompile as suggested in the original message
inreplace "sapi/apache2handler/sapi_apache2.c",
"You need to recompile PHP.",
"Homebrew PHP does not support a thread-safe php binary. "\
"To use the PHP apache sapi please change "\
"your httpd config to use the prefork MPM"
inreplace "sapi/fpm/php-fpm.conf.in", ";daemonize = yes", "daemonize = no"
# Required due to icu4c dependency
ENV.cxx11
config_path = etc/"php/#{php_version}"
# Prevent system pear config from inhibiting pear install
(config_path/"pear.conf").delete if (config_path/"pear.conf").exist?
# Prevent homebrew from harcoding path to sed shim in phpize script
ENV["lt_cv_path_SED"] = "sed"
# Each extension that is built on Mojave needs a direct reference to the
# sdk path or it won't find the headers
headers_path = "=#{MacOS.sdk_path_if_needed}/usr"
args = %W[
--prefix=#{prefix}
--localstatedir=#{var}
--sysconfdir=#{config_path}
--with-config-file-path=#{config_path}
--with-config-file-scan-dir=#{config_path}/conf.d
--with-pear=#{pkgshare}/pear
--enable-bcmath
--enable-calendar
--enable-dba
--enable-dtrace
--enable-exif
--enable-ftp
--enable-fpm
--enable-intl
--enable-mbregex
--enable-mbstring
--enable-mysqlnd
--enable-opcache-file
--enable-pcntl
--enable-phpdbg
--enable-phpdbg-readline
--enable-phpdbg-webhelper
--enable-shmop
--enable-soap
--enable-sockets
--enable-sysvmsg
--enable-sysvsem
--enable-sysvshm
--enable-wddx
--enable-zip
--with-apxs2=#{Formula["httpd"].opt_bin}/apxs
--with-bz2#{headers_path}
--with-curl=#{Formula["curl-openssl"].opt_prefix}
--with-fpm-user=_www
--with-fpm-group=_www
--with-freetype-dir=#{Formula["freetype"].opt_prefix}
--with-gd
--with-gettext=#{Formula["gettext"].opt_prefix}
--with-gmp=#{Formula["gmp"].opt_prefix}
--with-iconv#{headers_path}
--with-icu-dir=#{Formula["icu4c"].opt_prefix}
--with-jpeg-dir=#{Formula["jpeg"].opt_prefix}
--with-kerberos#{headers_path}
--with-layout=GNU
--with-ldap=#{Formula["openldap"].opt_prefix}
--with-ldap-sasl#{headers_path}
--with-libxml-dir#{headers_path}
--with-libedit#{headers_path}
--with-libzip
--with-mhash#{headers_path}
--with-mysql-sock=/tmp/mysql.sock
--with-mysqli=mysqlnd
--with-ndbm#{headers_path}
--with-openssl=#{Formula["openssl@1.1"].opt_prefix}
--with-password-argon2=#{Formula["argon2"].opt_prefix}
--with-pdo-dblib=#{Formula["freetds"].opt_prefix}
--with-pdo-mysql=mysqlnd
--with-pdo-odbc=unixODBC,#{Formula["unixodbc"].opt_prefix}
--with-pdo-pgsql=#{Formula["libpq"].opt_prefix}
--with-pdo-sqlite=#{Formula["sqlite"].opt_prefix}
--with-pgsql=#{Formula["libpq"].opt_prefix}
--with-pic
--with-png-dir=#{Formula["libpng"].opt_prefix}
--with-pspell=#{Formula["aspell"].opt_prefix}
--with-sodium=#{Formula["libsodium"].opt_prefix}
--with-sqlite3=#{Formula["sqlite"].opt_prefix}
--with-tidy=#{Formula["tidy-html5"].opt_prefix}
--with-unixODBC=#{Formula["unixodbc"].opt_prefix}
--with-webp-dir=#{Formula["webp"].opt_prefix}
--with-xmlrpc
--with-xsl#{headers_path}
--with-zlib#{headers_path}
]
system "./configure", *args
system "make"
system "make", "install"
# Allow pecl to install outside of Cellar
extension_dir = Utils.popen_read("#{bin}/php-config --extension-dir").chomp
orig_ext_dir = File.basename(extension_dir)
inreplace bin/"php-config", lib/"php", prefix/"pecl"
inreplace "php.ini-development", %r{; ?extension_dir = "\./"},
"extension_dir = \"#{HOMEBREW_PREFIX}/lib/php/pecl/#{orig_ext_dir}\""
# Use OpenSSL cert bundle
inreplace "php.ini-development", /; ?openssl\.cafile=/,
"openssl.cafile = \"#{etc}/openssl@1.1/cert.pem\""
inreplace "php.ini-development", /; ?openssl\.capath=/,
"openssl.capath = \"#{etc}/openssl@1.1/certs\""
config_files = {
"php.ini-development" => "php.ini",
"sapi/fpm/php-fpm.conf" => "php-fpm.conf",
"sapi/fpm/www.conf" => "php-fpm.d/www.conf",
}
config_files.each_value do |dst|
dst_default = config_path/"#{dst}.default"
rm dst_default if dst_default.exist?
end
config_path.install config_files
unless (var/"log/php-fpm.log").exist?
(var/"log").mkpath
touch var/"log/php-fpm.log"
end
end
def post_install
pear_prefix = pkgshare/"pear"
pear_files = %W[
#{pear_prefix}/.depdblock
#{pear_prefix}/.filemap
#{pear_prefix}/.depdb
#{pear_prefix}/.lock
]
%W[
#{pear_prefix}/.channels
#{pear_prefix}/.channels/.alias
].each do |f|
chmod 0755, f
pear_files.concat(Dir["#{f}/*"])
end
chmod 0644, pear_files
# Custom location for extensions installed via pecl
pecl_path = HOMEBREW_PREFIX/"lib/php/pecl"
ln_s pecl_path, prefix/"pecl" unless (prefix/"pecl").exist?
extension_dir = Utils.popen_read("#{bin}/php-config --extension-dir").chomp
php_basename = File.basename(extension_dir)
php_ext_dir = opt_prefix/"lib/php"/php_basename
# fix pear config to install outside cellar
pear_path = HOMEBREW_PREFIX/"share/pear@#{php_version}"
cp_r pkgshare/"pear/.", pear_path
{
"php_ini" => etc/"php/#{php_version}/php.ini",
"php_dir" => pear_path,
"doc_dir" => pear_path/"doc",
"ext_dir" => pecl_path/php_basename,
"bin_dir" => opt_bin,
"data_dir" => pear_path/"data",
"cfg_dir" => pear_path/"cfg",
"www_dir" => pear_path/"htdocs",
"man_dir" => HOMEBREW_PREFIX/"share/man",
"test_dir" => pear_path/"test",
"php_bin" => opt_bin/"php",
}.each do |key, value|
value.mkpath if /(?<!bin|man)_dir$/.match?(key)
system bin/"pear", "config-set", key, value, "system"
end
system bin/"pear", "update-channels"
%w[
opcache
].each do |e|
ext_config_path = etc/"php/#{php_version}/conf.d/ext-#{e}.ini"
extension_type = (e == "opcache") ? "zend_extension" : "extension"
if ext_config_path.exist?
inreplace ext_config_path,
/#{extension_type}=.*$/, "#{extension_type}=#{php_ext_dir}/#{e}.so"
else
ext_config_path.write <<~EOS
[#{e}]
#{extension_type}="#{php_ext_dir}/#{e}.so"
EOS
end
end
end
def caveats
<<~EOS
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module #{opt_lib}/httpd/modules/libphp7.so
<FilesMatch \\.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
#{etc}/php/#{php_version}/
EOS
end
def php_version
version.to_s.split(".")[0..1].join(".")
end
plist_options :manual => "php-fpm"
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_sbin}/php-fpm</string>
<string>--nodaemonize</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{var}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/php-fpm.log</string>
</dict>
</plist>
EOS
end
test do
assert_match /^Zend OPcache$/, shell_output("#{bin}/php -i"),
"Zend OPCache extension not loaded"
# Test related to libxml2 and
# https://github.com/Homebrew/homebrew-core/issues/28398
assert_includes MachO::Tools.dylibs("#{bin}/php"),
"#{Formula["libpq"].opt_lib}/libpq.5.dylib"
system "#{sbin}/php-fpm", "-t"
system "#{bin}/phpdbg", "-V"
system "#{bin}/php-cgi", "-m"
# Prevent SNMP extension to be added
assert_no_match /^snmp$/, shell_output("#{bin}/php -m"),
"SNMP extension doesn't work reliably with Homebrew on High Sierra"
begin
require "socket"
server = TCPServer.new(0)
port = server.addr[1]
server_fpm = TCPServer.new(0)
port_fpm = server_fpm.addr[1]
server.close
server_fpm.close
expected_output = /^Hello world!$/
(testpath/"index.php").write <<~EOS
<?php
echo 'Hello world!' . PHP_EOL;
var_dump(ldap_connect());
EOS
main_config = <<~EOS
Listen #{port}
ServerName localhost:#{port}
DocumentRoot "#{testpath}"
ErrorLog "#{testpath}/httpd-error.log"
ServerRoot "#{Formula["httpd"].opt_prefix}"
PidFile "#{testpath}/httpd.pid"
LoadModule authz_core_module lib/httpd/modules/mod_authz_core.so
LoadModule unixd_module lib/httpd/modules/mod_unixd.so
LoadModule dir_module lib/httpd/modules/mod_dir.so
DirectoryIndex index.php
EOS
(testpath/"httpd.conf").write <<~EOS
#{main_config}
LoadModule mpm_prefork_module lib/httpd/modules/mod_mpm_prefork.so
LoadModule php7_module #{lib}/httpd/modules/libphp7.so
<FilesMatch \\.(php|phar)$>
SetHandler application/x-httpd-php
</FilesMatch>
EOS
(testpath/"fpm.conf").write <<~EOS
[global]
daemonize=no
[www]
listen = 127.0.0.1:#{port_fpm}
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
EOS
(testpath/"httpd-fpm.conf").write <<~EOS
#{main_config}
LoadModule mpm_event_module lib/httpd/modules/mod_mpm_event.so
LoadModule proxy_module lib/httpd/modules/mod_proxy.so
LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
<FilesMatch \\.(php|phar)$>
SetHandler "proxy:fcgi://127.0.0.1:#{port_fpm}"
</FilesMatch>
EOS
pid = fork do
exec Formula["httpd"].opt_bin/"httpd", "-X", "-f", "#{testpath}/httpd.conf"
end
sleep 3
assert_match expected_output, shell_output("curl -s 127.0.0.1:#{port}")
Process.kill("TERM", pid)
Process.wait(pid)
fpm_pid = fork do
exec sbin/"php-fpm", "-y", "fpm.conf"
end
pid = fork do
exec Formula["httpd"].opt_bin/"httpd", "-X", "-f", "#{testpath}/httpd-fpm.conf"
end
sleep 3
assert_match expected_output, shell_output("curl -s 127.0.0.1:#{port}")
ensure
if pid
Process.kill("TERM", pid)
Process.wait(pid)
end
if fpm_pid
Process.kill("TERM", fpm_pid)
Process.wait(fpm_pid)
end
end
end
end
__END__
diff --git a/acinclude.m4 b/acinclude.m4
index 168c465f8d..6c087d152f 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -441,7 +441,11 @@ dnl
dnl Adds a path to linkpath/runpath (LDFLAGS)
dnl
AC_DEFUN([PHP_ADD_LIBPATH],[
- if test "$1" != "/usr/$PHP_LIBDIR" && test "$1" != "/usr/lib"; then
+ case "$1" in
+ "/usr/$PHP_LIBDIR"|"/usr/lib"[)] ;;
+ /Library/Developer/CommandLineTools/SDKs/*/usr/lib[)] ;;
+ /Applications/Xcode*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/*/usr/lib[)] ;;
+ *[)]
PHP_EXPAND_PATH($1, ai_p)
ifelse([$2],,[
_PHP_ADD_LIBPATH_GLOBAL([$ai_p])
@@ -452,8 +456,8 @@ AC_DEFUN([PHP_ADD_LIBPATH],[
else
_PHP_ADD_LIBPATH_GLOBAL([$ai_p])
fi
- ])
- fi
+ ]) ;;
+ esac
])
dnl
@@ -487,7 +491,11 @@ dnl add an include path.
dnl if before is 1, add in the beginning of INCLUDES.
dnl
AC_DEFUN([PHP_ADD_INCLUDE],[
- if test "$1" != "/usr/include"; then
+ case "$1" in
+ "/usr/include"[)] ;;
+ /Library/Developer/CommandLineTools/SDKs/*/usr/include[)] ;;
+ /Applications/Xcode*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/*/usr/include[)] ;;
+ *[)]
PHP_EXPAND_PATH($1, ai_p)
PHP_RUN_ONCE(INCLUDEPATH, $ai_p, [
if test "$2"; then
@@ -495,8 +503,8 @@ AC_DEFUN([PHP_ADD_INCLUDE],[
else
INCLUDES="$INCLUDES -I$ai_p"
fi
- ])
- fi
+ ]) ;;
+ esac
])
dnl internal, don't use
@@ -2411,7 +2419,8 @@ AC_DEFUN([PHP_SETUP_ICONV], [
fi
if test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.a ||
- test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME
+ test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME ||
+ test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.tbd
then
PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [
found_iconv=yes
可以看到文件定义了一个class, 类名为PhpAT72, 可以看到类名和文件名是有对应关系的, 文件名是php@7.2, 转换成类名就是PhpAT72
向下内容依次为:
desc //软件描述
homepage //软件主页
url //软件主下载路径
sha256 "186c6bfe6ecfba7a5b48c47f8a1673d0f3b0e5ba2e25602dd23b629975da3f35" //软件包sha256
//软件依赖 安装时候会先安装依赖软件 依赖软件可能会有自身的依赖 最终会把全部依赖先安装完
depends_on "httpd" => [:build, :test] //依赖httpd 实际就是依赖仓库里的httpd.rb
depends_on "apr-util" //依赖apr-util 实际就是依赖仓库里的apr-util.rb
......
// 安装文件补丁 实际就是安装前把安装文件先处理下以满足安装需求
patch :DATA
//安装方法 编译安装时会走这个方法 brew默认已经把软件构建好了 不走此方法 除非安装时候加上从软件源构建
def install
//安装前准备工作 设定一些环境变量等
........
// 安装configure配置 #{prefix}类似这些 都是路径
args = %W[
--prefix=#{prefix}
--localstatedir=#{var}
--sysconfdir=#{config_path}
--with-config-file-path=#{config_path}
--with-config-file-scan-dir=#{config_path}/conf.d
--with-pear=#{pkgshare}/pear
......
......
--with-unixODBC=#{Formula["unixodbc"].opt_prefix}
--with-webp-dir=#{Formula["webp"].opt_prefix}
--with-xmlrpc
--with-xsl#{headers_path}
--with-zlib#{headers_path}
]
// 执行编译安装
system "./configure", *args
system "make"
system "make", "install"
// 安装后的一些处理
......
......
end
// 安装完毕后的一些说明
def caveats
......
end
//写入系统服务 以服务运行时候使用
plist_options :manual => "php-fpm"
def plist
......
end
//安装完成后的测试 看是否安装成功
test do
......
end
end
// 安装文件补丁
__END__
......
二 安装老版本 old version软件
明白了上面的brew安装原理, 我们就可以自定义软件仓库版本了
主要是要设定
文件名和类名
url 下载链接
sha256 安装包sha256 这个必须设置正确
depends_on 软件依赖
configure 编译安装参数
以php@7.1.33.rb为例 以下是作者设定的自定义仓库
class PhpAT7133 < Formula
desc "General-purpose scripting language"
homepage "https://www.php.net/"
# Should only be updated if the new version is announced on the homepage, https://www.php.net/
url "http://mirrors.sohu.com/php/php-7.1.33.tar.xz"
sha256 "bd7c0a9bd5433289ee01fd440af3715309faf583f75832b64fe169c100d52968"
bottle do
sha256 "ddd14746138f0212dfd8d2c0944d573ce05c3ba900c2579440f7e8defa63b0c7" => :catalina
sha256 "fcc85c9f550df021a7f505d57c43e19672940c37ef7a1f909eec2d1d13202cef" => :mojave
sha256 "edfcefb109b356338ed324305f7317659df02bb5a8252b67a696180e75e81b1c" => :high_sierra
end
keg_only :versioned_formula
depends_on "pkg-config" => :build
depends_on "apr"
depends_on "apr-util"
depends_on "argon2"
depends_on "aspell"
depends_on "autoconf"
depends_on "freetds"
depends_on "freetype"
depends_on "gettext"
depends_on "glib"
depends_on "gmp"
depends_on "jpeg"
depends_on "libffi"
depends_on "libpng"
depends_on "libpq"
depends_on "libsodium"
depends_on "libzip"
depends_on "oniguruma"
depends_on "openldap"
depends_on "sqlite"
depends_on "tidy-html5"
depends_on "unixodbc"
depends_on "webp"
depends_on "zlib"
depends_on "libiconv"
depends_on "curl-openssl"
depends_on "openssl@1.1"
depends_on "icu4c"
patch :DATA
def install
if MacOS.version == :el_capitan || MacOS.version == :sierra
ENV["SDKROOT"] = MacOS.sdk_path
end
system "./buildconf", "--force"
ENV.cxx11
# Prevent homebrew from harcoding path to sed shim in phpize script
ENV["lt_cv_path_SED"] = "sed"
# Each extension that is built on Mojave needs a direct reference to the
# sdk path or it won't find the headers
headers_path = "=#{MacOS.sdk_path_if_needed}/usr"
args = %W[
--prefix=#{prefix}
--exec-prefix=#{prefix}
--localstatedir=#{prefix}/var
--sysconfdir=#{prefix}/conf
--with-config-file-path=#{prefix}/conf
--with-os-sdkpath=#{MacOS.sdk_path_if_needed}
--enable-bcmath
--enable-calendar
--enable-dba
--enable-dtrace
--enable-exif
--enable-ftp
--enable-cgi
--enable-fpm
--enable-gd
--enable-intl
--enable-mbregex
--enable-mbstring
--enable-mysqlnd
--enable-pcntl
--enable-phpdbg
--enable-phpdbg-webhelper
--enable-shmop
--enable-soap
--enable-sockets
--enable-sysvmsg
--enable-sysvsem
--enable-sysvshm
--with-bz2#{headers_path}
--with-ffi
--with-fpm-user=_www
--with-fpm-group=_www
--with-freetype
--with-gettext=#{Formula["gettext"].opt_prefix}
--with-gmp=#{Formula["gmp"].opt_prefix}
--with-iconv=#{Formula["libiconv"].opt_prefix}
--with-jpeg
--with-kerberos
--with-layout=GNU
--with-ldap=#{Formula["openldap"].opt_prefix}
--with-libxml
--with-libedit=#{Formula["libedit"].opt_prefix}
--with-mhash#{headers_path}
--with-mysql-sock=/tmp/mysql.sock
--with-mysqli=mysqlnd
--with-ndbm#{headers_path}
--with-curl=#{Formula["curl-openssl"].opt_prefix}
--with-password-argon2=#{Formula["argon2"].opt_prefix}
--with-pdo-dblib=#{Formula["freetds"].opt_prefix}
--with-pdo-mysql=mysqlnd
--with-pdo-odbc=unixODBC,#{Formula["unixodbc"].opt_prefix}
--with-pdo-pgsql=#{Formula["libpq"].opt_prefix}
--with-pdo-sqlite
--with-pgsql=#{Formula["libpq"].opt_prefix}
--with-pic
--with-pspell=#{Formula["aspell"].opt_prefix}
--with-sodium
--with-sqlite3
--with-tidy#{headers_path}
--with-unixODBC
--with-webp
--with-xmlrpc
--with-xsl
--with-zip
--with-zlib=#{Formula["zlib"].opt_prefix}
--with-icu-dir=#{Formula["icu4c"].opt_prefix}
--with-openssl=#{Formula["openssl@1.1"].opt_prefix}
]
libiconv_path = "#{Formula['libiconv'].opt_prefix}"
system "./configure", *args
system "make", "ZEND_EXTRA_LIBS='#{libiconv_path}/lib/libiconv.2.dylib'"
ENV["MAKEFLAGS"] = "-j1"
system "make", "install"
phpsbin = Pathname.new("#{prefix}/sbin")
if (phpsbin/"php-fpm.dSYM").exist? && !(phpsbin/"php-fpm").exist?
FileUtils.ln_s phpsbin/"php-fpm.dSYM", phpsbin/"php-fpm"
end
end
def caveats
<<~EOS
install success !!!!!!
EOS
Homebrew.failed = false
end
end
然后把自己的自定义库文件php@7.1.33.rb 复制到brew软件仓库中 默认路径是/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
下来可以使用 brew search php 看是否检测到我们新加的文件
==> Formulae
brew-php-switcher php-code-sniffer php@7.1.33 ✔ php@7.3 phpmd phpstan
php php-cs-fixer php@7.2 phplint phpmyadmin phpunit
==> Casks
eclipse-php netbeans-php phpstorm
安装: brew install php@7.1.33 就可以了
以上就是brew安装老版本old version软件的方法 brew安装最大的好处就是替我们处理了很多的软件依赖 不需要自己一个一个去处理 安装老版本可以在已有仓库的基础上修改下 一般依赖都以及处理过了
网友评论