网站更改,对内部网站建设的意见和建议,太原网页制作,想建网站怎么做基础环境
所有环境皆关闭防火墙与selinux
服务器功能主机IP主机名服务名称配置前端服务器192.168.231.177nginxnginx1C2G后端服务器代码打包192.168.231.178javajava、maven、nodejs4C8G数据库/缓存192.168.231.179dbmysql、redis2C4G
Nginx
#配置Nginxyum源
[rootnginx ~]…基础环境
所有环境皆关闭防火墙与selinux
服务器功能主机IP主机名服务名称配置前端服务器192.168.231.177nginxnginx1C2G后端服务器代码打包192.168.231.178javajava、maven、nodejs4C8G数据库/缓存192.168.231.179dbmysql、redis2C4G
Nginx
#配置Nginxyum源
[rootnginx ~]# cat /etc/yum.repos.d/nginx.repo
[nginx-stable]
namenginx stable repo
baseurlhttp://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck1
enabled1
gpgkeyhttps://nginx.org/keys/nginx_signing.key
module_hotfixestrue[nginx-mainline]
namenginx mainline repo
baseurlhttp://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck1
enabled0
gpgkeyhttps://nginx.org/keys/nginx_signing.key
module_hotfixestrue#安装Nginx
[rootnginx ~]# yum install -y nginx
java
# 上传java包到服务器
# 安装java环境
[rootjava ~]# tar -xf jdk-8u211-linux-x64.tar.gz -C /usr/local/
[rootjava ~]# mv /usr/local/jdk1.8.0_211/ /usr/local/java
[rootjava ~]# vim /etc/profile.d/java.sh
JAVA_HOME/usr/local/java
PATH$PATH:$JAVA_HOME/bin重载配置文件
[rootjava ~]# source /etc/profile.d/java.sh查看java是否安装成功
[rootjava ~]# java -version
java version 1.8.0_211
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
mysql、redis
# 配置mysql yum源
# 安装mysql
[rootdb ~]# yum install -y mysql-server
[rootdb ~]# systemctl start mysqld
[rootdb ~]# systemctl enable mysqld过滤MySQL初始密码必须启动MySQL才能过滤出来
[rootdb ~]# grep password /var/log/mysqld.log
2023-11-03T19:44:26.450149Z 1 [Note] A temporary password is generated for rootlocalhost: rb894yRh(NUG修改mysql密码
[rootdb ~]# mysqladmin -uroot -prb894yRh(NUG password QianFeng123!
[rootdb ~]# mysql -uroot -pQianFeng123!
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.42 MySQL Community Server (GPL)Copyright (c) 2000, 2023, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type help; or \h for help. Type \c to clear the current input statement.# 创建数据库
mysql create database ruoyi character set utf8 collate utf8_general_ci;
Query OK, 1 row affected (0.00 sec)#授权root用户远程登录
mysql grant all on *.* to root% identified by QianFeng123!;
Query OK, 0 rows affected, 1 warning (0.00 sec)#刷新权限
mysql flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql \q
Bye[rootdb ~]# wget http://download.redis.io/releases/redis-4.0.9.tar.gz
[rootdb ~]# tar -xf redis-4.0.9.tar.gz -C /usr/local/
[rootdb ~]# mv /usr/local/redis-4.0.9/ /usr/local/redis安装编译工具gcc make
[rootdb ~]# yum install -y gcc make
[rootdb ~]# cd /usr/local/redis/
[rootdb redis]# make修改redis的配置文件
[rootdb redis]# cat redis.conf
bind 192.168.231.179
port 6379
daemonize yes
[rootdb redis]# ./src/redis-server redis.conf
[rootdb redis]# ss -tlanp |grep redis
LISTEN 0 128 192.168.231.179:6379 *:* users:((redis-server,pid4938,fd6))
配置打包环境
配置前端打包环境
[rootjava ~]# wget https://nodejs.org/dist/v12.18.4/node-v12.18.4-linux-x64.tar.xz
[rootjava ~]# tar -xf node-v12.18.4-linux-x64.tar.xz -C /usr/local/改名
[rootjava ~]# mv /usr/local/node-v12.18.4-linux-x64/ /usr/local/node配置环境变量
[rootjava ~]# vim /etc/profile.d/node.sh
NODE_HOME/usr/local/node
PATH$PATH:$NODE_HOME/bin重载环境变量
[rootjava ~]# source /etc/profile.d/node.sh查看是否安装成功
[rootjava ~]# node -v
v12.18.4
配置后端打包环境
下包解压包改名
[rootjava ~]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.9.5/binaries/apache-maven-3.9.5-bin.tar.gz --no-check-certificate
[rootjava ~]# tar -xf apache-maven-3.9.5-bin.tar.gz -C /usr/local/
[rootjava ~]# mv /usr/local/apache-maven-3.9.5/ /usr/local/maven配置环境变量
[rootjava ~]# vim /etc/profile.d/mvn.sh
MAVEN_HOME/usr/local/maven
PATH$PATH:$MAVEN_HOME/bin重载环境变量
[rootjava ~]# source /etc/profile.d/mvn.sh查看是否安装成功
[rootjava ~]# mvn -version
Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546)
Maven home: /usr/local/maven
Java version: 1.8.0_211, vendor: Oracle Corporation, runtime: /usr/local/java/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: linux, version: 3.10.0-1160.el7.x86_64, arch: amd64, family: unix
获取代码
获取源代码
[rootjava ~]# yum install -y git
[rootjava ~]# git clone https://gitee.com/y_project/RuoYi-Vue.git获得RuoYi-Vue
[rootjava ~]# ls
anaconda-ks.cfg node-v12.18.4-linux-x64.tar.xz
apache-maven-3.9.5-bin.tar.gz RuoYi-Vue
jdk-8u211-linux-x64.tar.gz
前端代码打包
[rootjava ~]# cd RuoYi-Vue/ruoyi-ui
#替换为国内的taobaoyuan
[rootjava ruoyi-ui]# npm install --unsafe-perm --registryhttps://registry.npm.taobao.org
[rootjava ruoyi-ui]# npm run build:prod构建打包成功之后会在根目录生成 dist 文件夹里面就是构建打包好的文件通常是 xxx.js 、xxx.css、index.html 等静态文件。通常情况下 dist 文件夹的静态文件发布到你的 nginx 或者静态服务器即可其中的 index.html 是后台服务的入口页面。
[rootjava ruoyi-ui]# ls
babel.config.js dist package-lock.json src
bin node_modules public vue.config.js
build package.json README.md
[rootjava ruoyi-ui]# cd dist/
[rootjava dist]# ls
favicon.ico html index.html index.html.gz robots.txt static# 将静态资源移动到其他位置然后进行后端代码打包
[rootjava dist]# cd /root/RuoYi-Vue
[rootjava RuoYi-Vue]# mv ruoyi-ui/ /opt/
后端代码打包
首先修改后端所需的配置文件
[rootjava ~]# cd RuoYi-Vue/
[rootjava RuoYi-Vue]# vim ruoyi-admin/src/main/resources/application.yml
# 修改redis配置信息redis:# 地址host: 192.168.231.179# 端口默认为6379port: 6379# 数据库索引database: 0# 密码password:# 连接超时时间timeout: 10slettuce:[rootjava RuoYi-Vue]# vim ruoyi-admin/src/main/resources/application-druid.yml
### 修改数据库url修改数据库密码
# 数据源配置
spring:datasource:type: com.alibaba.druid.pool.DruidDataSourcedriverClassName: com.mysql.cj.jdbc.Driverdruid:# 主库数据源master:url: jdbc:mysql://192.168.231.179:3306/ruoyi?useUnicodetruecharacterEncodingutf8zeroDateTimeBehaviorconvertToNulluseSSLtrueserverTimezoneGMT%2B8username: rootpassword: QianFeng123!
后端打包
rootjava RuoYi-Vue]# mvn package
…………
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:35 min
[INFO] Finished at: 2023-11-03T20:18:2008:00
[INFO] ------------------------------------------------------------------------
[rootjava RuoYi-Vue]# ls ruoyi-admin/target/
classes maven-archiver ruoyi-admin.jar
generated-sources maven-status ruoyi-admin.jar.original#ruoyi-admin.jar 放在后端服务器运行
项目上线
前端项目上线
# 拷贝前端资源到前端服务器
[rootjava ~]# cd /opt
[rootjava opt]# scp -r ruoyi-ui/ 192.168.231.177:/opt/#前端项目上线
[rootnginx ~]# rm -rf /usr/share/nginx/html/*
[rootnginx ~]# cp -r /opt/ruoyi-ui/dist/* /usr/share/nginx/html/
[rootnginx ~]# ls /usr/share/nginx/html/
favicon.ico html index.html index.html.gz robots.txt static[rootnginx ~]# vim /etc/nginx/conf.d/default.conf
upstream rs {server 192.168.231.178:8080;
}
server {listen 80;server_name localhost;access_log /var/log/nginx/host.access.log main;location / {root /usr/share/nginx/html;try_files $uri $uri/ /index.html;index index.html index.htm;}location /prod-api/ {proxy_pass http://rs/;proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}
[rootnginx ~]# systemctl restart nginx#前端上线完成但是由于后端还未上线所以有报错并且验证码无法显示
#前端上线完成但是由于后端还未上线所以有报错并且验证码无法显示 后端项目上线
# 将jar包传送到后端服务器
[rootjava opt]# cp ~/RuoYi-Vue/ruoyi-admin/target/ruoyi-admin.jar /java/#导入初始化数据,首先将初始化数据传到数据库服务器
[rootjava ~]# cd /root/RuoYi-Vue/sql
[rootjava sql]# ls
quartz.sql ry_20230706.sql
[rootjava sql]# scp * 192.168.231.179:/opt/
# 导入初始化数据
[rootdb redis]# mysql -uroot -pQianFeng123! ruoyi /opt/quartz.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[rootdb redis]# mysql -uroot -pQianFeng123! ruoyi /opt/ry_20230706.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
#开始测试上线后端服务
[rootjava target]# java -jar -server -Xmx1024m -Xms1024m ruoyi-admin.jar
Application Version: 3.8.6
Spring Boot Version: 2.5.15// _ooOoo_ //
// o8888888o //
// 88 . 88 //
// (| ^_^ |) //
// O\ /O //
// ____/---\____ //
// . \\| |// . //
// / \\||| : |||// \ //
// / _||||| -:- |||||- \ //
// | | \\\ - /// | | //
// | \_| \---/ | | //
// \ .-\__ - ___/-. / //
// ___. . /--.--\ . . ___ //
// . .___\_|_/___. . //
// | | : - \.;\ _ /;./ - : | | //
// \ \ -. \_ __\ /__ _/ .- / / //
// -.____-.___\_____/___.-____.- //
// --- //
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
// 佛祖保佑 永不宕机 永无BUG //05:15:09.581 [background-preinit] INFO o.h.v.i.util.Version - [clinit,21] - HV000001: Hibernate Validator 6.2.5.Final
05:15:09.633 [main] INFO c.r.RuoYiApplication - [logStarting,55] - Starting RuoYiApplication using Java 1.8.0_211 on db with PID 15389 (/opt/RuoYi-Vue/ruoyi-admin/target/ruoyi-admin.jar started by root in /opt/RuoYi-Vue/ruoyi-admin/target)
05:15:09.634 [main] DEBUG c.r.RuoYiApplication - [logStarting,56] - Running with Spring Boot v2.5.15, Spring v5.3.27
05:15:09.634 [main] INFO c.r.RuoYiApplication - [logStartupProfileInfo,686] - The following 1 profile is active: druid
05:15:11.945 [main] INFO o.a.c.h.Http11NioProtocol - [log,173] - Initializing ProtocolHandler [http-nio-8080]
05:15:11.945 [main] INFO o.a.c.c.StandardService - [log,173] - Starting service [Tomcat]
05:15:11.946 [main] INFO o.a.c.c.StandardEngine - [log,173] - Starting Servlet engine: [Apache Tomcat/9.0.75]
05:15:12.035 [main] INFO o.a.c.c.C.[.[.[/] - [log,173] - Initializing Spring embedded WebApplicationContext
05:15:12.514 [main] DEBUG c.r.f.s.f.JwtAuthenticationTokenFilter - [init,242] - Filter jwtAuthenticationTokenFilter configured for use
05:15:13.856 [main] INFO c.a.d.p.DruidDataSource - [init,996] - {dataSource-1} inited
05:15:13.862 [main] DEBUG c.r.s.m.S.selectDictDataList - [debug,137] - Preparing: select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark from sys_dict_data WHERE status ? order by dict_sort asc
05:15:13.880 [main] DEBUG c.r.s.m.S.selectDictDataList - [debug,137] - Parameters: 0(String)
05:15:13.903 [main] DEBUG c.r.s.m.S.selectDictDataList - [debug,137] - Total: 29
05:15:14.462 [main] DEBUG c.r.s.m.S.selectConfigList - [debug,137] - Preparing: select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark from sys_config
05:15:14.463 [main] DEBUG c.r.s.m.S.selectConfigList - [debug,137] - Parameters:
05:15:14.465 [main] DEBUG c.r.s.m.S.selectConfigList - [debug,137] - Total: 6
05:15:14.873 [main] INFO o.q.i.StdSchedulerFactory - [instantiate,1220] - Using default implementation for ThreadExecutor
05:15:14.885 [main] INFO o.q.c.SchedulerSignalerImpl - [init,61] - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
05:15:14.885 [main] INFO o.q.c.QuartzScheduler - [init,229] - Quartz Scheduler v.2.3.2 created.
05:15:14.886 [main] INFO o.q.s.RAMJobStore - [initialize,155] - RAMJobStore initialized.
05:15:14.887 [main] INFO o.q.c.QuartzScheduler - [initialize,294] - Scheduler meta-data: Quartz Scheduler (v2.3.2) quartzScheduler with instanceId NON_CLUSTEREDScheduler class: org.quartz.core.QuartzScheduler - running locally.NOT STARTED.Currently in standby mode.Number of jobs executed: 0Using thread pool org.quartz.simpl.SimpleThreadPool - with 10 threads.Using job-store org.quartz.simpl.RAMJobStore - which does not support persistence. and is not clustered.05:15:14.887 [main] INFO o.q.i.StdSchedulerFactory - [instantiate,1374] - Quartz scheduler quartzScheduler initialized from an externally provided properties instance.
05:15:14.887 [main] INFO o.q.i.StdSchedulerFactory - [instantiate,1378] - Quartz scheduler version: 2.3.2
05:15:14.887 [main] INFO o.q.c.QuartzScheduler - [setJobFactory,2293] - JobFactory set to: org.springframework.scheduling.quartz.SpringBeanJobFactory649725e3
05:15:14.906 [main] DEBUG c.r.q.m.S.selectJobAll - [debug,137] - Preparing: select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark from sys_job
05:15:14.906 [main] DEBUG c.r.q.m.S.selectJobAll - [debug,137] - Parameters:
05:15:14.908 [main] DEBUG c.r.q.m.S.selectJobAll - [debug,137] - Total: 3
05:15:16.124 [main] INFO o.a.c.h.Http11NioProtocol - [log,173] - Starting ProtocolHandler [http-nio-8080]
05:15:16.511 [main] INFO o.q.c.QuartzScheduler - [start,547] - Scheduler quartzScheduler_$_NON_CLUSTERED started.
05:15:16.521 [main] INFO c.r.RuoYiApplication - [logStarted,61] - Started RuoYiApplication in 7.487 seconds (JVM running for 7.935)
(♥◠‿◠) 若依启动成功 ლ(´ڡლ).-------. ____ __| _ _ \ \ \ / /| ( ) | \ _. / |(_ o _) / _( )_ .| (_,_). __ ___(_ o _)| |\ \ | || |(_,_)| | \ /| - /| | \ / \ /- - -..- 结尾出现若依启动成功则证明后端服务成功上线 正式上线
[rootjava target]# nohup java -jar -server -Xmx1024m -Xms1024m ruoyi-admin.jar 错误及解决办法 ## 如果报错链接不上数据库且数据库配置无问题将RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml文件中 master: url: jdbc:mysql://192.168.231.179:3306/ruoyi?useUnicodetruecharacterEncodingutf8zeroDateTimeBehaviorconvertToNulluseSSLfalseserverTimezoneGMT%2B8 将url中useSSLyes改成useSSLfalse然后重新打包上线 在JDBC连接MySQL数据库时useSSL参数用于指定是否使用SSL安全套接层加密连接。SSL是一种用于在计算机网络上提供安全通信的协议它可以确保在客户端和服务器之间传输的数据在传输过程中是加密的从而提供了一定程度的安全性。 当useSSL参数设置为false时表示不使用SSL加密连接。这通常在开发和测试环境中比较常见因为在这些环境下对数据传输的安全性要求可能较低而且SSL加密会增加一些额外的性能开销。在这种情况下如果数据库服务器不要求强制的SSL连接你可以将useSSL参数设置为false来简化连接配置。 但是在生产环境中特别是涉及到敏感数据的应用强烈建议使用SSL加密来保护数据的传输安全性。在生产环境中通常会将useSSL参数设置为true以确保数据库连接是安全的。 在你的连接字符串中useSSLfalse表示不使用SSL加密连接。如果你的数据库服务器要求SSL连接那么你需要将useSSL参数设置为true以便建立加密连接。 nohup命令解释 nohup命令nohup 是 no hang up 的缩写就是不挂断的意思但没有后台运行终端不能标准输入。 nohup 不挂断的运行注意并没有后台运行的功能就是指用nohup运行命令可以使命令永久的执行下去和用户终端没有关系例如我们断开SSH连接都不会影响他的运行注意了nohup没有后台运行的意思才是后台运行 在缺省情况下该作业的所有输出都被重定向到一个名为nohup.out的文件中。 nohup和的区别 :指在后台运行 是指在后台运行但当用户推出(挂起)的时候命令自动也跟着退出 的意思是在后台运行 什么意思呢 意思是说 当你在执行 ./start.sh 的时候 即使你用ctrlC, 那么start.sh照样运行因为对SIGINT程序终止信号一般有ctrlC发出信号免疫。 但是要注意 如果你直接关掉shell后 那么start.sh进程同样消失。 可见 的后台并不硬因为对SIGHUP(用户终端连接(正常或非正常)结束时发出)信号不免疫。 nohup的意思是忽略SIGHUP信号 所以当运行nohup ./start.sh的时候 关闭shell, 那么start.sh进程还是存在的对SIGHUP信号免疫。 但是 要注意 如果你直接在shell中用CtrlC, 那么start.sh进程也是会消失的因为对SIGINT信号不免疫 所以 和nohup没有半毛钱的关系 要让进程真正不受shell中CtrlC和shell关闭的影响 那该怎么办呢 那么我们可以巧妙的将他们结合起来用就是 nohup COMMAND /dev/null 这样就能使命令永久的在后台执行两全其美。