Centos/Docker/Nginx/Node/Jenkins 操作

Centos

Centos 是一个基于 Linux 的开源免费操作系统

# 本地拷贝文件到远程服务器
scp output.txt root@47.93.242.155:/data/    

  • output.txt:本地文件
  • root:登录远程服务器的账号
  • 47.93.242.155:远程服务器的 IP
  • /data/:远程服务器的目录

# 拷贝D盘https目录下的所有文件到 远程的 /data 目录
scp D:/https/* root@47.93.242.155:/data

 

本地链接远程 Centos 服务器

ssh \-p 端口 用户名@服务器IP

例子:

ssh -p  22  root@47.93.242.155

# 输入登录密码

# 成功


Nginx 服务器搭建

===》Nginx 是一个高性能的 HTTP 和反向代理 web 服务器

Centos 下安装 Nginx 服务器

这里我们使用 yum 安装 Nginx 服务器=========》yum install -y nginx

启动 Nginx 服务器

安装后的 Nginx 没有启动,先启动 Nginx 服务器。========》nginx-------------》如果无法访问,请重试用 nginx \-s reload 命令重启 Nginx

配置静态服务器访问路径

外网用户访问服务器的 Web 服务由 Nginx 提供,Nginx 需要配置静态资源的路径信息才能通过 url 正确访问到服务器上的静态资源。

打开 Nginx 的默认配置文件 /etc/nginx/nginx.conf ,修改 Nginx 配置

vi /etc/nginx/nginx.conf

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80;
        # 修改域名
        server_name  nsuedu.cn;

        # 如果是HTTP请求则重定向到HTTPS
        rewrite ^(.*) https://$host$1 permanent;
    }

# Settings for a TLS enabled server.

    server {
         # 服务器端口使用443,开启ssl
        listen       443 ssl http2 default_server;
        listen       [::]:443 ssl http2 default_server;

        # 输入你的域名
        server_name  nsuedu.cn;

        # 修改静态文件的路径
        root         /data/www;

        # ssl证书配置

        # 修改证书路径一
        ssl_certificate "/data/cert/4726867_www.nsuedu.cn.pem";
        # 修改证书路径二
        ssl_certificate_key "/data/cert/4726867_www.nsuedu.cn.key";

        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;  #缓存有效期
        ssl_ciphers HIGH:!aNULL:!MD5;  #加密算法
        ssl_prefer_server_ciphers on;  #使用服务器端的首选算法

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

}

 
posted @ 2021-07-28 19:56  KLAPT  阅读(45)  评论(0编辑  收藏  举报