Nginx
安裝
# Search
$ brew search nginx
# Install
$ brew install nginx
配置
# 修改nginx默認(rèn)端口為80
$ vim /usr/local/etc/nginx/nginx.conf
$ ....
# nginx監(jiān)聽80端口需要root權(quán)限
$ sudo chown root:wheel /usr/local/Cellar/nginx/[版本號(hào)]/bin/nginx
$ sudo chmod u+s /usr/local/Cellar/nginx/[版本號(hào)]/bin/nginx
# 啟動(dòng)
$ nginx # 或者 brew services start nginx
#測(cè)試配置是否有語(yǔ)法錯(cuò)誤
$ nginx -t
# 重新加載配置|重啟|停止|退出 nginx
$ nginx -s reload|reopen|stop|quit
#使用launchctl來(lái)啟動(dòng)|停止
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
# 基本nginx站點(diǎn)
server {
listen 80;
server_name localhost;
charset utf-8;
access_log /usr/local/var/log/nginx/localhost.access.log;
error_log /usr/local/var/log/nginx/localhost.error.log;
root /path/to/youSites;
location / {
index index.php index.html index.htm;
# try_files $uri /$uri index.php?$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# 可單獨(dú)提取出來(lái)种蘸,再引入
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Mysql
# Search
$ brew search mysql
# Install
$ brew install mysql
# Exec mysql_secure_installation
$ mysql_secure_installation
# 查看mysql幫助
$ mysqld --help --verbose | more
...
Default options are read from the following files in the given order: # mysql 默認(rèn)配置讀取順序
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
...
# 查看mysql默認(rèn)配置樣例
$ ls $(brew --prefix mysql)/support-files/my-*
/usr/local/opt/mysql/support-files/my-default.cnf
# 移動(dòng)到/usr/local/etc/my.cnf
PHP
# Install php56 or php70 or php71
$ brew install php56
# 通過php-version控制多版本的php
$ brew install php-version
# PS: php-version使用在其他版本
基本開發(fā)足夠喷楣,其余優(yōu)化后續(xù)
未完待續(xù)..