Linux软件安装
创始人
2024-05-25 14:12:51
0

1.Linux安装JDK

1.安装位置

  • /opt

2.安装包

  • jdk-8u171-linux-x64.rpm

3.安装步骤

1.将安装包上传到虚拟机中

[root@localhost opt]# ls
jdk-8u171-linux-x64.rpm

2.执行安装命令

[root@localhost opt]# rpm -ivh jdk-8u171-linux-x64.rpm
准备中...                          ################################# [100%]
正在升级/安装...1:jdk1.8-2000:1.8.0_171-fcs        ################################# [100%]
Unpacking JAR files...tools.jar...plugin.jar...javaws.jar...deploy.jar...rt.jar...jsse.jar...charsets.jar...localedata.jar...

3.查看安装目录

[root@localhost opt]# rpm -qa | grep jdk
jdk1.8-1.8.0_171-fcs.x86_64[root@localhost opt]# rpm -ql jdk1.8
/usr
/usr/java
...[root@localhost ~]# cd /usr/java
[root@localhost java]# ls
default  jdk1.8.0_171-amd64  latest
[root@localhost java]# cd default
[root@localhost default]# ls
bin        javafx-src.zip  man          THIRDPARTYLICENSEREADME-JAVAFX.txt
COPYRIGHT  jre             README.html  THIRDPARTYLICENSEREADME.txt
db         lib             release
include    LICENSE         src.zip

4.配置环境变量

# 1.编辑配置文件
[root@localhost default]# vi /etc/profile# 2.profile文件最后追加以下3行配置
export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.# 3.刷新环境变量(没有出现错误表示配置成功)
[root@localhost default]# source /etc/profile

4.测试

# 成功显示
[root@localhost /]# java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

2.Linux安装Tomcat

  • 需要先安装JDK

1.安装位置

  • /opt/tomcat

2.压缩包

  • apache-tomcat-8.5.60.tar.gz

3.安装步骤

1.将压缩包上传到虚拟机中

[root@localhost tomcat]# ls
apache-tomcat-8.5.60.tar.gz

2.执行解压命令

[root@localhost tomcat]# tar -xzvf apache-tomcat-8.5.60.tar.gz
apache-tomcat-8.5.60/conf/
apache-tomcat-8.5.60/conf/catalina.policy
...[root@localhost tomcat]# ls
apache-tomcat-8.5.60  apache-tomcat-8.5.60.tar.gz

3.启动tomcat

# 1.进入tomcat文件夹
[root@localhost tomcat]# cd apache-tomcat-8.5.60
# 2.进入bin目录
[root@localhost apache-tomcat-8.5.60]# cd bin
# 3.启动tomcat
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE:   /opt/tomcat/apache-tomcat-8.5.60
Using CATALINA_HOME:   /opt/tomcat/apache-tomcat-8.5.60
Using CATALINA_TMPDIR: /opt/tomcat/apache-tomcat-8.5.60/temp
Using JRE_HOME:        /usr/java/default
Using CLASSPATH:       /opt/tomcat/apache-tomcat->8.5.60/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-8.5.60/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
# 4.查看tomcat进程 Bootstrap表示tomcat成功运行
[root@localhost bin]# jps
84071 Jps
64888 Bootstrap
# 5.Linux中测试访问tomcat默认8080端口号
[root@localhost bin]# curl -I http://localhost:8080
HTTP/1.1 200
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Date: Mon, 24 Oct 2022 22:24:18 GMT

