Windows系统下Nginx服务器的基本安装和配置方法介绍

这篇文章主要介绍了Windows系统下Nginx服务器的基本安装和配置方法,文中给出了一个配置文件的实例并作出了些说明,需要的朋友可以参考下
下载地址:http://nginx.org/download/nginx-1.2.4.zip
下载后直接解压到你的硬盘上,我的是d:\nginx
启动nginx

cd d:cd nginx-1.2.4start nginx
查看任务任务管理器里面会有nginx的进程
在浏览器输入http://127.0.0.1 此时会出现nginx的欢迎界面,说明启动nginx成功。百度收录批量查询

Welcome to nginx!If you see this page, the nginx web server is successfully installed and working. Further configuration is required.For online documentation and support please refer to nginx.org.Commercial support is available at nginx.com.Thank you for using nginx.
其他操作:

nginx -s stop // 停止nginxnginx -s reload // 重新加载配置文件nginx -s quit // 退出nginx
配置文件:

#user nobody; worker_processes 1;#启动的线程数:一本内核的数目*2 #错误的位置和级别 #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid;#pid进程文件的位置 events { worker_connections 1024;#每个进程的最大连接数 } http { include mime.types; default_type application/octet-stream; #nginx日志格式定义,在下面可以进行引用 #log_format main '$remote_addr - r e m o t e u s e r [ remote_user [ remoteuser[time_local] “KaTeX parse error: Expected 'EOF', got '#' at position 12: request" ' #̲ 'status b o d y b y t e s s e n t " body_bytes_sent " bodybytessent"http_referer” ’ # ‘“ h t t p u s e r a g e n t " " http_user_agent" " httpuseragent""http_x_forwarded_for”’; #access_log logs/access.log main;#日志路径 sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65;#请求时间 #gzip on;开启gzip压缩 #server为设置的虚拟机,可以设多个 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; # server_name localhost; # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_timeout 5m; # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 该资源内项目源码是个人的课程设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。
### 回答1: 在 Windows安装 nginx 比较简单,可以直接从官网下载安装包并进行安装。 1. 从 nginx 官网下载 Windows 版本的安装包(http://nginx.org/en/download.html) 2. 双击安装包并依次按照安装向导的提示进行安装。 3. 安装完成后,在命令行中输入 nginx,如果能看到“nginx 已成功启动”的提示,说明 nginx 安装成功。 配置 nginx: 1. 打开 nginx 安装目录下的 conf/nginx.conf 文件。 2. 修改配置文件中的相关配置,如服务器的地址、端口号等。 3. 保存配置文件。 4. 在命令行中输入 nginx -s reload,重新加载配置文件。 注意:具体配置内容因个人需求而异。 ### 回答2: WindowsNginx安装配置相对简单。下面是详细步骤: 1. 下载Nginx Windows版本的安装包,推荐到官网下载,地址为:http://nginx.org/en/download.html 2. 解压安装包,将解压后的文件夹重命名为nginx,并将其移动到C盘根目录。因为nginx默认会在C盘根目录寻找配置文件。 3. 进入nginx文件夹,打开conf目录下的nginx.conf文件,在开头添加如下代码,指定Nginx的运行目录: ```bash chdir c:/nginx/ ``` 4. 在nginx.conf文件中修改server块的配置,添加监听端口号和root目录,如下: ```bash server{ listen 80; server_name localhost; root html; index index.html index.htm; } ``` 这里的端口号可以根据实际需求修改,root目录则为Nginx的默认站点目录。 5. 启动nginx,在cmd命令行下输入: ```bash cd C:\nginx start nginx ``` 如果没有错误提示,则说明启动成功。 6. 在浏览器中输入localhost,如果看到Nginx的欢迎页面,则表示配置成功。 7. 关闭nginx,在cmd命令栏下输入: ```bash nginx -s stop ``` 注意:如果修改配置文件后需要重新启动Nginx,则输入: ```bash nginx -s reload ``` 总结:以上是WindowsNginx安装配置步骤,如果需要添加虚拟主机、负载均衡等功能,在nginx.conf文件中进行对应的配置即可。 ### 回答3: Nginx是一个高性能的HTTP和反向代理服务器。在Windows操作系统中,通过安装Nginx可以实现Web服务器的搭建以及各种代理和负载平衡操作。下面是WindowsNginx安装配置步骤。 一、下载Nginx 访问Nginx的官网,选择Windows版本的Nginx进行下载,下载后将文件解压到指定目录。 二、配置Nginx 1、进入到Nginx的目录中找到conf文件夹,这个文件夹中包含了Nginx配置文件。 2、打开nginx.conf文件,修改以下选项: 修改listen:将listen 80改为listen 8080,如果端口冲突,可以选择其他端口。 修改server_name:将server_name localhost改为server_name 你的域名,也可以使用IP地址。 修改root:将root html改为你的网站根目录。 3、将文件保存后,关闭文件。 三、启动Nginx服务 1、在cmd中进入到nginx.exe所在的文件夹中。 2、执行命令:nginx.exe -c conf/nginx.conf 提示nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions),说明80端口被占用,改成其他端口即可(如8080)。 3、打开浏览器,输入localhost:8080,就可以访问Nginx搭建的Web服务器了。 总结: 以上就是在Windows操作系统Nginx安装配置步骤。需要注意的是,配置文件中的选项对应的含义需要认真了解并修改,否则可能会造成配置错误或安全隐患。在运行之前还应当检查一下端口是否被占用,并选择一个空闲的端口,才可以正常启动Nginx服务器

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值