用了Mac有一阵了,以前一直使用的Mamp Pro的集成环境,很是强大。能够自由切换php版本、更换Apache 和 Nginx、自定义站点 --破解MAmp pro 连接php
须要Homebrew,更换中国镜像。有不少帖子这里就不说了html
brew install php56 --with-debug --with-homebrew-libressl --with-homebrew-curl --with-gmp --with-libmysql --with-imap
# 加入开机启动 mkdir -p ~/Library/LaunchAgents cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/ sudo aunchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist # 将php和php-fpm 加入环境变量 echo 'export PATH="$(brew --prefix php56)/bin:$PATH"' >> ~/.zshrc #for php echo 'export PATH="$(brew --prefix php56)/sbin:$PATH"' >> ~/.zshrc #for php-fpm
php-fpm -v
可能会出现以下报错:mysql
Cannot load Xdebug - it was built with configuration API220131226,NTS, whereas running engine is API220131226,NTS,debug PHP Warning: PHP Startup: igbinary: Unable to initialize module Module compiled with build ID=API20131226,NTS PHP compiled with build ID=API20131226,NTS,debug
解决办法: 将上面的报错的扩展从新安装编译一下。(注意。必定要看你的报错有几个)nginx
brew reinstall php56-xdebug --build-from-source php56-igbinary --build-from-source
状况分析: 我在第一次安装的时候出现了。报错,可是第二次装的时候没出现。 分析是由于以前用mamp集成环境,已经存在了对应的扩展。参考这个 连接sql
brew install nginx
安装完成以后,会提示一些信息:
一、nginx 的配置文件: /usr/local/etc/nginx/nginx.conf
二、能够在这个目录下新建本身的虚拟主机: /usr/local/etc/nginx/servers/vim
一、 新建php-fpm配置,用于解析php脚本app
mkdir /usr/local/etc/nginx/conf.d vim /usr/local/etc/nginx/conf.d/php-fpm ## 将以下内容粘贴保存 location ~ \.php$ { try_files $uri = 404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_intercept_errors on; include fastcgi.conf; } ## 修改nginx.conf vim /usr/local/etc/nginx/nginx.conf
二、修改nginx。confcurl
vim /usr/local/etc/nginx/nginx.conf
user thanatos staff; ###指定用户 worker_processes 1; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; autoindex on; # 开启目录结构 #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root /Users/thanatos/Web; index index.html index.htm index.php; autoindex on; include conf.d/php-fpm; # include 刚才建立的脚本 } } include servers/*; }
三、将nginx加入开机开机启动socket
cp /usr/local/opt/nginx/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/ sudo launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
保存退出,从新起nginx (要使用管理员权限,否则不能使用80端口)tcp
sudo brew services restart nginx
/usr/local/etc/php/5.6
主要修改运行的用户
; Per pool prefix ; It only applies on the following directives: ; - 'access.log' ; - 'slowlog' ; - 'listen' (unixsocket) ; - 'chroot' ; - 'chdir' ; - 'php_values' ; - 'php_admin_values' ; When not set, the global prefix (or /usr/local/Cellar/php56/5.6.30_6) applies instead. ; Note: This directive can also be relative to the global prefix. ; Default Value: none ;prefix = /path/to/pools/$pool ; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. user = 你的用户 group = 用户组
保存重启php-fpm
sudo brew services restart php56
一、安装mysql比较简单,主要是配置mysql的登录
brew install mysql
二、加入开机启动
cp /usr/local/opt/mysql/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/ sudo launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
三、修改root密码 具体就不写了。
由于,记录的有点乱,就是本身作一个备忘,有遇到一样问题的老哥,或者我落了那一步,欢迎纠正