4.关闭Linux防火墙

  • 1.Windows中访问Linux中的tomcat
    在这里插入图片描述
  • 2.此时需要关闭Linux防火墙
    # 1.查看防火墙状态
    [root@localhost bin]# systemctl status firewalld
    ● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)Active: active (running) since 日 2022-10-23 11:59:40 CST; 1 day 18h agoDocs: man:firewalld(1)Main PID: 669 (firewalld)CGroup: /system.slice/firewalld.service└─669 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid# 2.关闭防火墙
    [root@localhost bin]# systemctl stop firewalld
    [root@localhost bin]# systemctl status firewalld
    ● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)Active: deactivating (stop-sigterm) since 二 2022-10-25 06:30:36 CST; 44s agoDocs: man:firewalld(1)Main PID: 669 (firewalld)CGroup: /system.slice/firewalld.service└─669 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid# 3.关闭防火墙开机自启动
    # 每次开机防火墙都会自动打开,需要重新设置,所以在关闭防火墙后,关闭防火墙开机自启动,下次启动就不用重新设置
    [root@localhost bin]# systemctl disable firewalld
    Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
    Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.# 4.关闭selinux(Security-Enhanced Linux)	linux安全子系统
    # 不关闭会需要更多的配置
    # 查看状态
    [root@localhost ~]# getenforce
    Enforcing
    [root@localhost ~]# setenforce 0
    [root@localhost ~]# getenforce
    Permissive
    # 查看状态
    [root@localhost ~]# sestatus
    SELinux status:                 enabled
    SELinuxfs mount:                /sys/fs/selinux
    SELinux root directory:         /etc/selinux
    Loaded policy name:             targeted
    Current mode:                   permissive
    Mode from config file:          enforcing
    Policy MLS status:              enabled
    Policy deny_unknown status:     allowed
    Max kernel policy version:      31
    # 永久关闭selinux:
    # vi /etc/selinux/config
    # SELINUX=disabled
    # 配置文件后需要重启才能生效
    
    在这里插入图片描述

5.查看tomcat启动日志

# catalina.日期.log  记录tomcat启动时候的信息
# localhost.日期.log 记录tomcat启动时调用的方法
# localhost_access_log.日期.txt 访问tomcat的请求的所有地址以及请求的路径、时间,请求协议以及返回码等信息
# catalina.out 包含tomcat运行时所有的日志输出
[root@localhost apache-tomcat-8.5.60]# ls
bin           CONTRIBUTING.md  logs       RELEASE-NOTES  webapps
BUILDING.txt  lib              NOTICE     RUNNING.txt    work
conf          LICENSE          README.md  temp
[root@localhost apache-tomcat-8.5.60]# cd logs
[root@localhost logs]# ls
catalina.2022-10-25.log      localhost.2022-10-25.log
catalina.out                 localhost_access_log.2022-10-25.txt
host-manager.2022-10-25.log  manager.2022-10-25.log
[root@localhost logs]# less catalina.2022-10-25.log
[root@localhost logs]# less localhost.2022-10-25.log
[root@localhost logs]# less localhost_access_log.2022-10-25.txt
[root@localhost logs]# less catalina.out

3.Linux安装MySQL

1.安装位置

  • /opt/mysql5.7
    在这里插入图片描述

2.安装步骤

1.通过wget下载rpm安装包

[root@localhost tomcat]# wget -P /opt/mysql5.7 https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

在这里插入图片描述

2.通过rpm安装MySQL

[root@localhost mysql5.7]# rpm -ivh mysql57-community-release-el7-9.noarch.rpm

在这里插入图片描述

3.通过yum安装mysql(一般使用yum安装)

[root@localhost mysql5.7]# yum install -y mysql-server

在这里插入图片描述
如果出现上面安装失败可以通过下面方式解决(禁掉GPG验证检查)

[root@localhost mysql5.7]# yum -y install mysql-community-server --nogpgcheck

3.启动MySQL

# 1.启动mysql
[root@localhost mysql5.7]# systemctl start mysqld
# 2.查看mysql状态
[root@localhost mysql5.7]# systemctl status mysqld
# 3.查看mysql日志获取初始化密码
[root@localhost mysql5.7]# head -n 10 /var/log/mysqld.log
# 4.登陆mysql(输入上述初始化密码)
[root@localhost mysql5.7]# mysql -u root -p
# 5.修改mysql的密码策略(注意:默认密码检查策略比较严格,必须定义如类似密码 mysql> alter user 'root'@'localhost' identified by '$BAIZHIroot2002';)
mysql> set global validate_password_policy=0; 	# 修改为简单策略
mysql> set global validate_password_length=4;	# 修改密码长度最低为4
# 6.修改mysql密码
mysql> alter user root@'localhost' identified by 'root';

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

4.设置root允许远程访问

