MacOS_Web服务器学习#
MacOS_Web服务器学习#
一、前言#
资料来源
MacOS 自带
tomcat和apache,但是建议都用brew重新下载进行额外的管理which -a apache which apache查找用Homebrew管理的软件的安装路径(以
tomat为例)/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"brew list tomcat
二、tomcat#
1、tomcat的安装#
brew install tomcat2、tomcat的开启/关闭/重启#
- 进入tomcat安装目录下的
libexec/bin,执行里面对应的*.sh
三、httpd#
1、httpd的安装#
brew install httpd2、httpdhttpd的启动#
apachectl start3、httpd的停止#
apachectl stop4、httpd的重启#
apachectl restart5、httpd的相关备注和说明#
5.1、默认占用系统8080端口,俗称apache#
5.2、因为是只读所以需要加写权限,然后将默认的8080更改为8081,以及80更改为81(防止其他程序抢夺端口)#
open /etc/apache2/httpd.conf<IfDefine SERVER_APP_HAS_DEFAULT_PORTS>
Listen 8081
</IfDefine>
<IfDefine !SERVER_APP_HAS_DEFAULT_PORTS>
Listen 81
</IfDefine>四、nginx#
1、nginx的安装#
brew install nginx2、nginx的启动#
nginx3、nginx的关闭#
相当于先查出nginx的进程id再使用kill命令强制杀掉进程
nginx -s stop4、nginx的重启#
nginx -s reload5、nginx的停止#
待nginx进程处理任务完毕进行停止
nginx -s quit6、重读nginx日志文件#
nginx -s reopen7、nginx的相关备注和说明#
7.1、默认占用系统8080端口#
7.2、如果端口被占用则报错如下:#
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
nginx: [emerg] still could not bind()7.3、查询#
查询某个软件(比如:
Nginx)的进程号ps aux|grep nginx查询端口占用情况(比如查询
8080端口)lsof -i tcp:8080查询由
brew管理的nginx的安装目录brew list nginx查询
nginx的配置文件目录nginx -t(安装目录 ≠ 配置文件目录)