Loading

Mac 使用笔记

用于新买的电脑常用软件安装及配置。

安装brew

brew 又叫Homebrew,是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件, 只需要一个命令, 非常方便。brew类似ubuntu系统下的apt-get的功能。

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

安装常用命令行软件

brew install htop git wget curl lrzsz 

brew命令

brew install 安装软件
brew uninstall 卸载软件
brew search 搜索软件
brew list           列出已安装的软件
brew update     更新brew
brew home       用浏览器打开brew的官方网站
brew info         显示软件信息
brew deps        显示包依赖

brew使用加速镜像

默认的源实在是太慢了。我们可以使用国内源。

清华大学源使用说明:

替换现有上游

git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

brew update

复原

git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git

git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git

brew update

终端美化

iTerm2

安装 iTerm2 是一款完全免费的,专为 Mac OS 用户打造的命令行应用。功能比自带的强。

https://www.iterm2.com/

Zsh

终端采用zshoh-my-zsh,既美观又简单易用。

brew install zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

所以这时的zsh 基本已经配置完成,你需要一行命令就可以切换到 zsh 模式,终端下输入zsh切换,输入bash切回去。

安装常用应用软件

安装 微信、网易云音乐、钉钉、Foxmail、网易邮箱大师、Foxit Reader、迅雷、金山词霸、万年历、腾讯电脑管家 等软件的方法:
1、直接去App Store免费排行榜或者搜索下载:
2、去百度软件中心下载:http://rj.baidu.com/soft/mac_list
3、PC6苹果网_苹果软件游戏下载门户网站 http://www.pc6.com/apple/

安装搜狗拼音输入法
https://pinyin.sogou.com/mac/?f=imemac&f=index&r=2015

MAC应用无法打开或文件损坏的处理方法

在MAC下安装一些软件时提示"来自身份不明开发者或文件损坏",其实这是MAC新系统启用了新的安全机制。

默认只信任 Mac App Store 下载的软件和拥有开发者 ID 签名的应用程序。
换句话说就是 MAC 系统默认只能安装靠谱渠道(有苹果审核的 Mac App Store)下载的软件或被认可的人开发的软件。

出现这个问题的解决方法有2种:

最简单的方式:
1、按住Control后,再次点击软件图标,即可;
2、修改系统配置:系统偏好设置... -> 安全性与隐私;
3、修改为任何来源。如果没有这个选项的话(macOS Sierra 10.12),打开终端,执行

sudo spctl --master-disable

即可。

安装其它软件

Sublime Text 3

https://download.sublimetext.com/Sublime Text Build 3143.dmg
安装扩展的方法:http://www.cnblogs.com/52fhy/p/5426528.html

Phpstrom

https://download.jetbrains.com/webide/PhpStorm-2019.1.dmg
拓展资源:http://idea.lanyus.com/help/help.html

Goland

https://download.jetbrains.com/webide/PhpStorm-2019.1.dmg

Office 2016 for mac

https://www.jianshu.com/p/3c5dc4f3c96e

建议用WPS。

WPS

https://www.wps.cn/product/wpsmac/

postman

下载地址:http://www.pc6.com/mac/224724.html
官网的很慢,不建议。

Charles

Charles是一款用于HTTP信息抓包工具。详见:http://xclient.info/s/charles.html?_=943d23fec6ed754aebabe2e0f3947968

Docker

Mac无法像Ubuntu那样直接安装docker服务,需要借助VirtualBox。

需要先安装VirtualBox:http://sw.bos.baidu.com/sw-search-sp/software/5b5bc0c6f9ac9/VirtualBox-5.1.30-OSX.dmg
然后:

brew install docker-machine 

如果有本地的boot2docker.iso则执行:

docker-machine create --driver virtualbox --virtualbox-boot2docker-url=/Users/yjc/.docker/machine/cache/boot2docker.iso  default

没有本地的则执行(会很慢):

docker-machine create --driver virtualbox  default

然后查看虚拟机列表:

docker-machine ls

