mac 开启 httpServer 服务

649 阅读1分钟

开启服务

sudo apachectl start // 启动apache 
cd 文件夹 // cd到要共享的文件夹内(如果不清楚路径,可以直接将要共享的文件夹拖拽入终端) 
python3 -m http.server // python3x 启动服务 后面可以加端口,如:python3 -m http.server 8081 
python -m SimpleHTTPServer // python2x 启动服务

mac默认安装了apache,随机启动会占用80端口,致使nginx启动不了,须要关闭apache(httpd)服务,取消随机启动

启动apache

sudo apachectl start

重启apache

sudo apachectl restart

中止apache

sudo apachectl stop

查询端口被谁占用了

sudo lsof -i:端口

关闭随机启动

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

开启随机启动

sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist