CentOS安装配置
虚拟机最小安装之后无法上网的问题
# 修改网络配置脚本
cd /etc/sysconfig/network-scripts/
# 修改对应的网卡配置文件
vi ifcfg-ens33
# 把 NOBOOT=no -> NOBOOT=yes
# 重启网卡
nmcli c reload ens33
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
更新镜像源
# 备份
cd /etc/yum.repos.d/
mkdir repo_bak
mv *.repo repo_bak/
# 根据系统版本下载源 http://mirrors.aliyun.com/repo/
curl -o /etc/yum.repos.d/CentOS.repo http://mirrors.aliyun.com/repo/Centos-8.repo
# 清理缓存
yum clean all
yum makecache
# 更新系统
yum update
配置epel源
yum list | grep epel-release
yum install -y epel-release
# 替换为阿里云
vim /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux $releasever - $basearch
baseurl=https://mirrors.aliyun.com/epel/$releasever/Everything/$basearch
#metalink=https://mirrors.fedoraproject.org/metayumlink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
[epel-debuginfo]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Debug
baseurl=https://mirrors.aliyun.com/epel/$releasever/Everything/$basearch/debug
#metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1
[epel-source]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Source
baseurl=https://mirrors.aliyun.com/epel/$releasever/Everything/SRPMS
#metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1
# 清理缓存
yum clean all
yum makecache
安装jdk 11
yum search openjdk
yum install java-11-openjdk-devel.x86_64
# 切换jdk版本
alternatives --config java
安装Erlang
# 获取源码
wget http://erlang.org/download/otp_src_23.1.tar.gz
# 解压
tar -zxvf otp_src_23.1.tar.gz
cd otp_src_23.1
# 创建安装目录
mkdir /usr/local/erlang
# 安装依赖
yum install -y gcc gcc-c++ unixODBC-devel openssl-devel ncurses-devel
# 配置编译
./configure --prefix=/usr/local/erlang
make
make install
# 配置环境变量
vim /etc/profile
export ERLANG_HOME=/usr/local/erlang
export PATH=$ERLANG_HOME/bin:$PATH
source /etc/profile
# 验证
erl
halt()
erl -version
安装 Docker
# 设置仓库
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# x86_64 containerd.io
wget https://download.docker.com/linux/centos/7/x86_64/edge/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
yum -y install containerd.io-1.2.6-3.3.el7.x86_64.rpm
# aarch64 containerd.io
wget https://download.docker.com/linux/centos/7/aarch64/edge/Packages/containerd.io-1.2.6-3.3.el7.aarch64.rpm
yum -y install containerd.io-1.2.6-3.3.el7.aarch64.rpm
# 安装Docker Engine-Community
sudo yum install -y docker-ce docker-ce-cli
# 启动docker
sudo systemctl start docker
# 停止docker
sudo systemctl stop docker
# 检查是否安装成功
sudo docker run hello-world
# 查看docker信息
docker info
安装nginx
# 安装gcc
yum -y install gcc
gcc -v
# 安装pcre库,pcre是一个perl库,包括perl兼容的正则表达式库,nginx的http模块使用pcre来解析正则表达式
yum install -y pcre pcre-devel
# 安装zlib库 zlib库提供了很多种压缩和解压缩方式nginx使用zlib对http包的内容进行gzip
yum install -y zlib zlib-devel
# 安装openssl openssl是web安全通信的基石
yum install -y openssl openssl-devel
# 下载nginx源码包
wget http://nginx.org/download/nginx-1.16.1.tar.gz
# 解压到指定目录
tar -zxvf nginx-1.16.1.tar.gz -C /usr/local/
# 进入目录编译安装
./configure
make
make install
# 修改配置文件
vim /usr/local/nginx/conf/nginx.conf
# 启动服务
cd /usr/local/nginx/sbin
./nginx
# 查看是否启动成功
ps -ef | grep nginx
nginx加入到系统服务中
# 在 /usr/lib/systemd/system 目录中添加 nginx.service 文件
vim nginx.service
# 添加以下内容
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
# 测试
systemctl status nginx
# 设置开机启动
systemctl enable nginx
更新软件
# 检查是否有更新
yum check-update
# 更新
yum update
安装常用工具
# 获取screenfetch
wget -O screenfetch https://git.io/vaHfR
# 文件拷贝到 bin 目录下面
cp screenfetch /usr/bin
# 添加执行权限
chmod +x screenfetch
# 安装 vim
yum -y install vim
# 安装wget
yum -y install wget
# 安装netTools
yum -y install net-tools
# 安装rz
yum -y install lrzsz
# 安装 tar
yum -y install tar
# 安装 make
yum -y install make
# 安装 gcc
yum -y install gcc
# 安装 telnet
yum -y install telnet
# 安装 killall
yum -y install psmisc
BBR
# 查看是否开启
sysctl net.ipv4.tcp_available_congestion_control
# 查看配置是否正常
sysctl -p