Xshell + Xftp + Nginx 阿里云服务器项目部署

95 阅读2分钟

(需要软件包可以私聊我)

一、获取阿里云公网IP

image.png

二、Xshell配置

image.png

image.png

出现welcome表示连接成功 image.png

三、Xfpt配置

image.png

四、Xshell 配置nginx

1、nginx包放在Xtp的opt下面 ,并在Xshell执行解压nginx压缩包命令tar -zxf nginx.tar.gz -C /opt

cd /opt // 进入opt文件夹
tar -zxf nginx.tar.gz -C /opt // 解nginx压缩包

image.png 2、添加服务

# 添加服务(全部复制进去执行)
cat > /usr/lib/systemd/system/nginx.service << 'EOF'
[Unit]
Description=Nginx
After=network.target

[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStart=/opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf
ExecReload=/opt/nginx/sbin/nginx -s reload
ExecStop=/opt/nginx/sbin/nginx -s quit

[Install]
WantedBy=multi-user.target
EOF
# 启动服务(依次执行)
systemctl daemon-reload
systemctl start nginx
systemctl enable nginx      # 添加开机启动

image.png

ll查看文件 image.png mkdir web创建文件夹

image.png

将打包好的dist文件放入这个文件夹 image.png 配置nginx文件

# 配置文件
cat > /opt/nginx/conf/nginx.conf << 'EOF'
#user  nobody;
worker_processes  2;
worker_cpu_affinity 01 10;
worker_rlimit_nofile 65535;

events {
    use epoll;
    worker_connections  65535;
    accept_mutex on;
    multi_accept on;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format main '$remote_addr [$time_iso8601] [$status "$http_host" "$request" ' 
                    '$request_time *** $upstream_status $upstream_response_time "$body_bytes_sent" $upstream_addr] '
                    '["$http_referer" "$http_user_agent" "$remote_user" "$http_x_forwarded_for"]';
    access_log  logs/access.log  main;

    sendfile        on;
    tcp_nopush     on;
    tcp_nodelay on;
    server_tokens off;
    #gzip  on;

    keepalive_timeout 60;

    client_header_buffer_size 4k;
    client_body_buffer_size 256k;

    client_max_body_size 1000m;

    proxy_connect_timeout 6000;
    proxy_send_timeout 3000;
    proxy_read_timeout 3000;
    proxy_buffer_size 4k;
    proxy_buffers 4 32k;
    proxy_busy_buffers_size 64k;
    proxy_temp_file_write_size 64k;
    proxy_max_temp_file_size 2048m;

    open_file_cache max=65535 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 1;
    client_header_timeout 300;
    client_body_timeout 300;
    reset_timedout_connection on;
    send_timeout 300;   
 
    server {
        listen       80;
        server_name  localhost;
        underscores_in_headers on;
        add_header X-Frame-Options SAMEORIGIN;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        
		
      
          location /test-serve {
             alias /opt/web/test-serve;
             add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
        }

       
    }
}
EOF
systemctl status nginx
cat /usr/lib/systemd/system/nginx.service
systemctl start nginx 启动
systemctl restart nginx 重启命令 (服务器噶了,或者改了配置)

访问:http://47.110.153.193/test-serve/#/ 公网ip+dist文件夹名