Mac 下配置php环境,Mac下安装配置php开发环境

1、安装homebrew

curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1

2、安装nginx

sudo brew install nginx

3、安装mysql

sudo brew install mysql

4、由于mac默认安装了Apache和php,所以卸载掉Apache和php

sudo apachectl stop

sudo rm -rf /etc/apache2/

sudo rm -rf /usr/libexec/apache2/

sudo rm -rf /usr/php

sudo rm -rf /usr/bin/php

sudo rm -rf /usr/bin/php-config

sudo rm -rf /usr/bin/phpize

sudo rm -rf /usr/share/man/man*/php*

5、添加php源

sudo brew tap homebrew/dupes

sudo brew tap josegonzalez/homebrew-php

6、安装php

sudo brew install php55 --with-debug --with-fpm --with-gmp --with-homebrew-openssl --with-imap --with-intl --with-libmysql --without-bz2 --without-mysql --without-pcntl --without-pear php5 --with-cli --with-curl --with-fpm --with-intl --with-mcrypt --with-mysqlnd_ms --with-gd

验证php是否安装成功:php -v

验证php-fpm是否成功:php-fpm -t,结果报错“ERROR: failed to open configuration file '/private/etc/php-fpm.conf': No such file or directory”

php.ini.defalut和php-fpm.conf.default在/private/etc目录和/etc目录下都有

sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf

sudo chmod 777 /private/etc/php-fpm.conf

sudo php-fpm

报错“ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory”

sudo mkdir /usr/var

sudo mkdir /usr/var/log

sudo chmod 777 /usr/var/log

sudo php-fpm

到此php正常启动,接下来配置php.ini文件

sudo cp /etc/php.ini.default /etc/php.ini

sudo chmod 777 /etc/php.ini

sudo killall php-fpm

php-fpm

有两个notice,暂时不管

NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root

NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root

7、配置nginx

sudo vi /usr/local/etc/nginx/nginx.conf

修改监听端口为80

加上以下内容使nginx可以处理php

location ~ \.php$ {

root   /path/to/wwwroot;

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

include        fastcgi_params;

fastcgi_param  SCRIPT_FILENAME  /path/to/wwwroot$fastcgi_script_name;

}

启动nginx

sudo nginx

8、编辑mysql配置文件

检查mysql的运行状态

ps -ef | grep mysql

/usr/local/Cellar/mysql/5.6.25

/usr/local/opt/mysql/my.cnf

/usr/local/opt/mysql/bin/mysqld

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值