Mac折腾LNMP

之前安装mysql一直都是失败,于是使用了mamp,发现很多扩展安装非常麻烦。于是,又开始动手使用homebrew安装 php7 + mysql5.7 +nginx.

一、设置homebrew

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew update
 brew tap homebrew/dupes 
 brew tap homebrew/versions 
 brew tap homebrew/homebrew-php 

二、安装nginx

# 重启nginx : sudo nginx -s reload|stop
sudo nginx -s stop && sudo nginx

三、安装mysql

brew edit mysql
wget xxxx-5.7.11.tar.gz
mv mysql-5.7.11.el_capitan.bottle.tar.gz /Library/Caches/Homebrew/
brew install mysql

四、安装php

4.1 安装php5.x

使用brew可以安装php的版本有 5.3、5.4、5.5、5.6

如果已经有安装php,需要unlink后再继续。比如我现在有php54,但要安装hp55,则需要这样去执行升级操作:

brew unlink php54
brew install php55

4.2 安装php7.0

mac下重启php-fpm后可能使用了旧的版本,需要执行如下命令使得php和php-fpm调用的是7.0的版本:

export PATH="$(brew --prefix php70)/sbin:$PATH"

4.3 PHP常用扩展安装

# swoole: https://github.com/swoole/swoole-src/releases/
# redis:  下载:https://github.com/phpredis/phpredis/tree/php7

# 以上安装方式都是:
./configure
make && make install

# memcached
brew install memcached
brew install php70-memcached

4.4 安装php常见问题

  1. memcached 依赖问题
PHP Deprecated: PHP Startup: memcached.sess_lock_wait and memcached.sess_lock_max_wait are deprecated. Please update your configuration to use memcached.sess_lock_wait_min, memcached.sess_lock_wait_max and memcached.sess_lock_retries in Unknown on line 0Deprecated: PHP Startup: memcached.sess_lock_wait and memcached.sess_lock_max_wait are deprecated. Please update your configuration to use memcached.sess_lock_wait_min, memcached.sess_lock_wait_max and memcached.sess_lock_retries in Unknown on line 0PHP Deprecated: PHP Startup: memcached.sess_lock_wait and memcached.sess_lock_max_wait are deprecated. Please update your configuration to use memcached.sess_lock_wait_min, memcached.sess_lock_wait_max and memcached.sess_lock_retries in Unknown on line 0Deprecated: PHP Startup: memcached.sess_lock_wait and memcached.sess_lock_max_wait are deprecated. Please update your configuration to use memcached.sess_lock_wait_min, memcached.sess_lock_wait_max and memcached.sess_lock_retries in Unknown on line 0PHP 7.0.2 (cli) (built: Jan 7 2016 10:40:26) ( NTS )Copyright (c) 1997-2015 The PHP GroupZend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies with Xdebug v2.4.0RC3, Copyright (c) 2002-2015, by Derick Rethans

需要注释配置/usr/local/etc/php/7.0/conf.d/ext-memcached.ini如下内容:

;memcached.sess_lock_wait = 150000
;memcached.sess_lock_max_wait = 0

参考

  • http://stackoverflow.com/questions/35130463/php7-memcache-deprecated-error-message

博客已经迁移:阅读原文

你可能感兴趣的:(Mac折腾LNMP)