配置mac开发环境

按键

⌘(command)、⌥(option)、⇧(shift)、⇪(caps lock)、⌃(control)、↩(return)、⌅(enter)

安装secureCrt

secureCrt用于连接远程终端

安装

将windows的cinfig目录放到mac上报

The firewall ‘无’ was not found in the database .
This session will attempt to connect without a firewall

在config目录下执行下面命令解决

find . -name '*.ini' -type f -exec sed -i '' 's/=无/=None/g' '{}' \;

安装xcode

app store升级mac os x ,安装 xcode

xcode自带了svn、git、php、python、ruby

安装homebrew

官网

安装homebrew,使用os x不提供的命令

安装wget

brew install wget

git界面gitx-dev

gitx

在界面上选择安装命令行

cd到git仓库执行

gitx -all

smartySvn

升级svn到1.8

brew search subversion
brew tap homebrew/versions
brew install subversion18
svn --version

安装smartySvn open working copy选择svn co的目录

安装node

官网下载安装

安装包的时候使用sudo

sudo npm install -g webpack

搭建php开发环境

php开发环境

安装nginx

brew install nginx --with-http2
配置目录 /usr/local/etc/nginx/
sudo nginx
sudo nginx -t
sudo nginx -s reload

安装php

PHP在mac下默认安装了,但是不好控制版本,用brew安装php5.6

brew update
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install php70 --with-fpm #Nginx

/usr/local/etc/php/7.0/php.ini
/usr/local/etc/php/7.0/php-fpm.conf
brew services start josegonzalez/php/php70
sudo php-fpm -D # 启动
sudo killall php-fpm # 关闭

安装mysql

brew install mysql
chown -R mysql:mysql /usr/local/var/mysql
chmod -R 755 /usr/local/var/mysql
mysql.server start

安装composer

手动下载 composer.phar

mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer
composer -v

问题:

Your configuration does not allow connection to ... secure-http for details.

处理:

composer config -g secure-http false

安装memcached扩展

brew install memcached

/usr/local/opt/memcached/bin/memcached -d -m 64 -c 4096 -p 11210 -u www -t 10
/usr/local/opt/memcached/bin/memcached -d -m 256 -c 4096 -p 11211 -u www -t 10
killall memcached
pkill -9 memcached

brew install php70-memcached

安装其他扩展

brew install php70-mcrypt
brew install php70-xdebug

安装redis

brew install redis

启动

brew services start redis
brew install php70-redis

安装impala odbc

官网下载驱动

impala-odbc

cd /opt/cloudera/impalaodbc
cd Setup
cp odbc.ini ~/.odbc.ini

odbc.ini

[ODBC Data Sources]
Cloudera Impala DSN = Cloudera Impala ODBC Driver

[Cloudera Impala DSN]
Driver=/opt/cloudera/impalaodbc/lib/universal/libclouderaimpalaodbc.dylib
HOST = 192.168.8.207
PORT = 21050
AuthMech = 0

[Impala]
Description = ODBC for impala
Driver=/opt/cloudera/impalaodbc/lib/universal/libclouderaimpalaodbc.dylib

[ODBC Drivers]
Impala = Installed

[ODBC Data Sources]
Cloudera Impala DSN = Cloudera Impala ODBC Driver

[Cloudera Impala DSN]
Driver=/opt/cloudera/impalaodbc/lib/universal/libclouderaimpalaodbc.dylib
HOST = 192.168.8.207
PORT = 21050
AuthMech = 0

odbcinst.ini

[Impala]
Description = ODBC for impala
Driver=/opt/cloudera/impalaodbc/lib/universal/libclouderaimpalaodbc.dylib

[ODBC Drivers]
Impala = Installed

安装hive odbc

官网下载驱动

odbc.ini

[ODBC Data Sources]
Cloudera Impala DSN = Cloudera Impala ODBC Driver
Cloudera Hive DSN = Cloudera Hive ODBC Driver

[Cloudera Impala DSN]
Driver          = /opt/cloudera/impalaodbc/lib/64/libclouderaimpalaodbc64.so
HOST            = 192.168.8.207
PORT            = 21050
AuthMech        = 0

[Cloudera Hive DSN]
Driver=/opt/cloudera/hiveodbc/lib/64/libclouderahiveodbc64.so
HOST=192.168.8.207
PORT=10000
HiveServerType=2

[ODBC Drivers]
Impala          = Installed
Hive = Installed

odbcins.ini

[Impala]
Description     = ODBC for impala
Driver          = /opt/cloudera/impalaodbc/lib/64/libclouderaimpalaodbc64.so

[Hive]
Description     = ODBC for Hive
Driver          = /opt/cloudera/hiveodbc/lib/64/libclouderahiveodbc64.so

[ODBC Drivers]
Impala = Installed
Hive = Installed

测试连接

isql "Cloudera Hive DSN"

安装java

官网下载安装

锁屏快捷键

CTRL + SHIFT + Power

安装pip

sudo easy_install pip

zsh配置

mac自带了zsh

参考:终极shell

安装oh my zsh

git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

配置

vi ~/.zshrc

加上配置
alias cls='clear'
alias ll='ls -l'
alias la='ls -a'
alias vi='vim'
alias javac="javac -J-Dfile.encoding=utf8"
alias grep="grep --color=auto"
alias -s html=mate # 在命令行直接输入后缀为 html 的文件名,会在 TextMate 中打开
alias -s rb=mate # 在命令行直接输入 ruby 文件,会在 TextMate 中打开
alias -s py=vi # 在命令行直接输入 python 文件,会用 vim 中打开,以下类似
alias -s js=vi
alias -s c=vi
alias -s java=vi
alias -s txt=vi
alias -s gz='tar -xzvf'
alias -s tgz='tar -xzvf'
alias -s zip='unzip'
alias -s bz2='tar -xjvf'

oh my zsh 提供了数十种主题,相关文件在~/.oh-my-zsh/themes目录下

修改默认主题robbyrussell

将`%c`改为`%d`
c表示当前目录,d表示绝对路径

zsh插件

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.

插件目录 ~/.oh-my-zsh/plugins

自定义插件目录 ~/.oh-my-zsh/custom/plugins

启用插件 编辑 .zshrc 编辑 plugins=(rails git textmate ruby lighthouse)

安装autojump

brew install autojump

.bash_profile.zshrc加上

[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh

安装ctags

brew install ctags

vim配置

vim配置

vi ~/.vimrc
let Tlist_Ctags_Cmd='/usr/local/bin/ctags'

显示隐藏文件

使用终端,Finder需要重启才能应用修改,在终端中接着输入

defaults write com.apple.finder AppleShowAllFiles -bool true
killall Finder

恢复隐藏不可见,在终端中输入以下代码并回车

defaults write com.apple.finder AppleShowAllFiles -bool false
killall Finder

软件工具

  • Awesome Mac

  • dash 常见语言框架API文档

  • cakebrew brew的界面管理工具

  • cheatSheet 快捷键查看工具

  • licecap git录制工具

  • httpstat http分析工具

  • m-cli 常用命令行cli

  • fzf 历史命令搜索

  • percol

  • iHosts hosts编辑工具

mac1