前言:编译参数
./configure --prefix=/usr/local/etc/php74 --with-config-file-path=/usr/local/etc/php74/etc --with-fpm-user=www --with-fpm-group=www --enable-fpm --with-bz2 --enable-gd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-zlib-dir --with-iconv-dir=/usr/local --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-curl --enable-dba --enable-bcmath --enable-calendar --with-gettext --with-pdo-mysql=mysqlnd --with-ldap --with-openssl --with-pear --with-xmlrpc --with-libdir=lib64 --with-libxml-dir --with-pcre-regex --with-pear --with-xsl --with-zlib --with-mhash --enable-libxml --enable-inline-optimization --enable-mbregex --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --with-zip
编译安装的时候报错:
No package 'openssl' found
1.检查是否安装openssl:
brew info openssl
#输出
openssl@1.1: stable 1.1.1d (bottled) [keg-only]
没安装的话运行安装命令:
brew install openssl@1.1
2.如果已经安装还是报错
编辑文件:
vi ~/.bash_profile
在文件末尾追加:
# pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
# openssl 个人本地的路径可能不同,以实际为准
export OPENSSL_LIBS="/usr/local/Cellar/openssl@1.1/1.1.1d/lib"
export OPENSSL_CFLAGS="/usr/local/Cellar/openssl@1.1/1.1.1d/include"
:wq
保存!
重新加载环境变量:
source ~/.bash_profile
查看 openssl 是否在 pkgconfig 中:
#运行命令:
pkg-config --list-all | grep openssl
#输出:
libevent_openssl libevent_openssl - libevent_openssl adds openssl-based TLS support to libevent
#没有 openssl 包说明没有成功注册openssl,需要手动建立
#openssl 个人本地的路径可能不同,以实际为准
#进入openssl的pkgconfig目录
cd /usr/local/Cellar/openssl@1.1/1.1.1d/lib/pkgconfig
#目录下有个openssl.pc的文件
#建立软链接
ln -s `pwd`/openssl.pc /usr/local/lib/pkgconfig
#重新运行命令查看
pkg-config --list-all | grep openssl
#输出:
openssl OpenSSL - Secure Sockets Layer and cryptography libraries and tools
libevent_openssl libevent_openssl - libevent_openssl adds openssl-based TLS support to libevent
成功!