Skip to Content

我的 MacPro 更新记

Posted on 7 mins read

好记性不如烂笔头,要是让我写出自己的开发环境是如何搞的,可能还真写不全,长年累月的演变,实在记不住,用了快 5 年的 MacPro 终于要更新了,借此机会记录下自己装机折腾记。

常用软件安装

新机开苞后,先是各种软件各种装,有了之前折腾软件的经验,无用软件一概不再装。下面是我平时做后端架构开发、技术调研等工作时,常用的一些软件列表:

开发工具

编程软件

sublimeText

  1. 安装 package control,现在已经很方便了,直接参考官网,Sublime 命令行安装 packageControl 指令:
import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
  1. command + , 调出老电脑的 sublime 相关配置,直接加入到新电脑的 sublime 配置
{
	"always_show_minimap_viewport": true,
	"bold_folder_labels": false,
	"color_scheme": "Packages/Enki Theme/scheme/Enki.tmTheme",
	"default_line_ending": "unix",
	"enki_theme_accent_blue": true,
	"enki_theme_accent_bluegray": true,
	"enki_theme_accent_cyan": true,
	"enki_theme_accent_fuschia": true,
	"enki_theme_accent_green": true,
	"enki_theme_accent_indigo": true,
	"enki_theme_accent_lime": true,
	"enki_theme_accent_orange": true,
	"enki_theme_accent_pink": true,
	"enki_theme_accent_purple": true,
	"enki_theme_accent_red": true,
	"enki_theme_accent_samon": true,
	"enki_theme_accent_teal": true,
	"enki_theme_accent_white": true,
	"enki_theme_accent_yellow": true,
	"enki_theme_color_expanded_folder": true,
	"enki_theme_compact_sidebar": true,
	"enki_theme_panel_separator": true,
	"enki_theme_small_statusbar": true,
	"enki_theme_small_tab": true,
	"enki_theme_tabs_autowidth": true,
	"enki_theme_tree_headings": false,
	"font_size": 12,
	"ignored_packages":
	[
		"phpfmt",
		"Vintage"
	],
	"indent_guide_options":
	[
		"draw_normal",
		"draw_active"
	],
	"line_padding_bottom": 0,
	"line_padding_top": 0,
	"overlay_scroll_bars": "enabled",
	"theme": "Enki-Theme.sublime-theme"
}

Jetbrains 公司相关开发 IDE 安装

intelliJ IDEA、PHPStorm、CLion,很好,很强大也很贵,所以网上找了激活服务器,本次安装激活使用的 注册服务器:http://idea.iteblog.com/key.php,先这么用着。

iTerm

安装 zsh

服务器软件安装

PHP

在 Mac 上重头折腾 PHP 环境,是比较痛苦的,因为新的 Mac 上,缺少很多 PHP 安装的依赖,虽然安装依赖,甚至是 PHP 的安装,我们都可以通过 brew 来搞定,但是通常 brew 不便于定制化安装 PHP,而且 brew 安装所支持的扩展也有限,比如 PHP7.2 版本所支持的扩展列表为:

 ~/ brew search 'php72'
homebrew/php/php72                 homebrew/php/php72-pspell          homebrew/php/php72-rdkafka
homebrew/php/php72-redis           homebrew/php/php72-snmp            homebrew/php/php72-ev
homebrew/php/php72-couchbase       homebrew/php/php72-tidy            homebrew/php/php72-grpc
homebrew/php/php72-phalcon         homebrew/php/php72-uv              homebrew/php/php72-event
homebrew/php/php72-swoole          homebrew/php/php72-libsodium       homebrew/php/php72-lz4
homebrew/php/php72-gmp             homebrew/php/php72-oauth           homebrew/php/php72-blitz
homebrew/php/php72-opcache         homebrew/php/php72-stats           homebrew/php/php72-mecab
homebrew/php/php72-pcntl           homebrew/php/php72-geos            homebrew/php/php72-lua
homebrew/php/php72-pdo-dblib       homebrew/php/php72-ssh2            homebrew/php/php72-igbinary
homebrew/php/php72-pdo-pgsql       homebrew/php/php72-amqp            homebrew/php/php72-hprose