mysql> use mysql;
mysql> update user set host = '%' where user = 'root';
mysql> flush privileges;

在这里插入图片描述

5.关闭Linux防火墙

[root@localhost mysql5.7]# systemctl status mysqld	//当前已经关闭,若未关闭则执行 systemctl stop firewalld
● mysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)Active: inactive (dead)Docs: man:mysqld(8)http://dev.mysql.com/doc/refman/en/using-systemd.html

6.Navicat连接MySQL

在这里插入图片描述

7.远程访问MySQL

在这里插入图片描述

4.Linux安装Redis

5.Linux安装RibbitMQ

6.Linux系统下SSM项目打包部署

7.Linux系统下SpringBoot项目打包部署

  • 需要先安装JDK

1.简单SpringBoot项目打包部署(未连接mysql)

1.配置文件

  • 1.pom.xml
    
    4.0.0org.exampleSpringBootSimple1.0-SNAPSHOTjarUTF-81.81.8com.wd.SpringBootSimpleApplicationorg.springframework.bootspring-boot-starter-web2.6.3org.springframework.bootspring-boot-maven-plugin2.6.3repackage
    
  • application.yaml
    server:#修改项目端口号port: 8890#修改项目访问路径servlet:context-path: /springboot_simple
    

2.启动类

package com.wd;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
public class SpringBootSimpleApplication {public static void main(String[] args) {SpringApplication.run(SpringBootSimpleApplication.class, args);}
}

3.接口

package com.wd.controller;import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;@RequestMapping("/user")
@Controller
public class UserController {@RequestMapping("hello")@ResponseBodypublic String hello(){return "Hello SpringBootSimple";}
}

4.打包

  • 1.首先刷新Maven
  • 2.清空之前的target文件夹
  • 3.将test禁用(因为打包时会默认执行test中的代码,如果测试代码没有问题才会打包,如果测试代码有问题则打包失败)
  • 4.打包
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

