Linux 常用软件安装(Centos)

Centos 常用软件安装

一、Development tools

yum grouplist | more  						# 查看有那些组安装包可用
yum grouplist | grep Development			# 搜索和 Development 相关的
yum groupinstall -y "Development Tools" 	# 安装 Development Tools 工具包

二、yum-utils

yum -y install yum-utils

三、Docker

安装

使用官方脚本安装
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
# 也可以使用国内 daocloud 一键安装命令
curl -sSL https://get.daocloud.io/docker | sh

换源

编辑 /etc/docker/daemon.json文件,写入国内源:

{
  "registry-mirrors" : [
    "http://ovfftd6p.mirror.aliyuncs.com",
    "http://registry.docker-cn.com",
    "http://docker.mirrors.ustc.edu.cn",
    "http://hub-mirror.c.163.com"
  ],
  "insecure-registries" : [
    "registry.docker-cn.com",
    "docker.mirrors.ustc.edu.cn"
  ],
  "debug" : true,
  "experimental" : true
}

重启 docker:

service docker restart

查看换源是否成功:

docker info

output:
...
 Registry Mirrors:
  http://ovfftd6p.mirror.aliyuncs.com/
  http://registry.docker-cn.com/
  http://docker.mirrors.ustc.edu.cn/
  http://hub-mirror.c.163.com/
 ...

设置开机自启动:

systemctl enable docker.service

测试运行 hello-world:

docker run hello-world

Output:
Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

四、PostgreSQL 13

安装

# 1. 配置yum源
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm  

# 2. 安装 PostgreSQL
yum install -y postgresql13-server 

# 3. 初始化数据库
/usr/pgsql-13/bin/postgresql-13-setup initdb

# 4. 自启动
systemctl enable postgresql-13
systemctl start postgresql-13

初始化

# 1. 切换到 postgres 用户
su - postgres

# 2. 启动SQL Shell
psql

# 3. 修改密码
ALTER USER postgres WITH PASSWORD 'NewPassword';

配置远程访问

# 1. 开放防火墙端口
firewall-cmd --add-port=5432/tcp --permanent
firewall-cmd --reload

# 2. 修改IP绑定
#修改配置文件
vi /var/lib/pgsql/13/data/postgresql.conf

#将监听地址修改为 *
listen_addresses='*'

# 3. 允许所有IP访问
#修改配置文件
vi /var/lib/pgsql/13/data/pg_hba.conf

# 在文件底部写入:
host    all             all             0.0.0.0/0               md5

# 4. 重启PostgreSQL服务
systemctl restart postgresql-13

使用 Navicat 测试连接,连接成功!

五、Redis

安装

# 1. 下载 fedora 的 epel 仓库
yum install epel-release

# 2. 安装 Redis
yum install redis

# 3. 开机自启动
chkconfig redis on

# 4. 其他命令
# 启动redis
service redis start
# 停止redis
service redis stop
# 查看redis运行状态
service redis status
# 查看redis进程
ps -ef | grep redis

配置远程访问

# 1. 开放6379端口
firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --reload

# 2. 修改配置文件
vi /etc/redis.conf

# 查找 port 修改端口
port 6379
# 查找 requirepass 修改密码
requirepass NewPassword
# 配置远程访问
# 找到 bind 127.0.0.1 将其注释
# 找到 protected-mode yes 将其改为
protected-mode no

# 3. 停止并重启redis服务
# 停止
service redis stop
# 以配置文件重启
redis-server /etc/redis.conf &

使用

# 命令行交互
redis-cli

也可以使用:Another Redis Desktop Manager 在 Windows 管理 Redis 连接

六、Python

Python 2

Centos 自带了 Python 2.7,可直接进行使用

python2 -V
# Python 2.7.5

Python 3

yum 安装
# 安装 python 和 python3-devel
yum install -y python3 python3-devel

# 使用
python3 -V
# Python 3.6.8

