windows11系统安装nginx1.28.0
nginx作为一款轻量级、高性能的 Web 服务器和反向代理服务器。它以其卓越的处理高并发连接的能力、低内存消耗和高稳定性而闻名。本文以图文形式详细介绍nginx在windows11系统上的安装和初步配置使用。
nginx下载
官网下载nginx: download 选择当前稳定的windows版本进行下载(如下图所示)https://nginx.org/en/download.html

nginx安装
将下载好的文件(压缩包)解压到一个没有中文的目录下面即可

启动nginx
双击运行nginx.exe文件,此时黑色命令行弹窗会一闪而过

或者在导航栏输入cmd回车后,在命令行输入nginx.exe命令后,回车运行

出现图下黑色窗口,无法使用ctrl + c 命令关闭进程,也无法通过关闭命令行的方式关闭进程

访问nginx页面
在浏览器输入localhost:80或者本机ip:80,访问到如下页面代表nginx已经成功启动!

搜索nginx相关进程,出现的nginx相关进程全部右键结束任务即可

或者也可以在nginx根目录下进入cmd命令行,使用 nginx -s quit 命令停止nginx进程(完整有序的停止nginx)

或者也可以使用 nginx -s stop 命令停止nginx进程(快速停止nginx)

或者也可以使用 taskkill /f /t /im nginx.exe 命令杀死有关nginx的相关进程
taskkill是用来终止进程的
/f 强制终止
/t 终止指定的进程和任何由此启动的子进程
/im 指定的进程名称

修改监听端口号
可以在修改nginx根目录下面的conf文件夹里面的nginx.conf文件来修改监听端口号(默认配置的nginx监听的端口为80)

把这里改成想要设置的监听端口号即可

修改后保存文件

#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; #} } #定义集群 upstream mq660{ #web服务器信息 server 127.0.0.1:8088 weight=3; server 127.0.0.1:8099 weight=1; } server { listen 82; server_name localhost; location /{ # 代理的服务器地址 #proxy_pass http://127.0.0.1:8088; #集群 proxy_pass http://mq660; } } # 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服务,然后重启nginx服务后,访问ip:85即可出现nginx的页面

原文地址:https://blog.csdn.net/Tony1154/article/details/149323359

浙公网安备 33010602011771号