前提:nginxのインストール
オープンnginxのディレクトリ、通常は(は/ usr / local / nginxのの)
パケットにNPM実行ビルド、通常のレイVUE(は/ usr / local / nginxの/ HTML /)ディレクトリ
構成:nginxの
オープン(は/ usr / local / nginxの/ confに)ディレクトリ
- 新しいファイルを作成Xxx.conf、書き込みます:
server {
listen 80; //映射出的端口
server_name abc.com; //访问的域名或ip(默认是localhost,有时会被占用,是不是随便输个域名都可以?待验证)
location / {
root /usr/local/nginx/html/prod_dist; //放代码的路径(index.html的根目录)
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
- それとも、このディレクトリ、オープンnginx.confは、(HTTPでマークし、二ラベルされた)右の位置を見つけます
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;
//标记二:开启压缩静态资源
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
include api.conf;
include xxx.conf; //标记一,引入server配置
再起動してnginxの設定を有効にします
/ usr / local / nginxの/ sbinには入力
コマンドラインを:./ nginxの-sリロード
完了:訪問abc.com
参考ウェブサイト
https://blog.csdn.net/qq_35620501/article/details/89408581リソース圧縮