pip3 升级与换源

# 换阿里源
pip3 config set global.index-url http://mirrors.aliyun.com/pypi/simple/
pip3 config set install.trusted-host mirrors.aliyun.com

# pip 升级
pip3 install --upgrade pip
手动安装最新版
# 1. 下载安装包
wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tgz

# 2. 解压
tar -zxvf Python-3.9.7.tgz
 
# 3. 下载编译依赖
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

# 4. 编译安装
cd Python-3.9.7
./configure --prefix=/usr/local/python39  # --prefix是Python的安装目录,同时安装了setuptools和pip工具
make && make install

# 5. 建立软连接
ln -s /usr/local/python39 /usr/local/bin/python3

# 6. 建立环境变量
# 编辑环境变量配置文件 $HOME/.bashrc,在文件末尾追加:
export PATH=/usr/local/python27/bin:/usr/local/python39/bin:$PATH

# 使更改生效
source $HOME/.bashrc

# 7. 查看版本
python3 -V
# Python 3.9.7

Hello World!

新建 hello.py文件,写入以下代码:

print("Hello World!")

运行该文件:

python3 hello.py
 # Hello World!

七、Go

yum 安装

# 安装
yum install golang

# 使用
go version
# go version go1.15.14 linux/amd64

二进制发行版安装

安装
# 1. 去官网下载最新版二进制包
wget https://studygolang.com/dl/golang/go1.18.linux-amd64.tar.gz
 
# 2. 提取压缩包内容
sudo tar -xzf go1.18.linux-amd64.tar.gz -C /usr/local

# 3. 简历软链接
sudo ln -s /usr/local/go/bin/* /usr/bin/

# 4. 验证是否成功
go version
# go version go1.17 linux/amd64
配置环境变量
# 编辑环境变量配置文件 $HOME/.bashrc,在文件末尾追加:
export GOROOT=/usr/local/go  #设置为go安装的路径,有些安装包会自动设置默认的goroot
export GOPATH=$HOME/go-work   #默认的Golang项目的工作空间
export GOBIN=$GOPATH/bin   # go install命令生成的可执行文件的路径
export PATH=$PATH:$GOROOT/bin:$GOBIN
# 保存,使配置文件生效
source $HOME/.bashrc
# 查看环境变量
go env

Go Modules 配置

# 换源
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
go env -w GOSUMDB=sum.golang.google.cn

Hello World!

新建 hello.go文件,写入以下代码:

package main

import "fmt"

func main() {
    fmt.Println("Hello World!")
}

运行该文件:

 go run hello.go
 # Hello World!

八、NodeJS

yum 安装

# 安装
yum install nodejs

# 使用
node -v
# v6.17.1
npm -v
# 3.10.10

二进制发行版安装

安装
# 1. 官网下载二进制发行版的压缩包
wget https://nodejs.org/dist/v14.17.6/node-v14.17.6-linux-x64.tar.xz

# 2. 解压
tar -xf node-v14.17.6-linux-x64.tar.xz -C /usr/local/

# 3. 创建软连接
ln -s /usr/local/node-v14.17.6-linux-x64/bin/* /usr/bin/

# 4. 添加环境变量
# 编辑环境变量配置文件 $HOME/.bashrc,在文件末尾追加:
export NODE_HOME=/usr/local/node-v14.17.6-linux-x64
export PATH=$NODE_HOME/bin:$PATH

# 使更改生效
source $HOME/.bashrc
Hello World!

新建 hello.go文件,写入以下代码:

function hello() {
   console.log('Hello World!');
}

hello();

运行该文件:

node hello.js
# Hello World!

九、Docker-compose 安装

最新发行的版本地址:https://github.com/docker/compose/releases

下载适合自己的版本:

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose

赋予二进制文件可执行权限:

sudo chmod +x /usr/local/bin/docker-compose

测试安装:

docker-compose --version

docker-compose version 1.29.2, build 5becea4c
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值