Mac 配置php开发环境

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值