Linux安装软件的4种方式

笔记待改

1、宝塔面板

一键安装,一键卸载,一键启动,一键停止。
你用其他方式如压缩包方式,安装过nginx,仍然可以用宝塔面板安装,宝塔面板不会提醒你你安装过了。
用宝塔面板安装的,直接可以systemctl status nginx.service,也可以直接mysql -V
安装目录:/www/server/下。/www是宝塔面板自己新建的一个目录,不是Linux原本有的。

2、yum

安装:yum install -y redis.x86_64
卸载:yum remove -y httpd
查看安装目录:rpm -ql redis。/etc 下是yum安装软件的配置文件路径,/usr/bin 是yum安装软件的可执行文件路径。软件安装在/usr目录下。
yum安装完毕,直接可以systemctl status nginx.service这样,也直接可以nginx -v这样。

通过rpm包进行yum安装:
MySQL :: Download MySQL Yum Repository

# 安装mysql
[root@wu1 ~]# yum install -y mysql80-community-release-el8-1.noarch.rpm
[root@wu1 ~]# cd /
[root@wu1 /]# yum list mysql*
[root@wu1 /]# yum install -y mysql-community-server.x86_64

3、rpm

安装前:下载rpm包,传到Linux中,在包所在的目录下输入rpm -ivh安装。
安装方式:rpm -ivh jdk-8u221-linux-x64.rpm
检查是否rpm安装过jdk:rpm -qa|grep jdk,该命令无法查到压缩包安装的软件,但能查到宝塔安装的软件。
强制卸载:rpm -e --nodeps jdk1.8.0_121-1.8.0_121-fcs.x86_64
安装目录:/usr,同yum。
安装完直接就能java -version这样。

4、解压缩(一般是.tar.gz压缩包)

安装前:下载压缩包,传到Linux中。
安装:.tar.gz压缩包:tar -zvxf /root/elasticsearch-7.12.0-linux-x86_64.tar.gz -C /opt,.zip压缩包:unzip -d /opt/elasticsearch-7.12.0/plugins/ik /root/elasticsearch-analysis-ik-7.12.0.zip。有的软件,解压就算安装好了,有的软件,还需要执行软件目录下的make.shmake.sh install
安装目录:自己定,一般是/usr/local或者/opt
启动:例子1:/opt/kafka_2.13-2.7.0/bin/zookeeper-server-start.sh -daemon /opt/kafka_2.13-2.7.0/config/zookeeper.properties,例子2:/opt/elasticsearch-7.12.0/bin/elasticsearch -d,例子3:nohup /opt/kafka_2.13-2.7.0/bin/kafka-server-start.sh /opt/kafka_2.13-2.7.0/config/server.properties 1>/dev/null 2>&1 &,-daemon或者-d或者&表示后台启动,最后的zookeeper.properties指用该配置文件启动。
但用压缩包解压安装后,要配置环境变量后才能nginx -v,要新建并写入配置文件/usr/lib/systemd/system/nginx.service后才能systemctl status nginx.service
配置nginx的systemctl命令 - 菜鸟的一天 - 博客园

[root@wu1 /]# whereis nginx
nginx: /usr/local/nginx
[root@wu1 /]# nginx -v
-bash: nginx: command not found
[root@wu1 /]# systemctl status nginx.service
Unit nginx.service could not be found.
[root@wu1 /]# vim /etc/profile	# 末尾加一行
export PATH=$PATH:/usr/local/nginx/sbin
[root@wu1 /]# source /etc/profile
[root@wu1 /]# nginx -v
nginx version: nginx/1.15.4
[root@wu1 /]# systemctl status nginx.service
Unit nginx.service could not be found.

优先使用哪种安装方式:宝塔面板>yum>rpm>压缩包。

参考

为什么配环境变量

为什么要配环境变量?path用来干什么?_Pre_waist_L的博客-CSDN博客_配置环境变量path的目的是什么

linux中yum和rpm区别

linux中yum与rpm区别_ziyun的博客-CSDN博客

Linux下软件包的多种安装方式

Linux下软件包的多种安装方式 | 《Linux就该这么学》

其他

查看某个软件是否安装过

whereis nginx:定位可执行文件、源代码文件、帮助文件在文件系统中的位置。
rpm -qa|grep jdk:查看是否用rpm/yum/宝塔面板 安装过jdk,该命令无法查到压缩包安装的软件。
举例:

# 压缩包安装的maven和elasticsearch
[root@wu1 ~]# rpm -qa |grep maven
[root@wu1 ~]# whereis maven
maven: /etc/maven

[root@wu1 ~]# rpm -qa |grep elasticsearch
[root@wu1 ~]# whereis elasticsearch
elasticsearch: /opt/elasticsearch-7.12.0/bin/elasticsearch

# yum安装的unzip
[root@wu1 ~]# rpm -qa |grep unzip
unzip-6.0-21.el7.x86_64
[root@wu1 ~]# whereis unzip
unzip: /usr/bin/unzip /usr/share/man/man1/unzip.1.gz

# 宝塔安装的php
[root@wu1 ~]# rpm -qa |grep php
bt-php80-8.0.3-1.el7.x86_64	# bt开头,宝塔的缩写
[root@wu1 ~]# whereis php
php: /usr/bin/php

配置环境变量

[root@wu1 ~]# vim /etc/profile	# 末尾加一行
export PATH=$PATH:/opt/apache-maven-3.8.1/bin
[root@wu1 ~]# source /etc/profile

查看Centos版本

[root@wu1 ~]# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)

查看是否启动了某进程

ps -ef | grep nginx

查看软件版本

nginx -v
mysql -V	# 这里需要是大写字母V
mvn -version	# maven

后台进程

软件vsftp的后台进程就是vsftpd。

搜索文件

[root@wu2 ~]# find / -name golang*	# 在"/"目录下模糊搜索。
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值