整理工作中容易遗忘的小技巧和碰到的问题。
屏幕共享
打开 系统偏好设置 -> 共享 -> 屏幕共享。在另外的电脑打开 Finder -> 前往 -> 连接服务器 -> 输入 vnc://ip
访问。或者⌘+K
相关的远程控制s软件splashtop,teamviewer
找回Sierra允许”任何来源”的应用
sudo spctl --master-disable
屏幕截图
Command+shift+3
全屏截图,保存截图到桌面Command+shift+4
鼠标选定区域截图,保存截图到桌面
相关的扩展阅读:
如何重置 Mac 上的 NVRAM
Option + Command + P + R + Power
Apache
查看是否开启apache
服务 ps aux | grep httpd
或者 apachectl status
开启Apachesudo apachectl start
相关的设置目录 /etc/apache2/
扩展阅读
如何查看对于窗口的程序
sudo lsof -iTCP:80 | grep LISTEN
1 | ➜ apache2 sudo lsof -iTCP:80 | grep LISTEN |
sudo lsof -n -i4TCP:80 | grep LISTEN
查看当前所有监听的端口以及对应的Command和PID
1 | ➜ apache2 sudo lsof -nP -iTCP -sTCP:LISTEN |
安装nginx
1 | ➜ desktop brew install nginx |
不过试了一下,不是超级用户登陆,而是普通用户登陆,并且监听的端口在1024以下的(例如把默认的8080端口改为了80端口),nginx 开机是启动不了。因此,要 nginx 开机启动的话,需要给予它管理员权限:
sudo chown root:wheel /usr/local/Cellar/nginx/1.2.6/sbin/nginx
sudo chmod u+s /usr/local/Cellar/nginx/1.2.6/sbin/nginx
来自: http://dhq.me/mac-install-nginx-mysql-php-fpm
vagrant up 开启端口报错
==> homestead-7: Checking if box ‘laravel/homestead’ is up to date…
Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 27017 is already in use
on the host machine.
To fix this, modify your current project’s Vagrantfile to use another
port. Example, where ‘1234’ would be replaced by a unique host port:
config.vm.network :forwarded_port, guest: 27017, host: 1234
Sometimes, Vagrant will attempt to auto-correct this for you. In this
case, Vagrant was unable to. This is usually because the guest machine
is in a state which doesn’t allow modifying port forwarding. You could
try ‘vagrant reload’ (equivalent of running a halt followed by an up)
so vagrant can attempt to auto-correct this upon booting. Be warned
that any unsaved work might be lost.
➜ Homestead git:(master) ✗ sudo lsof -n -i4TCP:27017 | grep LISTEN
mongod 526 huixisheng 11u IPv4 0x40824e155718bce3 0t0 TCP 127.0.0.1:27017 (LISTEN)
原因homestead和mongod的端口冲突了