[TOC]
# GIthub 上的項目
https://github.com/donnemartin/dev-setup
創建一個新的開發人員機器可以是一個特別的、手動的、耗時的過程。devsetup的目的是簡化過程,使用易于理解的指令和多文件/腳本實現以下步驟的自動化:
OS X updates and Xcode Command Line Tools
OS X defaults geared towards developers
Developer tools:Vim, bash, tab completion, curl, git, GNU core utils, Python, Ruby, etc
Developer apps: iTerm2, Sublime Text, Atom, VirtualBox, Vagrant, Docker, Chrome, etc
Python data analysis: IPython Notebook, NumPy, Pandas, Scikit-Learn, Matplotlib, etc
Big Data platforms:Spark (with IPython Notebook integration) and MapReduce
Cloud services: Amazon Web Services (Boto, AWS CLI, S3cmd, etc) and Heroku
Common data stores: MySQL, PostgreSQL, MongoDB, Redis, and Elasticsearch
Javascript web development:Node.js, JSHint, and Less
Android development: Java, Android SDK, Android Studio, IntelliJ IDEA
# Xcode 安裝管理
https://github.com/KrauseFx/xcode-install
# Android 開發環境
## android-platform-tools
1. Install adb
~~~
brew install android-platform-tools
~~~
2. Start using adb
~~~
adb devices
~~~
## Android-SDK-Manager
http://developer.android.com/sdk/index.html#mac-tools
參考:https://stackoverflow.com/questions/31374085/installing-adb-on-macos
給二個靠譜的網址:
1. http://www.androiddevtools.cn/index.html
2. http://down.tech.sina.com.cn/page/45703.html
3. http://mac.softpedia.com/get/Developer-Tools/Google-Android-SDK.shtml
到這個面下載后,解壓到某個目錄。
或者通過`brew install android-sdk` 安裝~,我好像安裝之后,調不出 sdk manager~,在以后研究。
[如何在mac本上安裝android sdk](https://www.cnblogs.com/yjmyzz/p/4219829.html)
# Node Version Manager
官網:https://github.com/creationix/nvm
## 安裝 nvm
~~~
brew install nvm
~~~
然后重啟終端。
### nvm command not found!
~~~
mkdir ~/.nvm
export NVM_DIR="$HOME/.nvm"
. "/usr/local/opt/nvm/nvm.sh"
~~~
## 使用方法
1. 安裝 指定node版本
~~~
nvm install node #默認安裝最新版本。
nvm install 8.9.4 #命令后加版本號就可以進行安裝,字母v可以不寫
~~~
2. 查看當前使用的版本
~~~
nvm current
~~~
3. 切換指定版本,切換效果是全局的
~~~
nvm use v7.9.0
~~~
4. 查看該系統已經安裝的版本,這個命令也能看到當前使用的是哪個版本
~~~
nvm ls
~~~
## 國內 npm 加速
[nrm](https://github.com/Pana/nrm) 是管理npm源切換的利器,簡單方便。
~~~
npm i nrm -g #安裝 nrm
nrm test #測試源的響應時間,可以作為使用哪個源的參考
nrm use cnpm # 使用 cnpm
nrm ls #查看狀態
~~~
# jEnv
[jenv](https://github.com/gcuisinier/jenv#readme) 是一個專門用于配置 `JAVA_HOME` 環境變量工具(用來設置 `JAVA_HOME` 環境變量的)。你可以用它來管理 Mac 上的 Java 版本。
查看本機當前 已安裝 java 版本
~~~shell
/usr/libexec/java_home -V
/usr/libexec/java_home -v 1.8
~~~
## 安裝 jenv
~~~shell
brew install jenv
# 或者
git clone https://hub.fastgit.org/gcuisinier/jenv.git ~/.jenv
~~~
## 配置 jenv
Bash
~~~
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(jenv init -)"' >> ~/.bash_profile
~~~
Zsh
~~~
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(jenv init -)"' >> ~/.zshrc
~~~
如果已經添加但是仍沒有生效的話,可以試一下重新加載bash_profile
~~~
source ~/.bash_profile
~~~
## 安裝 JDK
Apple 已[發布公告](https://developer.apple.com/library/prerelease/mac/releasenotes/General/rn-osx-10.11/index.html),聲明 Mac OS X 10.11 (El Capitan) 將為最后一個支持 Java 6 的 OS X 發行版。
現在 OS X 都不會自帶 JDK 了,所以 需要 Oracle 網站上下載。
1. 手動下載: [JAVA SDK](http://www.oracle.com/technetwork/java/javase/overview/index.html)
2. brew 安裝 java
```shell
brew tap AdoptOpenJDK/openjdk
# 下載 Jdk8
brew install --cask homebrew/cask-versions/adoptopenjdk8
# 或者 jdk15
brew cask install adoptopenjdk15
```
**Mac 的 Java 默認會安裝到 `/Library/Java/JavaVirtualMachines/` 路徑下**。
接著配置 JAVA 多版本:
> ??具體 jdk 目錄,可以切到 `/Library/Java/JavaVirtualMachines/` 下查看!
~~~
# 成功添加 jdk1.8 配置到 jEnv
$ jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/
oracle64-1.8.0.131 added
1.8.0.131 added
1.8 added
# 添加 jdk9
$ jenv add /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home
$ jenv default java 1.8
~~~
成功之后,運行 `echo $JAVA_HOME`,如果定位到了`/Users/chandlerver5/.jenv/candidates/java/current`,說明配置成功。
## 列出管理的JDK
~~~
$ jenv versions
* system (set by /Users/demo/.jenv/version)
1.7
1.7.0.45
1.8
1.8.0.131
oracle64-1.7.0.45
oracle64-1.8.0.131
~~~
看起來有點多,但其實就是1.7、1.8兩個版本的別名。
## 使用Java版本
配置全局Java版本
~~~
$ jenv global 1.7
~~~
配置當前目錄的 Java 版本
~~~
$ jenv local 1.8
~~~
這種方式會只改變當前所在目錄的 jdk 版本,可以通過如下命令取消
~~~
$ jenv local --unset
~~~
配置 shell 實例的版本
~~~
jenv shell 1.8
~~~
這種配置方式,只會影響當前 shell 窗口。
## 配置JVM Options
~~~
$ jenv global-options "-Xmx512m"
~~~
or
~~~
$ jenv local-options "-Xmx512m"
~~~
or
~~~
$ jenv shell-options "-Xmx512m"
~~~
# 卸載JDK
~~~
sudo rm -fr ~/Library/Application\ Support/Java
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk<version>.jdk
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -fr /Library/PreferencesPanes/JavaControlPanel.prefpane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/LaunchAgents/com.oracle.java.Java-Updater.plist
sudo rm -rf /Library/PrivilegedHelperTools/com.oracle.java.JavaUpdateHelper
sudo rm -rf /Library/LaunchDaemons/com.oracle.java.Helper-Tool.plist
sudo rm -rf /Library/Preferences/com.oracle.java.Helper-Tool.plist
~~~
## 系統自帶切換
[mac中不同jdk版本切換](https://www.jianshu.com/p/91bbb537fd52)
# ~~jenv (他們網站關閉了)~~
(請注意該工具不同于 jEnv, 這是用來設置 `JAVA_HOME` 環境變量的,不但支持 管理Java 多版本,還支持其他Java開發工具!)
[jenv](https://github.com/linux-china/jenv) 支持 Windows、Mac 和 Linux – 可以輕松管理大量**基于 Java 開發的工具**的多個版本,如 Maven、Gradle 或者是 Tomcat 之類。目前已經支持超過 200 個不同的工具。
安裝 jenv:
~~~
$ curl -L -s get.jenv.mvnsearch.org | bash
~~~
接著配置 JAVA 多版本:
> ??具體 jdk 目錄,可以切到 `/Library/Java/JavaVirtualMachines/` 下查看!
~~~
$ mkdir -p $HOME/.jenv/candidates/java
$ ln -s /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home $HOME/.jenv/candidates/java/1.8
$ ln -s /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home $HOME/.jenv/candidates/java/9.0
$ jenv default java 1.8
~~~
查看jenv 支持的多個工具:
~~~
$ jenv all
~~~
例如 查看 `java` ,運行:
~~~
$ jenv list java
~~~
如果你想 安裝 其中的 java 一個版本,會提示你去官網下載!
~~~
$ jenv install java 1.8.0_77
Please visit http://www.oracle.com/technetwork/java/javase/downloads/ and download dmg file.
~~~
安裝其他的可以,也支持管理本地的已經安裝的工具,或是github上的源。
~~~
$ jenv list maven
$ jenv install maven 3.3.9
~~~
安裝成功之后,`mvn --version` 檢查安裝成功。
更新jenv
~~~
$ jenv selfupdate
~~~
> [使用 Jenv 讓所有 Java 開發工具同時運行多個版本](https://coyee.com/article/12114-how-to-run-multiple-versions-of-all-your-dev-tools-with-jenv)
# MySql
1. 安裝:搜索 mysql 版本 brew search mysql (若不更具需要選擇,會默認最新版本)
~~~
$ brew install mysql
~~~
安裝成功后:
~~~
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/mysql/bin:$PATH"' >> ~/.zshrc
To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don't want/need a background service you can just run:
mysql.server start
==> Summary
?? /usr/local/Cellar/mysql/8.0.12: 255 files, 233.0MB
~~~
查看 mysql 信息:
~~~
brew info mysql
~~~
2. 創建my.cnf配置文件
mysql 在新版中去掉了默認配置文件my.cnf如果需要可以手動創建。
首先需要知道系統是按如下順序去找my.cnf:
~~~
i. /etc/my.cnf
ii. /etc/mysql@5.7/my.cnf
iii. /usr/local/etc/my.cnf
iv. ~/.my.cnf
~~~
所以就在 `/etc`下創建 `my.cnf`
~~~
$ sudo vim /etc/my.cnf
~~~
配置文件內容如下:
~~~
# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
default-character-set=utf8
#password = your_password
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
character-set-server=utf8
init_connect='SET NAMES utf8
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
character-set-server=utf8
init_connect='SET NAMES utf8'
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
# binary logging format - mixed recommended
binlog_format=mixed
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
# the syntax is:
#
# CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
# MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
# where you replace <host>, <user>, <password> by quoted strings and
# <port> by the master's port number (3306 by default).
#
# Example:
#
# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
# MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
# start replication for the first time (even unsuccessfully, for example
# if you mistyped the password in master-password and the slave fails to
# connect), the slave will create a master.info file, and any later
# change in this file to the variables' values below will be ignored and
# overridden by the content of the master.info file, unless you shutdown
# the slave server, delete master.info and restart the slaver server.
# For that reason, you may want to leave the lines below untouched
# (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id = 2
#
# The replication master for this slave - required
#master-host = <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user = <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password = <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port = <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /usr/local/mysql/data
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /usr/local/mysql/data
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
default-character-set=utf8
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
~~~
3. 加入launchctl啟動控制
~~~
$ mkdir -p ~/Library/LaunchAgents
$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
$ find /usr/local/Cellar/mysql/ -name "homebrew.mxcl.mysql.plist" -exec cp {} ~/Library/LaunchAgents/ \;
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# 取消啟動
# launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
~~~
4. 初始化 mysql
~~~
mysql_install_db
~~~
5. 需要先啟動 mysql ,執行安全設置腳本,設置root賬號密碼
~~~
mysql_secure_installation
~~~
6. 最后測試一下登陸
~~~
$ mysql -u root -p
~~~
# Python
# nginx
# tomcat
~~~
$ brew install tomcat
~~~
安裝成功后:
~~~
==> Caveats
To have launchd start tomcat now and restart at login:
brew services start tomcat
Or, if you don't want/need a background service you can just run:
catalina run
==> Summary
?? /usr/local/Cellar/tomcat/9.0.10: 626 files, 13.3MB, built in 11 seconds
~~~
檢查是否安裝成功:
~~~
$ catalina -h
~~~
運行tomcat:
~~~
$ catalina run
~~~
正常是可以成功的了,訪問`http://localhost:8080` 看下是否出現Tomcat的網站。
webapp的根目錄(CATALINA_HOME)為:`/usr/local/Cellar/tomcat/9.0.10/libexec/webapps/ROOT/`
# Tomcat
catalina 就是Tomcat服務器使用的 Apache實現的servlet容器的 名字。
Tomcat的核心分為3個部分:
(1)Web容器---處理靜態頁面;
(2)catalina --- 一個servlet容器-----處理servlet;
(3)還有就是JSP容器,它就是把jsp頁面翻譯成一般的servlet。
catalina腳本啟動參數
~~~
-help : 輸出命令行選項的摘要表
-nonaming : 在tomcat中停用JNDI
-security : 啟用catalina.policy文件
debug : 以調試模式啟動tomcat
embedded : 在嵌入模式中測試tomcat;應用程序服務器的開發者通常使用此選項
jpda start : jpda 的調試方式啟動tomcat
run : 啟動tomcat,但不會重定向標準輸出與錯誤
start : 啟動tomcat,并將標準輸出與錯誤送至tomcat的日志文件
stop : 停止tomcat
version : 輸出tomcat的版本信息
~~~
https://www.jb51.net/article/120665.htm
https://blog.csdn.net/wild46cat/article/details/52412330
# [rbenv](https://github.com/sstephenson/rbenv)
人人都需要一個 Ruby 版本管理工具。rbenv 就是這樣一個輕量級工具,它可以通過 brew 安裝。
安裝:
~~~
brew install rbenv ruby-build
~~~
然后在`~/.zshrc`中加上rbenv插件。否則你需要手動添加`eval "$(rbenv init -)"`到`~/zshrc`或者`~/.zprofile`文件里。
有時候項目會依賴一些奇怪的版本號,比如ruby-2.1.0,這個時候你需要 [rbenv-aliases](https://github.com/tpope/rbenv-aliases) 幫忙:
~~~
brew install rbenv-aliases
~~~
替代品有 RVM、chruby。因為 RVM 不能通過 brew 安裝,并且安裝的時候會沒有節操的修改一堆文件,所以被我早早的棄用了。chruby 也是一個輕量級工具,而且可以完美的和 Oh My Zsh 集成在一起,我看到有些生產環境在用它。
## Ruby 常用別名
幾乎所有 Ruby 開發人員都會把`bi`作為bundle install的別名。
Oh My Zsh 提供builder插件,這個插件提供了一套別名,比如`bi`、`be`。同時還能讓你在運行一些常用 gem 的時候直接輸入`rspec`,不需要`be rspec`這樣了。具體包括哪些命令請[參考這里](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/bundler)。
Z shell 對于`[`和`]`符號有特殊的處理,所以在運行`rake task[parameter]`的時候會報錯,你需要改成`rake task\[parameter\]`或者`noglob rake task[parameter]`。
然而 Oh My Zsh 已經看穿這一切,自帶的 rake 插件已經解決了這個問題:`brake task[parameter]`。
添加插件的時候注意把`rake`放到`bundler`后面,例如這樣:
~~~
plugins=(git z sublime history rbenv bundler rake)
~~~
- 簡介
- 基本命令
- 高效操作
- 命令操作
- 常用軟件
- 問題設置
- 命令行神器
- 開發配置
- 開發環境配置
- brew
- git
- Karabiner-Elements
- iTerm2
- MacVim
- aria2
- LaunchBar
- zsh
- Tmux
- Charles
- Emacs(感覺不需要了)
- 常用工具
- Alfred
- mac 詞典增強
- Mac 高級操作
- mac 資源
- 黑蘋果
- 個人配置
- 黑蘋果資源
- 驅動集合
- 工具集合
- 黑蘋果指南
- [FAQ] 開始必讀!筆記本電腦常見問題
- [指南] hackintosh之SSDT/DSDT
- [指南] hackintosh之hotpatch
- [指南] 為Sierra(以及后來的版本)進行USB電源屬性注入
- [指南] 10.11+ USB的變化和解決方案
- [指南] 為USBInjectAll.kext創建一個自定義的SSDT
- [指南] Intel IGPU HDMI/DP audio (Sandy/Ivy/Haswell/Broadwell/Skylake)
- [指南] 怎么給DSDT打補丁來顯示電池狀態
- [指南]在雙GPU筆記本電腦中禁用獨立顯卡.md
- [指南]
- OpenCore
- 多系統引導
- hotpatch
- 黑蘋果裝機
- 刷BIOS大法
- dd