MacOS系统Web服务器

1.Apache

MacOS系统一般预装了Apache,我的机器是安装在/etc/apache2/目录中。

配置文件为:/etc/apache2/httpd.conf

Listen 8088

DocumentRoot "/Library/WebServer/Documents"

<Directory "/Library/WebServer/Documents">

</Directory>

apache命令:

#开启apache:  
sudo apachectl start
 
#重启apache:  
sudo apachectl restart
 
#关闭apache:  
sudo apachectl stop

2.Tomcat

配置文件位置:/usr/local/apache-tomcat-8.0.46/conf/server.xml

<Server port="8005" shutdown="SHUTDOWN">
    <Service name="Catalina">
        <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    </Service>
</Server>

tomcat命令:

cd /usr/local/apache-tomcat-8.0.46/bin
#开启tomcat:
sudo ./startup.sh

#关闭tomcat:
sudo ./shutdown.sh

3.Nginx

配置文件位置:/usr/local/etc/nginx/nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    #gzip  on;
    server {
        listen 8001;
        server_name  localhost;
        location / {
            #root   /usr/local/Cellar/nginx/1.17.2/dist;
            root   /Volumes/系统;
            try_files $uri $uri/ /index.html last;
            index  index.html index.htm;
            autoindex on; #开启目录浏览
            autoindex_format html; #以html风格将目录展示在浏览器中
            autoindex_exact_size off; #切换为 off 后,以可读的方式显示文件大小,单位为 KB、MB 或者 GB
            autoindex_localtime on; #以服务器的文件时间作为显示的时间
            charset utf-8,gbk;
        }
    }
    include servers/*;
}

nginx命令:

#开启nginx: 
nginx

#重启nginx: 
nginx -s reload

#关闭nginx: 
nginx -s quit
原文地址:https://www.cnblogs.com/asenyang/p/14156674.html