Mac中如何安裝PHP7尿孔,為什么brew?安裝php7為什么找不到.so文件呢,安裝php7后丟失libphp7.so了嗎 君丁。那安裝brew install php72時怎么配置參數(shù)呢
常見問題 找不到libphp7.so
首先系統(tǒng)中brew 1.4.0版本
?? apache2 git:(stable) ?brew -v
Homebrew 1.4.0
Homebrew/homebrew-core (git revision 7990; last commit 2017-12-14)
?? apache2 git:(stable) ?
查看php72有哪些options選項可以安裝枫夺,那其中--with-httpd看到?jīng)],這個就是libphp7.so文件的關(guān)鍵參數(shù)绘闷,其他參數(shù)根據(jù)需要自行選擇筷屡。
?? apache2 git:(stable) ?brew options php72
--with-cgi
Enable building of the CGI executable (implies --without-fpm)
--with-debug
Compile with debugging symbols
--with-enchant
Build with enchant support
--with-gmp
Build with gmp support
--with-homebrew-curl
Include Curl support via Homebrew
--with-homebrew-libressl
Include LibreSSL instead of OpenSSL via Homebrew
--with-homebrew-libxml2
Include Libxml2 support via Homebrew
--with-homebrew-libxslt
Include LibXSLT support via Homebrew
--with-httpd
Enable building of shared Apache Handler module
--with-imap
Include IMAP extension
--with-libmysql
Include (old-style) libmysql support instead of mysqlnd
--with-mssql
Include MSSQL-DB support
--with-pdo-oci
Include Oracle databases (requries ORACLE_HOME be set)
--with-pear
Build with PEAR
--with-phpdbg
Enable building of the phpdbg SAPI executable
--with-postgresql
Build with postgresql support
--with-thread-safety
Build with thread safety
--with-webp
Build with webp support
--without-bz2
Build without bz2 support
--without-fpm
Disable building of the fpm SAPI executable
--without-ldap
Build without LDAP support
--without-legacy-mysql
Do not include the deprecated mysql_ functions
--without-mysql
Remove MySQL/MariaDB support
--without-pcntl
Build without Process Control support
--without-unixodbc
Build without unixODBC support
--HEAD
Install HEAD version
那這里根據(jù)開發(fā)需要我選擇了自己需要的參數(shù),命令如下簸喂,要先解綁之前的PHP版本毙死,如下執(zhí)行過程:
?? apache2 git:(stable) ??brew install php72? --with-httpd --with-debug? --with-imap --with-mssql --with-pear --with-postgresql? --with-webp
==> Installing php72 from homebrew/php
Error: Cannot install homebrew/php/php72 because conflicting formulae are installed.
php71: because different php versions install the same binaries.
Please `brew unlink php71` before continuing.
Unlinking removes a formula's symlinks from /usr/local. You can
link the formula again after the install finishes. You can --force this
install, but the build may fail or cause obscure side-effects in the
resulting software.
?? apache2 git:(stable) ??brew unlink php71
Unlinking /usr/local/Cellar/php71/7.1.12_23... 39 symlinks removed
?? apache2 git:(stable) ? brew install php72? --with-httpd --with-debug? --with-imap --with-mssql --with-pear --with-postgresql? --with-webp
Updating Homebrew...
==> Installing php72 from homebrew/php
==> Installing dependencies for homebrew/php/php72: libsodium
==> Installing homebrew/php/php72 dependency: libsodium
==> Downloading https://homebrew.bintray.com/bottles/libsodium-1.0.16.sierra.bottle.tar.gz
############################################################ 100.0%
==> Pouring libsodium-1.0.16.sierra.bottle.tar.gz
??? /usr/local/Cellar/libsodium/1.0.16: 71 files, 945.3KB
==> Installing homebrew/php/php72 --with-webp --with-postgresql --with-httpd --with-debug --with-imap --with-mssql --with-pear
==> Downloading https://php.net/get/php-7.2.0.tar.bz2/from/this/mirror
==> Downloading from https://secure.php.net/get/php-7.2.0.tar.bz2/from/this/mirror
########################################################### 100.0%
==> ./configure --prefix=/usr/local/Cellar/php72/7.2.0_11 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/7.2 --with-config-file-path=
==> make
==> make install
==> /usr/local/Cellar/php72/7.2.0_11/bin/pear config-set php_ini /usr/local/etc/php/7.2/php.ini system
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/php72/libexec/apache2/libphp7.so
SetHandler application/x-httpd-php
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini file can be found in:
/usr/local/etc/php/7.2/php.ini
???? PEAR ????
If PEAR complains about permissions, 'fix' the default PEAR permissions and config:
chmod -R ug+w /usr/local/opt/php72/lib/php
pear config-set php_ini /usr/local/etc/php/7.2/php.ini system
???? Extensions ????
If you are having issues with custom extension compiling, ensure that you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:
PATH="/usr/local/bin:$PATH"
PHP72 Extensions will always be compiled against this PHP. Please install them using --without-homebrew-php to enable compiling against system PHP.
???? PHP CLI ????
If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent configuration file:
export PATH="$(brew --prefix homebrew/php/php72)/bin:$PATH"
???? FPM ????
To launch php-fpm on startup:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/opt/php72/homebrew.mxcl.php72.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php72.plist
The control script is located at /usr/local/opt/php72/sbin/php72-fpm
OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:
PATH="/usr/local/sbin:$PATH"
You may also need to edit the plist to use the correct "UserName".
Please note that the plist was called 'homebrew-php.josegonzalez.php72.plist' in old versions of this formula.
With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system you have to install php with the --with-httpd option. See? brew options php72 for more details.
To have launchd start homebrew/php/php72 now and restart at login:
brew services start homebrew/php/php72
==> Summary
??? /usr/local/Cellar/php72/7.2.0_11: 508 files, 69.4MB, built in 10 minutes 20 seconds
到此安裝步驟完成,libphp7.so在目錄/usr/local/Cellar/php72/7.2.0_11/libexec/apache2/libphp7.so下喻鳄,具體使用請在apache配置文件httpd.conf中引入切換扼倘。
另外之前有版本的參數(shù)是--with--apache,舊版本在這里不予贅述除呵。 希望本文可以幫助到你再菊,歡迎指正和提問。
作者博客:開發(fā)者說PHPersay