运行虚拟机(运行前建议打开VirtualBox虚拟机,设置default虚拟机的共享目录,例如/work,本地无该目录没有则自行新建):

docker-machine start

进入虚拟机:

docker-machine ssh

还有一种办法就是直接下载Docker.dmg,352M,会包含VirtualBox、docker-machine软件。上面的办法是按需下载。

Sketch

Sketch是轻量易用的矢量设计工具。详见 http://xclient.info/s/sketch.html?_=943d23fec6ed754aebabe2e0f3947968

Axure RP

原型图设计神器。

版本:Axure+RP+83312.dmg,地址:https://www.jianshu.com/p/4b78a6d9818c

Sequel Pro

免费的数据库管理神器。直接官网下载:http://www.sequelpro.com/

注:官网正式版已经很久没有更新了,存在一个BUG:关闭TAB会崩溃。可以下载测试版,试了很稳定:https://sequelpro.com/test-builds。

Navicat Premium for mac是一个可多重连接的数据库管理工具,支持的数据库有: MySQL、SQL Server、SQLite、Oracle 及 PostgreSQL。

详见 http://xclient.info/s/navicat-premium.html?_=943d23fec6ed754aebabe2e0f3947968

Free Download Manager

简称fdm。很好用的下载工具,下载github的release报特别快。
https://www.freedownloadmanager.org/zh/

CHM Reader

CHM阅读器Mac版是Mac平台上的一款CHM文件阅读器,CHM阅读器Mac版带着全新的UI,深受欢迎的CHM阅读器Mac版重新登陆Mac平台。

http://www.pc6.com/mac/490797.html

Beyond Compare

https://www.jianshu.com/p/596b4463eacd

calibre

Calibre Mac版是用于Mac系统的一个“一站式”的电子书解决方案,它可以全面满足你的电子书需求。Calibre Mac版是免费的,源代码开放,拥有跨平台的设计,可在Linux, OS X和Windows操作系统中运行。
http://www.pc6.com/mac/111232.html

Dr. Unarchiver

Dr. Unarchiver它是在一款即简单又好用的正版的Mac解压缩软件。在正版的Mac解压缩软件中,免费又好用的解压软件确实是非常少见的,它像解压缩界一股清流。
https://dr-unarchiver.en.softonic.com/mac

DropDMG

Dropdmg for mac是Mac os平台上的一款帮助用户快速打包DMG文件的Mac文件管理软件。
http://www.pc6.com/mac/128741.html

Redis

brew install redis

# 启动
brew services start redis
# 或者
redis-server /usr/local/etc/redis.conf

MAC使用homeBrew安装Redis - 简书
https://www.jianshu.com/p/e1e5717049e8

安装PHP7

安装 php7.1

brew install php@7.1

安装完成后注意看终端输出:


The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/7.1/

php@7.1 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have php@7.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.zshrc

For compilers to find php@7.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/php@7.1/lib"
  export CPPFLAGS="-I/usr/local/opt/php@7.1/include"


To have launchd start php@7.1 now and restart at login:
  brew services start php@7.1
Or, if you don't want/need a background service you can just run:
  php-fpm

所以我们按照提示在环境变量文件里配置上:

# 配置默认的php
export PATH="/usr/local/opt/php@7.1/bin:$PATH"
export PATH="/usr/local/opt/php@7.1/sbin:$PATH"

执行:source ~/.zshrc 即可生效。

后续安装PHP扩展如果提示找不到php.h可以执行:

export LDFLAGS="-L/usr/local/opt/php@7.1/lib"
export CPPFLAGS="-I/usr/local/opt/php@7.1/include"

pecl安装

# 下载
curl -O https://pear.php.net/go-pear.phar

# 安装及配置
sudo php -d detect_unicode=0 go-pear.phar

上述第二条命令会输出类似:

