Mac 下 Nginx、PHP、MySQL 和 PHP-fpm 的安装和配置

安装 Mac 的包管理器 - homebrew

home-brew?home-brew与OS X就像nodes与npm,php与composer,apt-get与Ubutun,yum与centos

安装Homebrew之前,先安装xcode命令行工具

xcode-select –install

home-brew的安装很容易,只要你的客户终端安装了ruby即可,其实,你一点都不用担心此事,OS X系统已经预装了ruby。

ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

安装 Nginx 服务器

安装好了Homebrew之后,便可以使用brew命令来安装相应的包了。接下来,安装nginx服务器。

brew install nginx

安装完成后执行下面几条命令测试一下

1
2
3
4
5
6
###### 启动 nginx服务
sudo nginx
# 重新加载配置|重启|停止|退出 nginx
nginx -s reload|reopen|stop|quit
#测试配置是否有语法错误
nginx -t

nginx启动后,在浏览器中输入http://localhost:8080/,回车即可看到运行结果

开机自启动nginx服务设置:

1
2
3
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/nginx/1.10.0/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

nginx权限

1
2
sudo chown root:wheel /usr/local/Cellar/nginx/1.10.0/sbin/nginx
sudo chmod u+s /usr/local/Cellar/nginx/1.10.0/sbin/nginx

安装和配置 MySQL 服务器

brew install mysql

查看mysql数据库是否启动

ps -ef | grep mysql

如果没有启动,使用安装的mysql目录下的mysqld命令启动mysql:

/usr/local/Cellar/mysql/5.7.12/bin/mysqld

可直接使用/usr/local/bin/mysqld就可以启动

which mysqld

设置开机启动mysql

mkdir -p ~/Library/LaunchAgents/
cp /usr/local/Cellar/mysql/5.7.12/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

安装php56和php-fpm

php的安装很简单,php-fpm目前已经集成到php的内核

brew install php56 –with-imap –with-tidy –with-debug –with-pgsql –with-mysql –with-fpm

安装php扩展

1
2
3
4
5
brew install php56-apcu php56-intl php56-redis php56-uuid php56-zookeeper
php56-thrift php56-solr php56-ssh2 php56-gmagick php56-kafka php56-libevent
php56-imagick php56-msgpack php56-geoip php56-mcrypt php56-swoole
php56-scrypt php56-xdebug php56-yaf php56-yaml php56-xhprof
php56-memcache php56-memcached php56-gearman

辨析 Sass 中的 Map 和 List

如果你使用过 Sass 3.3 之前的版本,那么你一定对那段时光颇有感触,那时候没有现如今这么好的条件,那时候的 Map 还只能用多重列表(lists of list)来模拟。多重列表可以实现复杂数据的嵌套定义,但却不是以键值对的形式实现的,所有当我们需要获取其中特定的某一项时就会比较麻烦。Map 这种数据类型天生就是基于键值对的形式,非常便于组织数据。

自从可以使用 Map 之后,开发者们开始毫无顾忌地定义 Map 存储数据,比如断点宽度、颜色值、栅格布局等等响应式排版的细节,都被一股脑的塞进了 Map 中。

那么,有了 Map 之后,我们还有必要使用 List 吗?可能某些人会觉得为了保持向后兼容应该继续使用多重列表模拟 Map,因为可能有些开发者仍然在使用老版本的 Sass 编译器,但实际上,这是多此一举了,Sass 的版本通常由 package.json 或者其他同类型的项目配置文件所控制,往往只需一条命令(gem update sass)即可更新 Sass 的版本,因此基本上无需考虑对老版本的兼容问题。

More...