5.部署

  • 1.将jar包上传到Linux中
  • 2.执行jar包
    # 错误原因:jar包内文件以及配置信息缺失
    # 正常的jar包内应该包含三个文件:BOOT-INF、META-INF、org
    # META-INF文件中有一个 MANIFEST.MF文件,正常文件如下图成功案例所示,配置丢失的文件如下图失败案例所示
    [root@localhost springboot]# java -jar SpringBoot-1.0-SNAPSHOT.jar
    SpringBoot-1.0-SNAPSHOT.jar中没有主清单属性# 解决方法
    pom.xml文件加入上述插件配置# 部署成功
    [root@localhost springboot]# java -jar SpringBootSimple-1.0-SNAPSHOT.jar.   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
    ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot ::                (v2.6.3)2022-10-25 14:29:05.065  INFO 4411 --- [           main] com.wd.SpringBootSimpleApplication       : Starting SpringBootSimpleApplication using 	Java 1.8.0_171 on localhost.localdomain with PID 4411 (/opt/springboot/SpringBootSimple-1.0-SNAPSHOT.jar started by root in /opt/springboot)
    2022-10-25 14:29:05.084  INFO 4411 --- [           main] com.wd.SpringBootSimpleApplication       : No active profile set, falling back to default profiles: default
    2022-10-25 14:29:09.500  INFO 4411 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8890 (http)
    2022-10-25 14:29:09.516  INFO 4411 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
    2022-10-25 14:29:09.516  INFO 4411 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]
    2022-10-25 14:29:09.942  INFO 4411 --- [           main] o.a.c.c.C.[.[.[/springboot_simple]       : Initializing Spring embedded WebApplicationContext
    2022-10-25 14:29:09.942  INFO 4411 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4738 ms
    2022-10-25 14:29:12.303  INFO 4411 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8890 (http) with context path '/springboot_simple'
    2022-10-25 14:29:12.350  INFO 4411 --- [           main] com.wd.SpringBootSimpleApplication       : Started SpringBootSimpleApplication in 8.473 seconds (JVM running for 11.126)
    2022-10-25 14:29:40.114  INFO 4411 --- [nio-8890-exec-1] o.a.c.c.C.[.[.[/springboot_simple]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
    2022-10-25 14:29:40.114  INFO 4411 --- [nio-8890-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
    2022-10-25 14:29:40.115  INFO 4411 --- [nio-8890-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
    
  • jar包及其解压后文件目录
    在这里插入图片描述
  • 失败案例在这里插入图片描述
  • 成功案例在这里插入图片描述

6.测试

2.简单SpringBoot项目打包部署(带日志,未连接mysql)

1.配置文件

  • 1.pom.xml
    
    4.0.0org.exampleSpringBootSimple1.0-SNAPSHOTjarUTF-81.81.8com.wd.SpringBootSimpleApplicationorg.springframework.bootspring-boot-starter-web2.6.3	org.projectlomboklombok1.18.10org.springframework.bootspring-boot-maven-plugin2.6.3repackage
    
  • application.yaml
    server:#修改项目端口号port: 8890#修改项目访问路径servlet:context-path: /springboot_simple
    

2.启动类

package com.wd;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
public class SpringBootSimpleApplication {public static void main(String[] args) {SpringApplication.run(SpringBootSimpleApplication.class, args);}
}

3.接口

package com.wd.controller;import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;import java.time.Instant;@Slf4j
@Controller
@RequestMapping("/user")
public class UserController {@RequestMapping("hello")@ResponseBodypublic String hello(){log.info("{} 调用hello方法", Instant.now());return "Hello SpringBootSimple";}@RequestMapping("bey")@ResponseBodypublic String bey(){log.info("{} 调用bey方法", Instant.now());return "Bey SpringBootSimple";}
}

4.打包

  • 1.首先刷新Maven
  • 2.清空之前的target文件夹
  • 3.将test禁用(因为打包时会默认执行test中的代码,如果测试代码没有问题才会打包,如果测试代码有问题则打包失败)
  • 4.打包
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

5.部署

  • 1.将jar包上传到Linux中
  • 2.创建日志文件
  • 3.后台一直运行项目并实时打印日志
  • 4.动态查看日志
    [root@localhost logs]# touch consoleMsg.log
    [root@localhost springboot]# nohup java -jar SpringBootSimple-1.0-SNAPSHOT.jar > logs/consoleMsg.log 2>&1 &
    [1] 9045
    [root@localhost springboot]# tail -f -n 20 logs/consoleMsg.log
    ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot ::                (v2.6.3)2022-10-25 16:02:21.383  INFO 9045 --- [           main] com.wd.SpringBootSimpleApplication       : Starting SpringBootSimpleApplication using Java 1.8.0_171 on localhost.localdomain with PID 9045 (/opt/springboot/SpringBootSimple-1.0-SNAPSHOT.jar started by root in /opt/springboot)
    2022-10-25 16:02:21.386  INFO 9045 --- [           main] com.wd.SpringBootSimpleApplication       : No active profile set, falling back to default profiles: default
    2022-10-25 16:02:23.694  INFO 9045 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8890 (http)
    2022-10-25 16:02:23.735  INFO 9045 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
    2022-10-25 16:02:23.735  INFO 9045 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]
    2022-10-25 16:02:23.887  INFO 9045 --- [           main] o.a.c.c.C.[.[.[/springboot_simple]       : Initializing Spring embedded WebApplicationContext
    2022-10-25 16:02:23.887  INFO 9045 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2377 ms
    2022-10-25 16:02:25.659  INFO 9045 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8890 (http) with context path '/springboot_simple'
    2022-10-25 16:02:25.687  INFO 9045 --- [           main] com.wd.SpringBootSimpleApplication       : Started SpringBootSimpleApplication in 5.46 seconds (JVM running for 6.993)
    2022-10-25 16:03:58.634  INFO 9045 --- [nio-8890-exec-1] o.a.c.c.C.[.[.[/springboot_simple]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
    2022-10-25 16:03:58.635  INFO 9045 --- [nio-8890-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
    2022-10-25 16:03:58.636  INFO 9045 --- [nio-8890-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
    2022-10-25 16:03:59.577  INFO 9045 --- [nio-8890-exec-1] com.wd.controller.UserController         : 2022-10-25T08:03:59.577Z 调用hello方法
    2022-10-25 16:04:10.007  INFO 9045 --- [nio-8890-exec-2] com.wd.controller.UserController         : 2022-10-25T08:04:10.007Z 调用bey方法# 查询SpringBoot项目的端口号
    [root@localhost logs]# ps -aux | grep SpringBoot# 杀死该后台运行的项目
    kill -9 9045
    

6.测试

8.Linux系统下SpringCloud项目打包部署

安装c语言开发环境

  • rpm
  • yum
yum groupinstall "Development tools"
  • 安装的是开发工具组,包含c,c++等多种语言,还有gdb调试器
  • 光安装c语言,可以按照gcc即可
yum -y install gcc
  • 按装vim编辑器及插件
yum -y install vim-*
  • 安装vim编辑器
  • 编写程序实现将百分制成绩转换为等级制成绩
  • 编译程序,运行程序
  • gdb调试程序
  • 安装gdb调试程序
yum -y install gdb
  • 编译用gcc编译器
  • gcc scoreGrade
    在这里插入图片描述
  • gcc scoreGrade.c -o score
  • -o执行文件的名字,即重命名
  • 运行程序
  • ./score
  • 如果需要调试程序,需要在编译时加上-g选项
  • gcc -g scoreGrade.c -o score
  • 调试
  • gdb score
  • 运行
  • ./score
  • 默认编译输出是a.out,不管编译的是哪一个c语言程序都会输出一个a.out
    在这里插入图片描述
  • ./a.out
    在这里插入图片描述
  • 执行可执行文件名用-o指定
    在这里插入图片描述
  • 可以同时编译多个可执行文件
  • gcc 文件名1 文件名2
    在这里插入图片描述
  • 调试内部命令:
  • file 文件名
  • y
  • l查看源码
  • b 行码 设置断点,注意b和行码之间有空格
    在这里插入图片描述
  • r 表示运行
  • 运行到断点会停止
  • n(next)会进行下一步
  • s(step)也是进行下一步
  • 如果有函数存在,s会进入函数体中调试,n不会进入函数体中,没有函数调用时,s和n效果一样
    q退出
    在这里插入图片描述

相关内容

热门资讯

喜欢穿一身黑的男生性格(喜欢穿... 今天百科达人给各位分享喜欢穿一身黑的男生性格的知识,其中也会对喜欢穿一身黑衣服的男人人好相处吗进行解...
发春是什么意思(思春和发春是什... 本篇文章极速百科给大家谈谈发春是什么意思,以及思春和发春是什么意思对应的知识点,希望对各位有所帮助,...
网络用语zl是什么意思(zl是... 今天给各位分享网络用语zl是什么意思的知识,其中也会对zl是啥意思是什么网络用语进行解释,如果能碰巧...
为什么酷狗音乐自己唱的歌不能下... 本篇文章极速百科小编给大家谈谈为什么酷狗音乐自己唱的歌不能下载到本地?,以及为什么酷狗下载的歌曲不是...
华为下载未安装的文件去哪找(华... 今天百科达人给各位分享华为下载未安装的文件去哪找的知识,其中也会对华为下载未安装的文件去哪找到进行解...
怎么往应用助手里添加应用(应用... 今天百科达人给各位分享怎么往应用助手里添加应用的知识,其中也会对应用助手怎么添加微信进行解释,如果能...
家里可以做假山养金鱼吗(假山能... 今天百科达人给各位分享家里可以做假山养金鱼吗的知识,其中也会对假山能放鱼缸里吗进行解释,如果能碰巧解...
四分五裂是什么生肖什么动物(四... 本篇文章极速百科小编给大家谈谈四分五裂是什么生肖什么动物,以及四分五裂打一生肖是什么对应的知识点,希...
一帆风顺二龙腾飞三阳开泰祝福语... 本篇文章极速百科给大家谈谈一帆风顺二龙腾飞三阳开泰祝福语,以及一帆风顺二龙腾飞三阳开泰祝福语结婚对应...
美团联名卡审核成功待激活(美团... 今天百科达人给各位分享美团联名卡审核成功待激活的知识,其中也会对美团联名卡审核未通过进行解释,如果能...