win运行nginx

1,下载nginx
2,在conf下修改nginx.conf
3,,运行nginx.exe nginx闪退属于正常,启动成功失败都会闪退

		# 在这儿配置多个服务器
        upstream web_app{
            server 127.0.0.1:80;
            server 127.0.0.1:8080;
        }
		server {
			#设置nginx端口
			listen       8089;
			server_name  localhost;
			#设置tomcat项目目录
					location ~ \.(html|js|css|png|gif)$ {  
						root F:/Software/apache-tomcat-7.0.68/webapps/meididi;  
					}  

配置事例


#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 web_app{
            server 127.0.0.1:80;
            server 127.0.0.1:8080;
        }
    server {
		#设置nginx端口
        listen       8089;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
		#设置tomcat地址
        location / {
            proxy_pass http://web_app; 
        }
		#设置tomcat项目目录
		location ~ \.(html|js|css|png|gif)$ {  
			root F:/Software/apache-tomcat-7.0.68/webapps/meididi;  
		}  
        #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;
    #    }
    #}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 Windows 10 上使用 Nginx 访问 HTML 页面,你需要先安装 Nginx,并将 HTML 页面放置在 Nginx 的默认网站目录或指定的网站目录中。以下是在 Windows 10 上使用 Nginx 访问 HTML 页面的步骤: 1. 下载 Nginx Windows 版本 你可以从 Nginx 官网下载适用于 Windows 的 Nginx 版本,下载完成后解压缩到指定目录。 2. 配置 Nginx 进入 Nginx 安装目录下的 `conf` 目录,打开 `nginx.conf` 配置文件,找到 `http` 部分,在其中添加以下配置: ``` server { listen 80; server_name localhost; location / { root html; # 指定网站目录 index index.html index.htm; } } ``` 该配置将 Nginx 监听 80 端口,并将域名 `localhost` 映射到网站目录 `html`,当访问 `localhost` 时,将会自动寻找该目录下的 `index.html` 或 `index.htm` 文件作为默认页面。 3. 放置 HTML 页面 将 HTML 页面放置在 `html` 目录下,例如,将 `index.html` 放置在 `nginx-1.21.1\html` 目录下。 4. 启动 NginxNginx 安装目录下的 `sbin` 目录中找到 `nginx.exe` 文件,双击运行该文件启动 Nginx。 5. 访问 HTML 页面 在浏览器中输入 `http://localhost`,即可访问 `index.html` 页面。 注意:如果你希望通过局域网中的其他计算机访问 HTML 页面,你需要将 Nginx 的防火墙端口(默认为 80)添加到 Windows 防火墙的例外规则中,并将计算机的防火墙设置为允许访问该端口。另外,你还需要通过计算机的 IP 地址或域名来访问该页面。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值