mac ox 10.11 brew安裝Nginx+PHP+MySQL+擴充套件
阿新 • • 發佈:2019-02-07
安裝brew
要求:OS X 10.6以上系統,並且安裝有XCode命令列工具
對於10.11的系統需要設定下local的許可權為當前使用者
$ sudo chown -R $(whoami):admin /usr/local
brew安裝程式的過程中需要用到蘋果的xcode中的 編譯器,你可以到蘋果的官網中免費下載安裝(需要註冊免費的開發者,然後才能下載),安裝後到屬性(Xcode – Perference–Downloads–Components–Command Line Tools)點選下載就可以了,這裡使用命令安裝
xcode-select --install
進入到 /usr/local 然後執行程式碼安裝brew
$ cd /usr/local
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
上面的安裝只是將Homebrew解壓到本地,還需要配置環境變數才能使用brew命令
$ touch ~/.bash_profile
$ open ~/.bash_profile
$ export PATH=/usr/local/bin:$PATH
$ source ~/.bash_profile
檢查下brew的安裝情況 我的是沒問題的 然後執行update 更新軟體
$ brew doctor
$ brew update
brew常用命令
brew –help 檢視brew的幫助
brew install git 安裝軟體
brew uninstall git 解除安裝軟體
brew search git 搜尋軟體
brew list 顯示已經安裝軟體列表
brew update 更新軟體,把所有的Formula目錄更新,並且會對本機已經安裝並有更新的軟體用*標明。
brew upgrade git 更新某具體軟體
brew [info | home] [FORMULA...] 檢視軟體資訊
刪除程式,和upgrade一樣,單個軟體刪除和所有程式老版刪除。
brew cleanup git
brew cleanup
brew outdated 檢視那些已安裝的程式需要更新
brew home *—用瀏覽器開啟
brew deps * — 顯示包依賴
brew server * —啟動web伺服器,可以通過瀏覽器訪問http://localhost:4567 / 來同網頁來管理包
brew -h brew —幫助
安裝Nginx
$ brew search nginx
$ brew install nginx
安裝成功後的一些配置資訊
Docroot is: /usr/local/var/www
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in /usr/local/etc/nginx/servers/.
To have launchd start nginx at login:
mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents
Then to load nginx now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
Or, if you don't want/need launchctl, you can just run:
nginx
根據提示設定開機啟動
$ mkdir -p ~/Library/LaunchAgents
$ ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents
現在就啟動nginx的方式有兩種
Then to load nginx now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
Or, if you don't want/need launchctl, you can just run:
nginx
安裝php
查詢php
$ brew search php56
檢視可以使用的選項
$ brew options homebrew/php/php56
--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-apxs
Build against apxs in Homebrew prefix
--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-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 (PHP 5.4 and above)
--with-postgresql
Build with postgresql support
--with-thread-safety
Build with thread safety
--without-apache
Disable building of shared Apache 2.0 Handler module
--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
--HEAD
Install HEAD version
安裝
brew install homebrew/php/php56 --without-snmp --without-apache --without-debug --with-fpm --without-intl --with-homebrew-libxslt --with-homebrew-openssl --with-imap --with-mysql --with-tidy
路徑
/usr/local/php/sbin/php-fpm
/usr/local/php/etc/php-fpm.conf
/usr/local/php/etc/php.ini
新增環境變數
PATH="/usr/local/sbin:$PATH"
設定開機啟動
mkdir -p ~/Library/LaunchAgents
cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
nginx 新增對php的支援
location / {
root html;
//index index.html index.htm; //改為⬇️
index index.php index.html index.htm;
}
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
去掉註釋
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 改成
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
php擴充套件
使用brew search php56-命令,可以檢視還有哪些擴充套件可以安裝,然後執行brew install php55-XXX就可以了。
安裝memcache
brew search php55-
brew install homebrew/php/php55-memcache
brew tap josegonzalez/homebrew-php
brew untap homebrew/php
install josegonzalez/php/php56-memcached
To have launchd start memcached at login:
ln -sfv /usr/local/opt/memcached/*.plist ~/Library/LaunchAgents
Then to load memcached now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
Or, if you don't want/need launchctl, you can just run:
/usr/local/opt/memcached/bin/memcached
重啟php 和nginx
安裝mysql
brew install mysql
安裝完會提示執行mysql_secure_installation
請參考