swoole?mac編譯錯誤怎么辦?mac 安裝 swoole 可能會出現的錯誤
請先看完之后再操作
一、用pecl安裝swoole(沒有安裝起來)
2018年4月,由于homebrew的變動,導致無法使用brew install的方式安裝php的擴展,現在改為用pecl安裝,pecl安裝swoole的方法為:
pecl?install?swoole
出現在選項要填yes還是no
可能出現的報錯及解決方法
1 fatal Error: ‘openssl/ssl.h‘ file not found
解決方法1:cp -R /usr/local/opt/openssl/include/openssl /usr/local/include
解決方法2:ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/openssl
原因:一般用brew安裝的軟件,都會把需要include的文件自動放到/usr/local/include里的,但是不知為什么安裝openssl的時候沒有放到那里,所以要自己拷過去,其實最好的方法是做一個鏈接,即用解決方法2!
2 error: Cannot find libpq-fe.h. Please confirm the libpq or specify correct postgresql(libpq) installation path
解決方法 brew reinstall PostgreSQL
原因:可能是沒有安裝PostgreSQL
3 fatal error: ‘hiredis/hiredis.h‘ file not found
出現這個原因絕大多數是因為沒有安裝hiredis,用brew search hiredis看看有沒安裝,沒有安裝直接用brew install hiredis安裝后,再次pecl install swoole就可以
細心的童鞋會發現,brew install hiredis后,/usr/local/include里,多了一個hiredis,而且這個是一個軟鏈,鏈接到/usr/local/Cellar/hiredis/0.13.3/include/hiredis
結果還是報錯,沒有搞定,能力有限.
二、換了個方式 安裝swoole(完美解決)
2.1 下載swoole
sudo?pecl?download?swoole
2.2 編譯安裝
tar?zxvf?swoole-4.2.12.tgz????//?注意自己下載的版本,可能不一定 cd?swoole-4.2.12 phpize ./configure?--enable-openssl?--enable-http2?--enable-sockets?--enable-mysqlnd?-with-openssl-dir=/usr/local/Cellar/openssl/1.0.2s/ make?clean?&&?make?&&?sudo?make?install
2.3 遇到報錯
mkdir:?/usr/local/Cellar/php@7.1/7.1.30/pecl:?File?exists mkdir:?/usr/local/Cellar/php@7.1/7.1.30/pecl:?No?such?file?or?directory make:?***?[install-modules]?Error?1 //?大致意思就是?pecl??文件夾存在,但是打不開 //?我的pecl是軟連接過來的?不知道為什么打不開
2.4 解決方法
修改 /usr/local/Cellar/php@7.1/7.1.30/bin/php-config?
extension_dir=‘/usr/local/Cellar/php@7.1/7.1.30/pecl/20160303‘?中的?『pecl』?換成?『lib/php』 extension_dir=‘/usr/local/Cellar/php@7.1/7.1.30/lib/php/20160303‘
2.5 重新編譯
./configure?--enable-openssl?--enable-http2?--enable-sockets?--enable-mysqlnd?-with-openssl-dir=/usr/local/Cellar/openssl/1.0.2s/ make?clean?&&?make?&&?sudo?make?install
2.6 添加 swoole.so
修改php.ini 在文件末尾 加一行
extension?=?"/usr/local/Cellar/php@7.1/7.1.30/lib/php/20160303/swoole.so"
mac安裝swoole 真是疼