如何在Windows环境配置 Nginx?
AI 概述
部署文档结构注意事项NGINX 相关命令
部署
1、首先,从官网下载 Nginx 包,版本自己选择,官网地址:传送门
2、然后,选择 Windows 版本的安装包进行下载(大家根据自己实际情况下载对应版本),根据图片描述,最新版是 1.23.1 (具体看当前官网),稳定版是 1.22.0 (具体看当前官网):
3、我们选...
目录
文章目录隐藏
部署
1、首先,从官网下载 Nginx 包,版本自己选择,官网地址:传送门
2、然后,选择 Windows 版本的安装包进行下载(大家根据自己实际情况下载对应版本),根据图片描述,最新版是 1.23.1 (具体看当前官网),稳定版是 1.22.0 (具体看当前官网):

3、我们选择合适的版本下载到本地后,用解压程序进行解压,得到一个文件夹,将文件夹复制到指定目录就完成了安装,解压后得到的 .exe 文件不要双击!
注意:一定不要直接双击 nginx.exe,这样会导致修改配置后重启、停止 nginx 无效,需要手动关闭任务管理器内的所有 nginx 进程,再启动才可以。
4、启动 Nginx
# 进入 Nginx 所在目录 cd D:\nginx-1.xx.x # 启动 Nginx 服务 start nginx # 执行后会有一闪而过的信息,是正常的 # 查看任务进程是否存在,可使用以下命令 s 或打开任务管理器都行 tasklist /fi "imagename eq nginx.exe" # 日志路径 c:\nginx-1.xx.x\log
5、到浏览器访问 127.0.0.1:80,查看是否成功,看到以下页面表示成功:

文档结构

默认配置文件路径 D:/nginx-1.xx.x/conf/nginx.conf
#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;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#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;
# }
#}
}
注意事项
- Nginx 默认端口号为 80,若已被占用则无法启动,可在配置文件中修改端口号,修改配置后可执行命令检查配置是否合法。
- Nginx 文件夹路径不要包含中文。
NGINX 相关命令
以上关于如何在Windows环境配置 Nginx?的文章就介绍到这了,更多相关内容请搜索码云笔记以前的文章或继续浏览下面的相关文章,希望大家以后多多支持码云笔记。
声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权/违法违规/事实不符,请将相关资料发送至 admin@mybj123.com 进行投诉反馈,一经查实,立即处理!
重要:如软件存在付费、会员、充值等,均属软件开发者或所属公司行为,与本站无关,网友需自行判断
码云笔记 » 如何在Windows环境配置 Nginx?
如若内容造成侵权/违法违规/事实不符,请将相关资料发送至 admin@mybj123.com 进行投诉反馈,一经查实,立即处理!
重要:如软件存在付费、会员、充值等,均属软件开发者或所属公司行为,与本站无关,网友需自行判断
码云笔记 » 如何在Windows环境配置 Nginx?

微信
支付宝