TracerLee / tracerlee.github.io

Personal blog written by Tracer
4 stars 0 forks source link

🖥️ Mac Tips #24

Open TracerLee opened 7 years ago

TracerLee commented 7 years ago

记录使用Mac电脑系统的技巧

快速显示桌面

command + F3

MissionControl

设置 - MissionControl,可以设置一些辅助的控制方式。

Charles

http://blog.csdn.net/tech4j/article/details/53509329

TracerLee commented 7 years ago

在终端使用ss代理通过ssh连接vps

如果是国内vps(阿里云等),一般使用ssh root@ip去连上vps是不会有什么大问题的,但是国外vps连接就要看节点速度了,甚至墙太高导致无法得到响应。 如果手上有一个ss可以科学上网,那又如何使用ss在终端代理连接vps呢

  1. 安装proxychains-ng
brew install proxychains-ng
  1. 编辑配置
vim /usr/local/etc/proxychains.conf

#注释最后一行,在后面新增一行,根据ss的socks5端口配置,我的是1086,最终如下
-------------------------------
#socks4         127.0.0.1 9050
socks5  127.0.0.1 1086
-------------------------------
  1. 由于OSX10.11的限制,需要拷贝一个ssh执行文件到其他地方,这里拷贝到~
cp /usr/bin/ssh ~
  1. 连接vps,完成任务!
proxychains4 ~/ssh root@ip
  1. 其他
# 可以给proxychain4起别名
alias pc='proxychains4'
# 之后这样子调用就可以了
pc ~/ssh root@ip

参考:

TracerLee commented 7 years ago

替换homebew源

替换现有上游

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

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

# 这一步需要一点时间,耐心等待
brew update

参考: https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/

TracerLee commented 7 years ago

使用ssh超时断开连接的处理方式

推荐在客户端新增配置解决此问题,方法如下:

vim ~/.ssh/config
Host *
    ServerAliveInterval 60

参考: Linux使用ssh超时断开连接的真正原因

TracerLee commented 6 years ago

Mac 安全性与隐私,增加任何来源

安装Mac软件有时候无法安装,显示已经损坏,是因为系统设置的权限问题

『允许从以下位置下载的应用』中若没有下图的『任何来源』,则会导致一些软件安装不了

激活此选项的方式:

  1. 打开终端(terminal)
  2. 输入sudo spctl --master-disable,系统提示输入密码,输入密码
  3. 重新打开设置项,发现『任何来源』有了
TracerLee commented 6 years ago

符号对照表格

TracerLee commented 6 years ago

指定窗口截图

command + shift + 4 ,然后按住空格键,会有一个相机出来,选中你要截图的窗口。

TracerLee commented 6 years ago

设置 Terminal 代理的方式

$ export http_proxy=http://127.0.0.1:1087 # 配置http
$ export https_proxy=http://127.0.0.1:1087 # 配置https
$ export socks5_proxy=socks5://127.0.0.1:1086 # 配置socks5

以上可以在当次当前窗口实现代理访问

以下可以长期使用

以 zsh 为例,存到 .zshrc 文件中

alias proxy='export socks5_proxy=socks5://127.0.0.1:1086;export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;'
alias unproxy='unset socks5_proxy http_proxy https_proxy'

source 生效

. ~/.zshrc 或 source ~/.zshrc

测试和使用

$ proxy
$ curl cip.cc
IP  : 35.189.*.*
地址  : 中国  台湾  彰化县
运营商 : cloud.google.com

数据二 : 美国 | 加利福尼亚州圣克拉拉县山景市谷歌公司

数据三 : 美国南卡罗来纳 | 谷歌

URL : http://www.cip.cc/35.189.*.*
$ unproxy
$ curl cip.cc
IP  : 61.242.*.*
地址  : 中国  广东  广州
运营商 : 联通

数据二 : 广东省广州市 | 联通

数据三 : 中国广东省广州市 | 联通

参考:

TracerLee commented 6 years ago

Mac 配置自带 PHP 环境和 Apache 服务器 (命令行)

启动 Apache

apachectl start

编辑 Apache 配置加载 PHP 模块

sudo vim /etc/apache2/httpd.conf
# 编辑 LoadModule php5_module libexec/apache2/libphp5.so 去除前面的 # 注释

打开浏览器输入localhost,看到It works!,表示已经启动了 Apache 服务器

新建一个phpinfo.php到 Apache 目录/Library/WebServer/Documents下面,内容如下:

<!-- phpinfo.php -->
<?php
phpinfo();
?>

打开浏览器输入localhost/phpinfo.php,返回一个 PHP 信息页面,表示已经成功将 PHP 环境运行在 Apache 服务器上面。