admin管理员组

文章数量:1567915


水香木鱼 新手攻略,来喽!
还在为部署nginx 服务而苦恼吗? 看了很多教程,部署nginx 服务依然困惑吗?
珍藏版 攻略 它来了,它来了!!!


在此 观看博主文章的你,需要准备两件趁手的兵器:
1.华为云服务器或者阿里云服务器等。
2.域名


——本博主使用的就是华为云 云耀服务器,本次攻略以我的云服务器作为栗子仅供大家参考!


一、云服务器

1.注册华为云

https://www.huaweicloud/


没有 服务器的需要去购买,按照自己的需求的配置即可。


以下操作在 云服务器内

二.在云服务器内 配置nginx服务器

1.进入云服务器 【通过rdp 形式进入

2.浏览器搜索nginx

这里 博主 在云服务器里 下载了谷歌浏览器

第一次进入的同学,可在本地电脑 下载好 谷歌浏览器 的安装包,然后复制到云服务器 磁盘当中。


3.下载nginx


4.移动nginx 文件

5.nginx 文件放置

解压后 ,将文件 移到 布置服务的磁盘内

放到你想要放置的磁盘中即可!

6.nginx.conf文件修改

server_name 处修改 为 自己的域名即可

例如:server_name www.shadow;


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  www.shadow.org.cn;#ip

        # 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  www.shadow.org.cn;
    #      ssl_certificate      cert.crt;
    #      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;
    #      }
    #  }

}


回到 华为云 控制面板

三、华为云控制台配置DNS解析

针对 已有域名 的配置


1.找到DNS解析

2.点击管理解析

3.快速添加解析

解析即可设置成功,届时你可通过自己的域名 访问 到云服务器当中!

需要注意的是:目前只配置的是 http https需要自己去nginx.conf当中配置。


本文标签: 器上ServerWindowsNginx