网站首页 > 技术教程 正文
下载地址:
http://nginx.org/en/download.html
下载完成后解压
?
直接cmd到本路径下
然后用命令启动(也可以直接点击Nginx直接启动)
启动
直接点击Nginx目录下的nginx.exe 或者 cmd运行start nginx
关闭
nginx -s stop 或者 nginx -s quit
stop表示立即停止nginx,不保存相关信息
quit表示正常退出nginx,并保存相关信息
重启(因为改变了配置,需要重启)
nginx -s reload
启动完成后可以先试试输入localhost访问,如果出现nginx启动界面说明启动正常
接下来修改配置:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
upstream localtomcat { #服务器集群名字,这里我用本地模拟
# least_conn;//负载策略
server 192.168.50.111:8080 fail_timeout=30s; #localhost时会自动切换,ip时不自动
server 192.168.50.111:8081 fail_timeout=30s;
server 192.168.50.111:8082 fail_timeout=30s;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
# location / {
# root html;
# index index.html index.htm;
# proxy_pass http://localtomcat;
#}
# 所有动态请求都转发给tomcat处理
location /so/{ #此处配置rest接口代理
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_pass http://localtomcat; #这里与上面配置的upstream 名字要相同
}
#静态文件交给nginx处理
location ~ .*\.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$
{
root E:\2; #静态资源路径
}
#静态文件交给nginx处理
location ~ .*\.(js|css)?$
{
root E:\2;
}
#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;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
猜你喜欢
- 2024-10-10 如何使用 Nginx 搭建一个具有缓存功能的反向代理服务呢?
- 2024-09-16 Windows使用nginx时,端口被占用怎么办?
- 2024-09-16 使用nginx对视频、音频、图片等静态资源网址,加token签权
- 2024-09-16 快速建立php的Windows开发环境(win10搭建php环境)
- 2024-09-16 windows下php开发环境php+nginx单步安装
- 2024-09-16 Windows+php7+nginx1.14+apache+mysql配置
- 2024-09-16 在windows环境下 nginx + .net core 3.1 实现反向代理和负载均衡
- 2024-09-16 如何解决Nginx服务器,启动成功,访问无效
- 2024-09-16 超强windows10稳定Nginx绿色环境,可无限自定义PHP和mysql版本、同时运行N个版本
- 2024-09-16 windows服务器配置nginx日志分割(nginx 日志配置)
你 发表评论:
欢迎- 最近发表
-
- Linux新手必看:几种方法帮你查看CPU核心数量
- linux基础命令之lscpu命令(linux中ls命令的用法)
- Linux lscpu 命令使用详解(linux常用ls命令)
- 如何查询 Linux 中 CPU 的数量?这几个命令要知道!
- 在linux上怎么查看cpu信息(linux如何查看cpu信息)
- 查看 CPU 的命令和磁盘 IO 的命令
- 如何在CentOS7上改变网卡名(centos怎么改网卡名字)
- 网工必备Linux网络管理命令(网工必备linux网络管理命令是什么)
- Linux 网络命令知多少(linux 网络 命令)
- Linux通过命令行连接wifi的方式(linux命令行连接无线网)
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)