1.nginx设置
安装:brew install nginx
/usr/local/Cellar/nginx/1.6.2
/usr/local/etc/nginx/nginx.conf
nignx 安装完之后默认是监听8080 端口的,要在nginx.conf文件里修改端口
设置开机启动
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/nginx/1.6.2/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
设置权限
sudo chown root:wheel /usr/local/Cellar/nginx/1.6.2/bin/nginx
sudo chmod u+s /usr/local/Cellar/nginx/1.6.2/bin/nginx
2.mysql配置
安装:brew install mysql
/usr/local/Cellar/mysql/5.6.23
默认配置文件/usr/local/Cellar/mysql/5.6.23/my.cnf
安装完之后可能会报以下错误:
ERROR 2002 (HY000): Can not connect to local MySQL server through socket '/tmp/mysql.sock' (2)
执行以下语句:
unset TMPDIR
mysql.server start
如果以上操作还不可以的话,可以尝试以下操作:
sudo chown -R _mysql:admin /usr/local/var/mysql
设置开机启动:
cp /usr/local/Cellar/mysql/5.6.16/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
设置mysql root用户名密码:
mysqladmin -u root -h host_name password 新密码
3.php配置
brew update
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/php
brew install php55 --with-fpm --with-gmp --with-imap --with-tidy --with-debug --with-mysql --with-libmysql --with-homebrew-curl --with-homebrew-libxslt --with-homebrew-openssl
由于Mac自带了php和php-fpm,因此需要添加系统环境变量PATH来替代自带PHP版本。
echo 'export PATH="$(brew --prefix php55)/bin:$PATH"' >> ~/.bash_profile #for php
echo 'export PATH="$(brew --prefix php55)/sbin:$PATH"' >> ~/.bash_profile #for php-fpm
echo 'export PATH="/usr/local/bin:/usr/local/sbib:$PATH"' >> ~/.bash_profile #for other brew install soft
source ~/.bash_profile
brew安装的php在/usr/local/opt/php55/bin/php
开机自动启动php-fpm
cp /usr/local/Cellar/php55/5.5.23/homebrew.mxcl.php55.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist
Nginx 配置php-fpm
location ~ \.php$ {
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/Cellar/nginx/1.2.6/html$fastcgi_script_name;
include /usr/local/etc/nginx/fastcgi_params;
}
修改原有的项目路径
/usr/local/Cellar/nginx/1.6.2/html -> ../../../var/www
改为
/usr/local/Cellar/nginx/1.6.2/html -> /var/www/htdocs