nginx導入フロントエンドプロジェクト(vue)
1870 ワード
前提:nginxをインストールする nginxディレクトリを開きます.一般的には(/usr/local/nginx) です. npm run build vueパッケージを作成するには、一般的に(/usr/local/nginx/html/)ディレクトリの下に を配置します.
構成:nginxオープン(/usr/local/nginx/conf)ディレクトリ 新しいxxxを作成します.confファイル、書き込み: このディレクトリでnginxを開きます.conf,位置(http内のタグ1とタグ2)
nginx有効構成の再起動
/usr/local/nginx/sbinコマンドラインに入ります:./nginx -s reload
完了:abcへのアクセスcom
参考サイト
https://blog.csdn.net/qq_35620501/article/details/89408581リソース圧縮
構成:nginx
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;
}
}
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 reload
完了:abcへのアクセスcom
参考サイト
https://blog.csdn.net/qq_35620501/article/details/89408581リソース圧縮