1.安装home-brew
https://www.jianshu.com/p/bca8fc1ff3f0
安装command line
xcode-select --install
xcode也可从appstore里面下载。
如果失败可以到这个网址下载:https://developer.apple.com/download/more/
下载homebrew
/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
我安装时候好像遇到了问题,换个资源源地址
2.安装mysql
brew install mysql@5.7
安装完成后开启mysql:/usr/local/opt/mysql@5.7/bin/mysql.server start
然后设置密码:执行文件 ./usr/local/opt/mysql@5.7/bin/mysql_secure_installation 根据提示操作
加入开机自启
cp /usr/local/opt/mysql@5.7/homebrew.mxcl.mysql@5.7.plist ~/Library/LaunchAgents/(路径根据版本而定)
3.安装PHP
brew install php@7.1
然后将php加入环境变量,运行:
echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.bash_profile
关掉终端窗口后重新打开
pecl命令可用来安装php扩展,在安装php@7.1时已经顺便把pecl安装了
安装Yaf扩展:pecl install yaf
安装redis扩展: pecl install redis (这里安装的是扩展!!!)
homebrew安装redis本地服务
安装debug:pecl install xdebug
安装扩展后记得运行 brew services restart php@7.1 重启php-fpm才生效
4.安装nginx
brew install nginx
加入开机自启
cp /usr/local/opt/nginx/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
给Nginx root权限
sudo chown root:wheel /usr/local/Cellar/nginx/1.6.0_1/bin/nginx
sudo chmod u+s /usr/local/Cellar/nginx/1.6.0_1/bin/nginx
如果nginx启动报错:nginx: [error] open() “/usr/local/var/run/nginx.pid” failed (2: No such file or directory)
执行:sudo nginx -c /usr/local/etc/nginx/nginx.conf
配置nginx虚拟主机
server {
listen 80;
server_name 域名;
root 根目录;
charset utf-8;
location / {
index index.php index.html index.htm;
#index放到后面好像先解析html,导致问题
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
#开启rewrite
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9001;
#端口这里做了修改
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
#开启解析PHP文件
}
}
还有不少坑记不住了后续遇到再补充…