cd /usr/share/nginx/html```<br />#打包前端项目<br />run build<br />将生成的dist文件夹整个丢进来<br />systemctl restart nginx`
    以下为nginx.conf

    1. # For more information on configuration, see:
    2. # * Official English Documentation: http://nginx.org/en/docs/
    3. # * Official Russian Documentation: http://nginx.org/ru/docs/
    4. user nginx;
    5. worker_processes auto;
    6. error_log /var/log/nginx/error.log;
    7. pid /run/nginx.pid;
    8. # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
    9. include /usr/share/nginx/modules/*.conf;
    10. events {
    11. worker_connections 1024;
    12. }
    13. http {
    14. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    15. '$status $body_bytes_sent "$http_referer" '
    16. '"$http_user_agent" "$http_x_forwarded_for"';
    17. access_log /var/log/nginx/access.log main;
    18. sendfile on;
    19. tcp_nopush on;
    20. tcp_nodelay on;
    21. keepalive_timeout 65;
    22. types_hash_max_size 2048;
    23. include /etc/nginx/mime.types;
    24. default_type application/octet-stream;
    25. # Load modular configuration files from the /etc/nginx/conf.d directory.
    26. # See http://nginx.org/en/docs/ngx_core_module.html#include
    27. # for more information.
    28. include /etc/nginx/conf.d/*.conf;
    29. # 设置监听端口号 服务器ip root指向前端资源目录
    30. server {
    31. listen 8080;
    32. server_name 81.69.46.120;
    33. # server_name _;
    34. root /usr/share/nginx/html/dist;
    35. # Load configuration files for the default server block.
    36. include /etc/nginx/default.d/*.conf;
    37. location / {
    38. index index.html;
    39. try_files $uri $uri/ /index.html;
    40. }
    41. # error_page 404 /404.html;
    42. # location = /40x.html {
    43. # }
    44. #
    45. # error_page 500 502 503 504 /50x.html;
    46. # location = /50x.html {
    47. # }
    48. }
    49. # Settings for a TLS enabled server.
    50. #
    51. # server {
    52. # listen 443 ssl http2 default_server;
    53. # listen [::]:443 ssl http2 default_server;
    54. # server_name _;
    55. # root /usr/share/nginx/html;
    56. #
    57. # ssl_certificate "/etc/pki/nginx/server.crt";
    58. # ssl_certificate_key "/etc/pki/nginx/private/server.key";
    59. # ssl_session_cache shared:SSL:1m;
    60. # ssl_session_timeout 10m;
    61. # ssl_ciphers PROFILE=SYSTEM;
    62. # ssl_prefer_server_ciphers on;
    63. #
    64. # # Load configuration files for the default server block.
    65. # include /etc/nginx/default.d/*.conf;
    66. #
    67. # location / {
    68. # }
    69. #
    70. # error_page 404 /404.html;
    71. # location = /40x.html {
    72. # }
    73. #
    74. # error_page 500 502 503 504 /50x.html;
    75. # location = /50x.html {
    76. # }
    77. # }
    78. }