诸如此类,所以对于 PHP 定制化的安装需求,源码安装将是不二之选。 但是如果只需要一个 PHP 某个版本的运行环境,而不 care 调试或者某些特殊扩展的安装的话,brew 是个很好的选择。下面记录下两种安装的方式。

源码安装 PHP

源码安装 PHP 的过程可以说比较痛苦,尤其是在全新的环境来安装。所以我一般的安装方式就是安装 PHP 前,先针对我计划使用的编译参数,使用 brew 安装一些必须的依赖, 以下先贴出我所用的 configure 参数:

./configure  --prefix=/usr/local/php-7.1.7 --enable-phpdbg --enable-phpdbg-debug --enable-phpdbg-webhelper --enable-debug --enable-fpm  --with-mysqli --with-zlib --enable-mbstring=all --enable-sockets --with-pear --enable-ftp --with-libxml-dir --with-mcrypt --with-pdo-mysql --with-freetype-dir --enable-pcntl --with-ldap --with-curl --enable-soap --with-openssl --enable-shmop --enable-sysvsem --enable-sysvshm --enable-sysvmsg

可能需要依赖的包有 libmcrypt、 openssl@1.1

brew install libmcrypt openssl@1.1

安装完以上依赖后,运行 configure,在这个过程中根据报错缺啥补啥,下面是本次安装过程中遇到的一些错误,以及处理方式:

  1. 找不到 OpenSSL configure: error: Cannot find OpenSSL's <evp.h> 问题及解法:没有指定 OpenSSL 的安装目录,--with-openssl=/usr/local/openssl-1.1.0f/,我本机使用源码安装的方式将 openssl 安装到了 /usr/local/openssl-1.1.0f/ 目录。

  2. 找不到 OpenSSL’s libraries configure: error: Cannot find OpenSSL's libraries 问题及解法:我编译参数中多了一个 --with-libdir=lib64,因为我的编译参数是之前 CentOS 虚拟机中使用的,当时加了这个参数,所以导致在编译的时候找不到 OpenSSL's libraries,Mac 的路径与 CentOS 不一样。将这个参数去掉即可。

brew 安装 PHP5.4

可能由于测试或者其他需求,我们需要多个 PHP 运行环境,而这些版本往往不是我们研习的主要方向,这时我们可以使用 brew 来方便的安装。这里以 brew 安装 PHP5.4 为例。

 // brew search 'php54'
homebrew/php/php54                           homebrew/php/php54-magickwand                homebrew/php/php54-solr
homebrew/php/php54-amqp ...
... ...

 ~/ brew install homebrew/php/php54 --with-fpm --with-gmp --with-imap --with-tidy --with-debug --with-mysql --with-libmysql
==> Tapping homebrew/php
关于 brew 安装

后面专门有个段落说明在 Mac 上安装 brew,这里主要说明几个使用 brew 关注的点。

  1. brew 默认将包安装到 /usr/local/Cellar/ 路径下。
  2. brew 安装的包,会自动的在 /usr/local/opt 路径下建立软连接,所以上面 --with-openssl 可以指定到 /usr/local/opt/openssl 路径。
  3. 会根据具体安装包的情况,同样也会在相应的系统目录建上相关的连接,比如:/usr/local/sbin/usr/local/bin/usr/local/lib/usr/local/share/usr/local/include

其他

这些软件都是这么些年来觉得很不错的软件,价钱不太贵,收费方式比较合理的,我都买了正版支持,所以下面这些软件我也忘了哪些是买过的,反正 APPStore 能直接安装。如何安装不了,可以到网上搜索盗版,推荐 7do.net、soft.macx.cn 等

RegExRx

正则表达式检查软件,方便调试正则表达式。

Markdown Plus

