1、配置云服务器
https://blog.csdn.net/modaoshi51991/article/details/139547630
2、上传前端项目并配置nginx
首先在前端项目运行以下代码将项目打包
我遇到node.js和openssl两个版本不兼容问题,更新版本依次解决即可
bash
vue-cli-service build
看一下package.json文件里脚本配置里面对应的命令,运行那个
一般会把项目整个打包到dist文件里,然后上传dist文件即可
bash
> ruoyi@3.8.1 build:prod
> vue-cli-service build
| Building for production...Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:133:10)
at module.exports (C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:471:10)
at C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:503:5
at C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:358:12
at C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at iterateNormalLoaders (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
at C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:236:3
at runSyncOrAsync (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
at iterateNormalLoaders (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
at Array.<anonymous> (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (C:\D\USERPROG\ruoyi-ui\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at C:\D\USERPROG\ruoyi-ui\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
| Building for production...C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:114
throw e;
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:133:10)
at module.exports (C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:471:10)
at C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:503:5
at C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:358:12
at C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at iterateNormalLoaders (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
at C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:236:3
at context.callback (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
at C:\D\USERPROG\ruoyi-ui\node_modules\cache-loader\dist\index.js:147:7
at C:\D\USERPROG\ruoyi-ui\node_modules\graceful-fs\graceful-fs.js:61:14
at FSReqCallback.oncomplete (node:fs:197:23) {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
bash
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
| Building for production...Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:133:10)
at module.exports (C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:471:10)
at C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:503:5
at C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:358:12
at C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at iterateNormalLoaders (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
at C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:236:3
at runSyncOrAsync (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
at iterateNormalLoaders (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
at Array.<anonymous> (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (C:\D\USERPROG\ruoyi-ui\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at C:\D\USERPROG\ruoyi-ui\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:114
throw e;
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:133:10)
at module.exports (C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:471:10)
at C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:503:5
at C:\D\USERPROG\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:358:12
at C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:186:6
at context.callback (C:\D\USERPROG\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
at C:\D\USERPROG\ruoyi-ui\node_modules\cache-loader\dist\index.js:240:7
at C:\D\USERPROG\ruoyi-ui\node_modules\neo-async\async.js:2830:7
at done (C:\D\USERPROG\ruoyi-ui\node_modules\neo-async\async.js:2865:11)
at C:\D\USERPROG\ruoyi-ui\node_modules\neo-async\async.js:2818:7
at Array.<anonymous> (C:\D\USERPROG\ruoyi-ui\node_modules\cache-loader\dist\index.js:229:9) {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js v18.13.0
安装 EPEL(Extra Packages for Enterprise Linux)存储库:
bash
sudo yum install epel-release
安装 Nginx:
bash
sudo yum install nginx
启动并启用 Nginx:
bash
sudo systemctl start nginx
sudo systemctl enable nginx
上传dist文件到服务器指定目录
bash
scp -r ./dist/* username@your_server_ip:/var/ww/myapp
编辑 Nginx 配置文件以指向你的应用目录:
bash
sudo vi /etc/nginx/conf.d/myapp.conf
在配置文件中添加以下内容:
bash
server {
listen 80;
server_name your_domain_or_ip;//只需要将your_domain_or_ip改成服务器域名或者公网ip即可
location / {
root /var/www/myapp;
index index.html;
try_files $uri $uri/ /index.html;
}
# 转发后端请求到 Tomcat
location /backend/ {
proxy_pass http://localhost:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Serve gzipped files if available
gzip_static on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
}
测试 Nginx 配置文件的正确性:
bash
sudo nginx -t
如果配置文件测试通过,重启 Nginx:
bash
sudo systemctl restart nginx
确保防火墙允许 HTTP 流量:
bash
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
在浏览器中访问你的域名或服务器 IP,确保你的前端应用已经成功部署。
然后就可以通过http://your_eip访问你的前端页面了
3、下载jdk,tomcat、maven,mysql,打包后端项目,创建新数据库,上传后端项目并复制到tomcat目录下
下载jdk
bash
sudo dnf install java-1.8.0-openjdk-devel
验证
bash
java -version
使用 wget 命令下载 Tomcat 9.0.89:(需要到官网查看最新版本,替换里面的版本号)
bash
cd /tmp
wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.89/bin/apache-tomcat-9.0.89.tar.gz
将下载的压缩包解压到你想安装的目录,例如 /opt/tomcat:
bash
sudo mkdir /opt/tomcat
sudo tar xvf apache-tomcat-9.0.89.tar.gz -C /opt/tomcat --strip-components=1
验证
bash
sudo systemctl status tomcat
在浏览器中打开 http://:8080,如果看到 Tomcat 欢迎页面,说明 Tomcat 已成功安装并运行。
下载maven
如果遇到yum的问题看如下文章解决
https://blog.csdn.net/modaoshi51991/article/details/139606895
打包java后端项目
使用 cd 命令切换到你的项目目录。
bash
cd C:\D\USERPROG\rear\RuoYi-Vue
运行 Maven 构建命令:
bash
mvn clean package
下载mysql
如果遇到问题参考我的这篇文章
安装 MySQL:
bash
sudo yum install mysql-community-server -y
启动 MySQL 服务:
bash
sudo systemctl start mysqld
设置 MySQL 开机自启动:
bash
sudo systemctl enable mysqld
获取 MySQL 临时 root 密码:
bash
sudo grep 'temporary password' /var/log/mysqld.log
运行 MySQL 安全安装向导:
bash
sudo mysql_secure_installation
运行这个命令后,系统会提示你输入临时 root 密码,然后进行一些安全配置:
Enter password for user root: 输入临时密码 dw)<Zk*rs1b+
New password: 设置一个新的 root 密码
Re-enter new password: 再次输入新密码以确认
Do you wish to continue with the password provided? (Press y|Y for Yes, any other key for No): 输入 Y
Remove anonymous users? (Press y|Y for Yes, any other key for No): 输入 Y
Disallow root login remotely? (Press y|Y for Yes, any other key for No): 输入 Y
Remove test database and access to it? (Press y|Y for Yes, any other key for No): 输入 Y
Reload privilege tables now? (Press y|Y for Yes, any other key for No): 输入 Y
登录 MySQL:
bash
mysql -u root -p