一:Nginx介绍
二:Nginx配置
Nginx可以充当虚拟主机
server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root G:programweb-demohtml; index index.html index.htm; } location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ { root G:programweb-demo; if (-f $request_filename) { expires 1d; break; } } location ~ .*.(js|css)$ { root G:programweb-demo; if (-f $request_filename) { expires 1d; break; } } location ~* .(eot|ttf|ttc|otf|eot|woff|woff2|svg)$ { root G:programweb-demo; add_header Access-Control-Allow-Origin *; } location ~ (.*.json) { root G:programweb-demo; error_page 405 =200 $1; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ .php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ .php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /.ht { # deny all; #} }
Nginx-反向代理配置
Nginx-负载均衡配置
Nginx 虚拟主机配置 通过域名
Nginx 常用命令
启动Nginx start Nginx
关闭Nginx Nginx -s stop
重启配置文件 nginx -s reload
快速停止或关闭Nginx:nginx -s stop
正常停止或关闭Nginx:nginx -s quit