nginx windows 下配置

 

1.下載nginxhtml

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

2.查看系統80端口占用狀況app

netstat -ano |findstr "80"tcp

若是是其餘軟件佔了端口號  直接關掉進程就OKide

 TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       4orm

 

若是端口占用是系統  server

net stop http 中止http 服務htm

下面的服務依賴於 HTTP Service 服務。
中止 HTTP Service 服務也會中止這些服務。blog

World Wide Web 發佈服務
SSDP Discovery
Print Spooler進程

你想繼續此操做嗎? (Y/N) [N]: Y

並禁用服務 

Sc config http start= disabled

中止後重啓電腦   發現80端口正常了   

啓動nginx      nginx.exe

啓動成功頁面

 

配置nginx 

 

打開 D:\nginx-1.16.0\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;
upstream xxx.xxx.com {
server 127.0.0.1:81;
}
server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
proxy_pass http://xxx.xxx.com;
}

#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;
}

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;
}

}



}

 

配置完成以後  nginx -s reload

 

 

 以後就能夠正常訪問了

 

啓動  net start http

 

C:\WINDOWS\system32>net start http
發生系統錯誤 1058。

沒法啓動服務,緣由多是已被禁用或與其相關聯的設備沒有啓動。

 

須要修改服務配置

sc config http start= demand & net start http

服務正常啓動  

相關文章
相關標籤/搜索