フロントエンドは Vue プロジェクトを Tencent Cloud Server にデプロイします

pagoda dist包上传服务器
、 FileZilla 、手動アップロードなどを使用できます。
手動アップロード方法

  1. Tencent Cloudサーバーを使用した後、パネルインターフェイスに入ります
    ここに画像の説明を挿入

次にNginxをインストールします

请一步一步,紧跟步骤

  • 最初の一歩

    gcc-c++ コンパイラをインストールします。nginx は pcre および zlib パッケージに依存します
    yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

  • はい、問題ありません 2 番目のステップ

    コマンド ダウンロード ファイル
    wget http://nginx.org/download/nginx-1.18.0.tar.gz

     解压文件
     tar -zxvf nginx-1.18.0.tar.gz
     
     解压之后把nginx-1.18.0文件手动移动到
     /usr/local目录中
     
     进入安装目录
     cd /usr/local/nginx-1.18.0
    

    ディレクトリに入ったら、「./configure
    make && make install」と入力します。 コンパイルしてインストールすると、同じレベルに nginx ファイルが生成されます。
    cd /usr/local/nginx/sbin ディレクトリを入力します。
    sudo ./nginx テストを開始します
    。 サーバー アドレスとアクセスは成功しましたここに画像の説明を挿入

  1. インストールが完了したら、nginx ディレクトリの conf ファイルに nginx.conf ファイルを入力します。
  1. サーバーは、
    主にポート番号ファイル ディレクトリを構成する別個の Vue プロジェクト構成とみなすことができます。
  server {
    
    
          listen       8080;//端口号
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
    
    
            root   /root/gitee_go/deploy/dist;//文件目录
            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;
        }
    }

若果需要是不同端口不同项目直接复制serve放至下边只需修改端口号、dist文件位置即可
ps 每次修改nginx.conf文件后都需要重启服务

まず、cd local/nginx/sbin restart command ==> sudo ./nginx -s reloadのように、nginx の sbin フォルダーに入ります。

last.
サーバー インターフェイスに入り、ファイアウォールを選択し
ポート
、正常にアクセスするには対応するポート番号を追加します。
ここに画像の説明を挿入
アクセスは 403 である場合もあります
ここに画像の説明を挿入
。conf ファイルにユーザー root を追加して、
ここに画像の説明を挿入
ps 有时候服务器重启服务起不来报错 nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
/usr/local/nginx/sbin/nginx -c /usr/local/ と入力します。 nginx/conf/nginx .conf ディレクトリを指定してnginxを再起動します

============

静的リソース ファイルをサーバーに保存する

conf ファイルに新しいサーバーを作成します

 # 资源文件
    server {
        listen       35;     端口
        server_name  localhost;
        # 存放文件的目录
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /root/gitee_go/deploy;     对应的资源文件夹
            # index  index.html index.htm;
            autoindex on;
        }

        #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;
        #}
    }

構成が完了したら、アクセスするサービスを再起動します。
たとえば、

ここに画像の説明を挿入

おすすめ

転載: blog.csdn.net/regretTAT/article/details/130653660