1. Installation base ($prefix)                   : /usr/local/Cellar/php@7.1/7.1.32
 2. Temporary directory for processing            : /tmp/pear/install
 3. Temporary directory for downloads             : /tmp/pear/install
 4. Binaries directory                            : /usr/local/Cellar/php@7.1/7.1.32/bin
 5. PHP code directory ($php_dir)                 : /usr/local/Cellar/php@7.1/7.1.32/share/pear
 6. Documentation directory                       : /usr/local/Cellar/php@7.1/7.1.32/docs
 7. Data directory                                : /usr/local/Cellar/php@7.1/7.1.32/data
 8. User-modifiable configuration files directory : /usr/local/Cellar/php@7.1/7.1.32/cfg
 9. Public Web Files directory                    : /usr/local/Cellar/php@7.1/7.1.32/www
10. System manual pages directory                 : /usr/local/Cellar/php@7.1/7.1.32/man
11. Tests directory                               : /usr/local/Cellar/php@7.1/7.1.32/tests
12. Name of configuration file                    : /usr/local/etc/php/7.1/pear.conf

1-12, 'all' or Enter to continue:

会显示各项所在的路径,后续发现有被改动可以参考修改回来。

默认不需要修改,直接一路回车到最后,然后查看版本:

pecl version

如果第2、3项的路径需要修改,也可以单独执行下列命令修改:

pecl config-set php_dir /usr/local/Cellar/php@7.1/7.1.32/install

注意:需要确保/usr/local/Cellar/php@7.1/目录可写,所属者是当前用户。如果不是,可以使用下列命令修改,否则后续扩展无法安装:

sudo chown -R  `whoami`:staff /usr/local/Cellar/php@7.1/7.1.32/

使用pecl安装扩展

Mac下使用pecl正确安装扩展的前提:

1、/usr/local/Cellar/php@7.1/7.1.32/目录可写

2、php.ini配置的extension_dir是与php-config --extension-dir的输出是相同的,如果不是,请配置extension_dir

使用 pecl安装扩展完成后,会自动帮我们在 php.ini 启用扩展。

  • 安装redis
pecl install redis
  • 安装 swoole
pecl install swoole

# or
pecl install swoole-4.4.5
  • 安装 protobuf、grpc
pecl install protobuf grpc
  • 安装 其它
pecl install  msgpack xdebug mongodb seaslog yac yaf yaconf
  • 安装phalcon
wget https://github.com/phalcon/cphalcon/archive/v3.4.2.zip
unzip v3.4.2.zip && cd cphalcon-3.4.2/build/
./install

或者:

brew tap tigerstrikemedia/homebrew-phalconphp
$ brew install php71-phalcon

NTFS支持

Mounty for NTFS 完全免费,可以完美实现 Mac 系统对 NTFS 磁盘格式的读写,而且非常易用,不必学习繁琐的命令,对于只是偶尔使用U盘/移动硬盘的广大普通用户来说非常的实用!

安装:

brew cask install mounty

或者下载:http://enjoygineering.com/mounty/releases/Mounty.dmg

常见问题

1、dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
原因是应用程序依赖openssl 1.0.0版本,当前的版本可能是1.1.0版本。如果你的Mac里有对应版本,可以直接使用brew switch openssl 1.0.0切换。
查看电脑里的版本:

$ ls /usr/local/opt/openssl/lib/libssl.1.*
/usr/local/opt/openssl/lib/libssl.1.1.0.dylib

然后可以考虑降级版本:

brew uninstall openssl; brew uninstall openssl; brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb

这里面有历史版本:
https://mirrors.aliyun.com/homebrew/homebrew-bottles/bottles/

Mac资源站

1、精品MAC应用分享 http://xclient.info/s/
2、awesome-mac/README-zh.md at master · jaywcjlove/awesome-mac
https://github.com/jaywcjlove/awesome-mac/blob/master/README-zh.md
3、swift - dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib - Stack Overflow
https://stackoverflow.com/questions/59006602/dyld-library-not-loaded-usr-local-opt-openssl-lib-libssl-1-0-0-dylib

posted @ 2018-09-01 20:20  飞鸿影  阅读(1032)  评论(0编辑  收藏  举报