nginx 笔记

1. 下载

http://nginx.org/en/download....

2. 解压

3. 启动

start nginx  

或者双击nginx.exe
访问localhost:80

如果无法访问,检查80端口是否被占用

4. 关闭nginx

nginx目录下

./nginx.exe -s stop

5. root

默认根据路是html文件夹下
访问locahost/a/index.html时,查找的就是html目录下a/index.html

location /a {
            root   html;
            index  index.html index.htm;~~~~
        }

将根目录修改为html/helpcenter
访问localhost/a/index.html时,查找的就是html/helpcenter/a/index.html

location /a {
            root   html/helpcenter/;
            index  index.html index.htm;
        }

6. alias

同样的配置,访问localhost/a/index.html时,寻找的是html/helpcenter/index.html

location /a {
            alias   html/helpcenter/;
            index  index.html index.htm;
        }

7. listen

监听多个端口,对应同样的逻辑

server {
    listen       8000;
    listen       8080;

    location / {
        root   html;
        index  index.html index.htm;
}

监听多个端口,对应不同的逻辑

server {
    listen       8000;

    location / {
        root   html;
        index  index.html index.htm;
}
server {
    listen       8001;

    location / {
        root   html/a/;
        index  index.html index.htm;
}

你可能感兴趣的:(nginx)