安装 homebrew
ruby -e "$(curl -fsSLhttps://raw.github.com/Homebrew/homebrew/go/install)”
安装常用的包
brew install wget watch tmux cmake openssl imagemagick graphicsmagick gearman geoip readline autoconf multitail source-highlight autojump zsh-completions
xode6.1要先装command line tools 新版的不能直接从Xcode里下载了
https://developer.apple.com/library/ios/technotes/tn2339/_index.html
下载地址https://developer.apple.com/downloads/index.action#要开发者账号
我是直接命令行下载的
终端里运行xcode-select --install
cd
mkdir -p Data/tgz Data/apps/libs
cd Data/tgz
wgethttp://download.redis.io/releases/redis-3.0.2.tar.gz
wget -chttp://cn2.php.net/distributions/php-5.6.10.tar.gz
wget -chttp://pecl.php.net/get/yaf-2.3.3.tgz
wgethttp://nginx.org/download/nginx-1.9.2.tar.gz
wget -chttps://downloads.mariadb.com/archives/mysql-5.6/mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz
先安装最简单的 redis
tar -zxvf redis-3.0.2.tar.gz
cd redis-3.0.2
cp src/redis-* /usr/local/bin/
sudo cp redis.conf /etc/
sudo vi /etc/redis.conf
把修改daemonize yes
启动 redis-server /etc/redis.conf
mysql二进制安装一直安装不上 为方便就不用cmake编译安装了 直接下载mysql的dmg安装
下载地址http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.21-osx10.9-x86_64.dmg
shit dmg也安装不上 还是brew吧
brew install mysql
unset TMPDIR
sudo chmod -R 777 /usr/local/share/man
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
启动mysql
mysql.server start
设置密码
mysql_secure_installation
添加开机启动
ln -sfv /usr/local/Cellar/mysql/5.6.25/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
brew install nginx
常用目录
docroot is: /usr/local/var/www
/usr/local/etc/nginx/nginx.conf
添加开机启动
ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
#打开 nginx
sudo nginx
#重新加载|重启|停止|退出 nginx
nginx -s reload|reopen|stop|quit
brew install freetype mhash mcrypt libmcrypt jpeg libpng gd homebrew/dupes/zlib openssl unixodbc
查看能编译的参数
brew options homebrew/php/php56
brew install homebrew/php/php56 \
--homebrew-apxs \
--without-apache \
--with-fpm \
--with-gmp \
--with-homebrew-curl \
--with-homebrew-libxslt \
--with-homebrew-openssl \
--with-imap \
--without-snmp \
--with-libmysql \
--with-mssql \
--with-tidy
几个常用路径:
/usr/local/Cellar/php56/5.6.10/
/usr/local/etc/php/5.6/php.ini
/usr/local/Cellar/php56/5.6.10/sbin/php-fpm
# 设置目录权限
chmod -R ug+w /usr/local/Cellar/php56/5.6.10/lib/php
# 设置pear
pear config-set php_ini /usr/local/etc/php/5.6/php.ini
# 启动开机配置
ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
# 修改php-fpm的用户组为root
sudo chown root:wheel /usr/local/Cellar/php56/5.6.10/sbin/php-fpm
# 修改php-fpm的权限
sudo chmod u+s /usr/local/Cellar/php56/5.6.10/sbin/php-fpm
export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"
sudo rm -rf /usr/sbin/php-fpm
sudo ln -s /usr/local/Cellar/php56/5.6.10/sbin/php-fpm /usr/sbin/php-fpm
sudo rm -rf /usr/bin/php
sudo ln -s /usr/local/Cellar/php56/5.6.10/bin/php /usr/bin/php
vi /usr/local/etc/php/5.6/php-fpm.conf
# 找到并修改下面配置
daemonize = yes
查看php都有说明扩展能装
brew search php56
安装几个扩展
brew install php56-memcache php56-sphinx php56-swoole php56-redis php56-mcrypt
安装yaf扩展
cd ~/Data/tgz/
tar -zxvf yaf-2.3.3.tgz
cd yaf-2.3.3/
/usr/local/Cellar/php56/5.6.10/bin/phpize
./configure --with-php-config=/usr/local/Cellar/php56/5.6.10/bin/php-config
make
sudo make install
vi /usr/local/etc/php/5.6/php.ini
添加
extension_dir = "/usr/local/Cellar/php56/5.6.10/lib/php/extensions/debug-non-zts-20131226/"
extension="yaf.so"
查找
date.timezone =Asia/Shanghai
short_open_tag = On
保存退出
sudo killall php-fpm
sudo php-fpm
参考文章
http://blog.joefallon.net/2013/10/install-mysql-on-mac-osx-using-homebrew/
http://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew/
https://stackoverflow.com/questions/4359131/brew-install-mysql-on-mac-os