公司配的电脑也曾经应用了一年多了,期间也降级了零碎,应用了 beta 版的MacOS 12,体验也还是不错的,但因为应用的工夫也比拟久了,零碎缓存占了一半,并且还删不掉,以及电脑时不时卡顿后主动重启。所以就趁着春节把系统重装一下,晋升下应用体验。
1、装置 Xcode、Xcode Command Line Tools
Xcode 是苹果出品的蕴含一系列工具及库的开发软件。目前最新版本是 13.2.1 能够通过App Store 装置,其次要目标是防止装置其他软件提醒更新 Xcode,软件有 12G 之大,还是找个网好点的中央装置吧。
Xcode Command Line Tools 作为 Xcode 的一部分,蕴含了 GCC 编译器。在命令行中执行以下命令即可装置:
xcode-select --install
间接点击装置,而后期待装置实现
xcode-select -p返回以下示意装置胜利/Applications/Xcode.app/Contents/Developer
2.装置 Homebrew
HomeBrew
是 macOS 软件包管理器,用来装置、降级以及卸载罕用的软件
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
或者应用国内源
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
3. 装置 iTerm2
iTerm2 是 MAC 下最好的终端工具(没有之一)以及配合oh-my-zsh 及其插件,将是弱小的神器
下载 iTerm2,关上会提醒挪动到 Application,或者在 Finder 中,将 iTerm 拖拽进入 Application 文件夹中。这样,你能够在 Launchpad 中启动 iTerm2。
3.1 装置 oh-my-zsh
oh-my-zsh
Mac 自带 zsh 版本较低,能够装置最新版 brew install zsh
上面装置 oh-my-zsh
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
iTerm2 的界面霎时变清新了
换个主题,我比拟喜爱上面这个主题agnoster.zsh-theme
还有各种主题自行抉择
各种主题
sudo vim ~/.zshrc //关上这个配置文件ZSH_THEME="robbyrussell" 找到这行主题配置ZSH_THEME="agnoster" 更换成agnoster的主题
这个主题须要装置一个字体,能力失常显示 Powerline fonts
git clone https://github.com/powerline/fonts.git --depth=1cd fonts./install.shcd ..rm -rf fonts
preferences > profiles > colors 批改配色
preferences > profiles > text 抉择 fria mono for powerline 字体
cd ~/.oh-my-zsh/themes //进入主题文件夹cp agnoster.zsh-theme myagnoster.zsh-theme //复制一份vim myagnoster.zsh-theme 关上 ## Main promptbuild_prompt() { RETVAL=$? prompt_status prompt_virtualenv #prompt_context prompt_dir prompt_git prompt_hg prompt_end}只需把prompt_context用#正文掉即可 而后关上.zshrc ZSH_THEME="agnoster" 》 ZSH_THEME="myagnoster" 改成这样就能够了 这样做的起因是防止降级有抵触
3.2 插件
oh my zsh
自带插件
Oh My Zsh 自身自带了很多插件,比方 git,插件目录: ~/.oh-my-zsh/plugins
我次要应用的两个是:
1、命令高亮显示 [zsh-syntax-highlighting
]https://github.com/zsh-users/...)
2、主动补全命令 zsh-autosuggestions
git clone 到本地
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestionsgit clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
配置
sudo vim ~/.zshrcplugins=(git zsh-autosuggestions zsh-syntax-highlighting)Source ~/.zshrc
3.3 iterm 快捷键
open . 在当前目录下关上finder⌘ + return 全屏⌘ + f 所查找的内容会被主动复制⌘ + d 横着分屏 / ⌘ + shift + d 竖着分屏令⌘ + / 光标地位⌘ + r 只是换到新一屏,不会像 clear 一样创立一个空屏ctrl + u 革除以后行ctrl + a 到行首ctrl + e 到行尾ctrl + w 删除光标之前的单词ctrl + k 删除到文本开端⌘ + alt + 方向键 切换屏幕(用于hotkey window)⌘ + 方向键 切换tabctrl + _ Undoctrl + y Paste the last thing to be cut
4. 装置 PHP、Composer、GO、Nginx
macOS 12 零碎不会默认装置 PHP 和 GO,所以咱们须要自行装置。
brew install php composer go nginx // 应用 brew 装置非常简单# composer 设置本地仓库门路composer config repositories.arunfung path ../shop
4.1. 装置 Laravel Valet
valet
是 laravel
官网提供的一个开发环境,次要劣势就是简略不便,开发 PHP 我的项目就足够应用。(装置 valet
需提前装置 composer 和 php)。
composer global require laravel/valet //先获取我的项目valet install //而后装置
增加环境变量:装置好了 valet 之后,咱们须要将 valet 增加环境变量中能力应用对应指令
sudo vim ~/.zshrc# 增加到文件最初export PATH="$PATH:$HOME/.composer/vendor/bin"source ~/.zshrc
在家目录创立Sites文件夹,之后所有我的项目都放在这个文件夹中,拜访的话也是文件夹名+.test就能够了
mkdir ~/Sitescd ~/Sitesvalet park //将这个目录设置为我的项目仓库valet path //查看valet 仓库门路这样就能够拜访相似 http://blog.test 的域名# 如需切换不同 PHP 版本你能够这样切换valet use php@7.2valet use php
9. 装置 Redis、Etcd、MySQL、Nsq等根底组件
brew install redis etcd nsq mysql当初默认版本的 MySQL 曾经是8了,如果5.7版本就装置制订版本即可。退出开机自启ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
MySQL 配置明码
//运行mysql_secure_installation
mysql_secure_installation Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD PLUGIN can be used to test passwords //明码验证插件,为了进步安全性,须要验证明码and improve security. It checks the strength of password // 它会查看明码的强度and allows the users to set only those passwords which are //只容许用户设置足够平安的明码secure enough. Would you like to setup VALIDATE PASSWORD plugin? //你确定要装置验证明码插件吗? Press y|Y for Yes, any other key for No: y //确定装置 There are three levels of password validation policy: //三个等级的验证策略 LOW Length >= 8 //最小长度大于等于8个字符MEDIUM Length >= 8, numeric, mixed case, and special characters //数字,字母,特殊字符 混合,具体的应该是至多1个数字,1个字母,1个特殊字符,长度不超过32个字符STRONG Length >= 8, numeric, mixed case, special characters and dictionary file // 最严格,加上了,字典文件 Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 //这里我抉择0最简略的,Please set the password for root here. New password: //输出明码 Re-enter new password: //反复输出明码 Estimated strength of the password: 50 //明码强度的评级Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y //是否应用刚输出的明码?By default, a MySQL installation has an anonymous user, //默认状况下,MySQL有一个匿名用户,allowing anyone to log into MySQL without having to have //这个匿名用户,不用有一个用户为他们创立,匿名用户容许任何人登录到MySQL,a user account created for them. This is intended only for //这只是为了不便测试应用testing, and to make the installation go a bit smoother.You should remove them before moving into a production //在正式环境应用的时候,倡议你移除它environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y //提醒移除匿名用户Success. Normally, root should only be allowed to connect from //个别状况下,root用户只容许应用"localhost"形式登录,'localhost'. This ensures that someone cannot guess at the root password from the network. // 以此确保,不能被某些人通过网络的形式拜访 Disallow root login remotely? (Press y|Y for Yes, any other key for No) : no //不容许root远程登陆? ... skipping.By default, MySQL comes with a database named 'test' that //默认状况下,MySQL数据库中anyone can access. This is also intended only for testing, //这也仅仅是为了测试and should be removed before moving into a production // 在正式环境下,应该移除掉environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y //确认删除test数据库? - Dropping test database...Success. - Removing privileges on test database...Success. Reloading the privilege tables will ensure that all changesmade so far will take effect immediately. //刷新权限表,以确保所有的批改能够立即失效 Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y //确认刷新Success. All done!