很早之前买的一款 MD 编辑器,还行挺方便。

Keka

解压软件,常用的一些都能解压,够用了。

brew

brew MacX 的包管理工具。

 ~/ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

-e:161: warning: Insecure world writable dir /Volumes/g/idevz/code/z/git/go/bin in PATH, mode 040777
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following existing directories will be made group writable:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man8
==> The following existing directories will have their owner set to zhoujing2:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man8
==> The following existing directories will have their group set to admin:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man8
==> The following new directories will be created:
/usr/local/Cellar
/usr/local/Homebrew
/usr/local/Frameworks
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/opt
/usr/local/sbin
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man8
Password:
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man8
==> /usr/bin/sudo /usr/sbin/chown zhoujing2 /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man8
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man8
==> /usr/bin/sudo /bin/mkdir -p /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown zhoujing2 /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /bin/mkdir -p /Users/idevz/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/idevz/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown zhoujing2 /Users/idevz/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/mkdir -p /Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown zhoujing2 /Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 6819, done.
remote: Compressing objects: 100% (4074/4074), done.
remote: Total 6819 (delta 4052), reused 4488 (delta 2535), pack-reused 0
Receiving objects: 100% (6819/6819), 3.63 MiB | 1.14 MiB/s, done.
Resolving deltas: 100% (4052/4052), done.
From https://github.com/Homebrew/brew
 * [new branch]      master     -> origin/master
 * [new tag]         0.1        -> 0.1
 * [new tag]         0.2        -> 0.2
 * [new tag]         0.3        -> 0.3
 * [new tag]         0.4        -> 0.4
 * [new tag]         0.5        -> 0.5
 * [new tag]         0.6        -> 0.6
 * [new tag]         0.7        -> 0.7
 * [new tag]         0.7.1      -> 0.7.1
 * [new tag]         0.8        -> 0.8
 * [new tag]         0.8.1      -> 0.8.1
 * [new tag]         0.9        -> 0.9
 * [new tag]         0.9.1      -> 0.9.1
 * [new tag]         0.9.2      -> 0.9.2
 * [new tag]         0.9.3      -> 0.9.3
 * [new tag]         0.9.4      -> 0.9.4
 * [new tag]         0.9.5      -> 0.9.5
 * [new tag]         0.9.8      -> 0.9.8
 * [new tag]         0.9.9      -> 0.9.9
 * [new tag]         1.0.0      -> 1.0.0
 * [new tag]         1.0.1      -> 1.0.1
 * [new tag]         1.0.2      -> 1.0.2
 * [new tag]         1.0.3      -> 1.0.3
 * [new tag]         1.0.4      -> 1.0.4
 * [new tag]         1.0.5      -> 1.0.5
 * [new tag]         1.0.6      -> 1.0.6
 * [new tag]         1.0.7      -> 1.0.7
 * [new tag]         1.0.8      -> 1.0.8
 * [new tag]         1.0.9      -> 1.0.9
 * [new tag]         1.1.0      -> 1.1.0
 * [new tag]         1.1.1      -> 1.1.1
 * [new tag]         1.1.10     -> 1.1.10
 * [new tag]         1.1.11     -> 1.1.11
 * [new tag]         1.1.12     -> 1.1.12
 * [new tag]         1.1.13     -> 1.1.13
 * [new tag]         1.1.2      -> 1.1.2
 * [new tag]         1.1.3      -> 1.1.3
 * [new tag]         1.1.4      -> 1.1.4
 * [new tag]         1.1.5      -> 1.1.5
 * [new tag]         1.1.6      -> 1.1.6
 * [new tag]         1.1.7      -> 1.1.7
 * [new tag]         1.1.8      -> 1.1.8
 * [new tag]         1.1.9      -> 1.1.9
 * [new tag]         1.2.0      -> 1.2.0
 * [new tag]         1.2.1      -> 1.2.1
 * [new tag]         1.2.2      -> 1.2.2
 * [new tag]         1.2.3      -> 1.2.3
 * [new tag]         1.2.4      -> 1.2.4
 * [new tag]         1.2.5      -> 1.2.5
 * [new tag]         1.2.6      -> 1.2.6
