MacOS_Web服务器学习#

MacOS_Web服务器学习#

Jobs倾情奉献

一、前言#

  • 资料来源

  • MacOS 自带tomcatapache,但是建议都用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 tomcat

2、tomcat的开启/关闭/重启#

  • 进入tomcat安装目录下的libexec/bin,执行里面对应的*.sh

三、httpd#

1、httpd的安装#

brew install httpd

2、httpdhttpd的启动#

apachectl start

3、httpd的停止#

apachectl stop

4、httpd的重启#

apachectl restart

5、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 nginx

2、nginx的启动#

nginx

3、nginx的关闭#

相当于先查出nginx的进程id再使用kill命令强制杀掉进程

nginx -s stop

4、nginx的重启#

nginx -s reload

5、nginx的停止#

nginx进程处理任务完毕进行停止

nginx -s quit

6、重读nginx日志文件#

nginx -s reopen

7、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(安装目录 ≠ 配置文件目录)