• 【Linux】部署单机项目以及前后端分离项目


    Linux部署单机项目:

    优点:

    简化了系统管理:由于所有服务都在同一台机器上运行,因此可以简化系统管理和维护。
    提高了性能:由于没有网络延迟和其他因素的影响,所以可以提高系统的性能。
    缺点:

    容易出现故障:如果一台机器发生故障,那么整个系统都会受到影响。
    难以扩展:随着业务的发展,可能需要增加更多的服务器来处理请求,但是这在单机项目中是很难实现的。
     

    一,部署单机

    (这里我以之前发布过的项目:OA项目为例)

    1.导入后台提供的数据库

    2.将部署包放在主机上配置服务

    关于部署包的生成,eclipse工具就选中我们要打包的文件进行打jar就行,idear开发工具使用maven先要clean,再install就行

    然后启动项目

    报错(原因是配置文件,配置sql的数据库不对)

    修改配置连接的密码

    二,部署前后端分离项目

    2.1导入数据库

    2.2后端连接,403是后端验证,这时我们就要使用node.js

    2.3安装node.js

    这里这篇博客已经非常详细了http://t.csdnimg.cn/hx7MCicon-default.png?t=N7T8http://t.csdnimg.cn/hx7MC

    npm config set cache "C:\software\node-v18.16.1-win-x64\node-v18.16.1-win-x64\node_cache"

    npm config set prefix "C:\software\node-v18.16.1-win-x64\node-v18.16.1-win-x64\node_global"

    npm config set registry https://registry.npm.taobao.org/

    npm config get registry

    node_global:npm全局安装位置

    node_cache:  npm缓存路径

    node.js的环境配置: %NODE_HOME%;%NODE_HOME%\node_global;

    注:C:\software\node-v18.16.1-win-x64\node-v18.16.1-win-x64\node_cache为安装node.js的根目录

    2.4如果直接这么访问就会访问不到,只有虚拟机自己才可访问。

    2.5解决方法第一种:

    利用nginx做反向代理处理该问题,在nginx文件中找到nginx.conf 文件,将文件种的 location 进行修改。

    1. #user nobody;
    2. worker_processes 1;
    3. #error_log logs/error.log;
    4. #error_log logs/error.log notice;
    5. #error_log logs/error.log info;
    6. #pid logs/nginx.pid;
    7. events {
    8. worker_connections 1024;
    9. }
    10. http {
    11. include mime.types;
    12. default_type application/octet-stream;
    13. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    14. # '$status $body_bytes_sent "$http_referer" '
    15. # '"$http_user_agent" "$http_x_forwarded_for"';
    16. #access_log logs/access.log main;
    17. sendfile on;
    18. #tcp_nopush on;
    19. #keepalive_timeout 0;
    20. keepalive_timeout 65;
    21. #gzip on;
    22. server {
    23. listen 80;
    24. server_name localhost;
    25. #charset koi8-r;
    26. #access_log logs/host.access.log main;
    27. location / {
    28. proxy_pass http://localhost:8081;
    29. }
    30. #error_page 404 /404.html;
    31. # redirect server error pages to the static page /50x.html
    32. #
    33. error_page 500 502 503 504 /50x.html;
    34. location = /50x.html {
    35. root html;
    36. }
    37. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    38. #
    39. #location ~ \.php$ {
    40. # proxy_pass http://127.0.0.1;
    41. #}
    42. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    43. #
    44. #location ~ \.php$ {
    45. # root html;
    46. # fastcgi_pass 127.0.0.1:9000;
    47. # fastcgi_index index.php;
    48. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    49. # include fastcgi_params;
    50. #}
    51. # deny access to .htaccess files, if Apache's document root
    52. # concurs with nginx's one
    53. #
    54. #location ~ /\.ht {
    55. # deny all;
    56. #}
    57. }
    58. # another virtual host using mix of IP-, name-, and port-based configuration
    59. #
    60. #server {
    61. # listen 8000;
    62. # listen somename:8080;
    63. # server_name somename alias another.alias;
    64. # location / {
    65. # root html;
    66. # index index.html index.htm;
    67. # }
    68. #}
    69. # HTTPS server
    70. #
    71. #server {
    72. # listen 443 ssl;
    73. # server_name localhost;
    74. # ssl_certificate cert.pem;
    75. # ssl_certificate_key cert.key;
    76. # ssl_session_cache shared:SSL:1m;
    77. # ssl_session_timeout 5m;
    78. # ssl_ciphers HIGH:!aNULL:!MD5;
    79. # ssl_prefer_server_ciphers on;
    80. # location / {
    81. # root html;
    82. # index index.html index.htm;
    83. # }
    84. #}
    85. }

    之后在nginx根目录下输入cmd进入命令窗口输入 nginx.exe -s reload重启

    成功

    方法二:在spa项目中找到config文件下的index.jshost:'localhost'改为0.0.0.0

    部署成功!!!

  • 相关阅读:
    2022.4昆明 E Easy String Problem
    R语言ggplot2可视化地图并使用scale_fill_gradient函数自定义设置地图颜色刻度为灰色梯度刻度(grey gradient scales)
    【PostgreSQL-14版本snapshot的几点优化】
    STM32单片机入门学习(一)
    【Spring Cloud系列】 雪花算法原理及实现
    互动超2800万!小红书涌现大批“听劝人”,关键词数据发掘内容玩法
    如何在Xamarin中快速集成Android版远程配置
    如何使用ArkUI从0-1写一个开发购物应用程序(下)
    【Leetcode】1829. Maximum XOR for Each Query
    一次完整的支付链路
  • 原文地址:https://blog.csdn.net/m0_73647713/article/details/134083060