HEAD is now at af463a0 formula_installer: never build dependency bottles.
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 4495, done.
remote: Compressing objects: 100% (4286/4286), done.
remote: Total 4495 (delta 34), reused 467 (delta 13), pack-reused 0
Receiving objects: 100% (4495/4495), 3.57 MiB | 107.00 KiB/s, done.
Resolving deltas: 100% (34/34), done.
Tapped 4284 formulae (4,540 files, 11.1MB)
==> Cleaning up /Library/Caches/Homebrew...
==> Migrating /Library/Caches/Homebrew to /Users/idevz/Library/Caches/Homebrew...
==> Deleting /Library/Caches/Homebrew...
Already up-to-date.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate user behaviour analytics.
Read the analytics documentation (and how to opt-out) here:
  http://docs.brew.sh/Analytics.html

==> Next steps:
- Run `brew help` to get started
- Further documentation:
    http://docs.brew.sh

效率工具

Alfred 3

虽然 MacX 本身其实就支持 workflow 的定制,也能通过 Spotlight Search 来达到快速启动 APP 的作用,但是我个人还是喜欢 Alfred 的高可定制,强大的社区,多样的 workflow。本次安装是直接用了之前的 workflow。

安装 Alfred

  1. Alfred 的 workflow 功能是需要单独购买 PowerPack 才能启用的,但是我一直都是用的破解版,7do 下载。
  2. 导入之前收集的 workflow(chrome、dev doctor、GoogleSearch、New File、Youdao),在导入 Youdao 的时候,报了系统兼容性错误,不过跟着错误提示进行了修正,很简单就解决了(安装 Fixum workflow,运行后,自动修复)。
  3. 修改 > 打开的终端,默认是系统默认的 Terminal,通过修改脚本,改成我习惯的 ITerm
on alfred_script(q)
	if application "iTerm2" is running or application "iTerm" is running then
		run script "
			on run {q}
				tell application \":Applications:iTerm.app\"
					activate
					try
						select first window
						set onlywindow to false
					on error
						create window with default profile
						select first window
						set onlywindow to true
					end try
					tell the first window
						if onlywindow is false then
							create tab with default profile
						end if
						tell current session to write text q
					end tell
				end tell
			end run
		" with parameters {q}
	else
		run script "
			on run {q}
				tell application \":Applications:iTerm.app\"
					activate
					try
						select first window
					on error
						create window with default profile
						select first window
					end try
					tell the first window
						tell current session to write text q
					end tell
				end tell
			end run
		" with parameters {q}
	end if
end alfred_script

Unclutter

Unclutter 提供了三个随时可用的功能“临时文件、临时随手记、剪贴板历史”,我最常用的是后两者,随时可以把一些临时的记忆碎片备忘在临时随手笔记里,剪贴板历史记录了你最近的剪贴历史,方便快速调用,甚至是对剪贴板进行编辑。

科学上网

之前搭建了一个 shadowsocks 的代理服务,这次直接用了。

安装 shadowsocks-mac-dmg

shadowsocks,安装后进行配置,相关配置必须与服务端 /etc/shadowsocks.json 中的配置一致。 新电脑还没有翻墙,无法安装谷歌浏览器翻墙扩展 SwitchyOmega,只能搜点 hosts 先翻墙把扩展装上。

娱乐 APP

Vox

MacOSX 系统保护

OSX 是我最喜欢的系统之一,本着安全第一的问题,Mac 并不允许你对一些系统级别的路径做修改,但是也不是无法突破。 重启系统,当启动的时候我们同时按下cmd+r进入Recovery模式,之后选择实用工具 => 终端,在终端输入如下命令,接口文件系统的锁定,并且重启电脑:

$ csrutil disable
$ reboot

安全第一,修改完后,记得恢复。

comments powered by Disqus