1.环境说明
系统:MacOS 10.12.5 (16F73)
容器:VirtualBox 5.1.10 r112026 (Qt5.6.2)
镜像:CentOS-7-x86_64-Minimal-2009.iso
VirtualBox创建centos7虚拟机:很简单,不啰嗦了。
设置网卡
VirtualBox设置网卡链接方式为桥接
查看ip地址ip addr
以后用ssh客户端连接。
关闭SELinux 1 2 3 vi /etc/selinux/config 将`SELINUX=enforcing`改为`SELINUX=disabled` 重启 reboot
禁用防火墙 1 2 3 systemctl stop firewalld.service systemctl disable firewalld.service firewall-cmd --state
安装基础软件 1 yum -y install wget automake autoconf libtool make gcc gcc-c++ zip unzip
使用国内yum源(可选) repo 源一般包括 base, updates, Extras 三部分。
1 2 3 4 5 6 7 8 9 cd /etc/yum.repos.d/ mv CentOS-Base.repo CentOS-Base.repo.backup wget http://mirrors.163.com/.help/CentOS7-Base-163.repo yum clean all yum makecache yum -y update yum -y upgrade yum -y install epel-release
查看已安装的源(可选)
查看centos版本(可选) 命令 lsb_release -a
或者 cat /etc/redhat-release
1 2 3 4 5 LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch Distributor ID: CentOS Description: CentOS release 5.4 (Final) Release: 5.4 Codename: Final
用户管理(可选)
创建用户 useradd admin
设置密码 passwd admin
添加sudo权限 1 2 chmod -v u+w /etc/sudoers vi /etc/sudoers
1 2 3 ## Allow root to run any commands anywher root ALL=(ALL) ALL admin ALL=(ALL) ALL
取消 sudoers 文件可写权限1 chmod -v u-w /etc/sudoers
2.安装软件 安装git 1 2 yum install -y git git config --global credential.helper store #记住用户名密码,不用每次输入
安装jdk 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #查看已经安装(若有,则卸载) java -version rpm -qa | grep java rpm -e --nodeps tzdata-java-2012c-1.el6.noarch rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64 rpm安装(二选一,不推荐) wget https://d6.injdk.cn/oraclejdk/8/jdk-8u341-linux-x64.rpm rpm -ivh jdk-8u212-linux-x64.rpm java -version cd /usr/java tar.gz安装(二选一,推荐) 其他jdk版本下载请访问:https://www.injdk.cn/ wget https://d6.injdk.cn/oraclejdk/8/jdk-8u381-linux-x64.tar.gz mkdir -p /usr/java #解压到rpm安装方式的默认目录 tar -zxvf jdk-8u381-linux-x64.tar.gz -C /usr/java cd /usr/java mv jdk1.8.0_341 jdk8
安装maven 1 2 3 4 5 6 7 其他版本maven下载请访问:https://mirrors.huaweicloud.com/apache/maven/maven-3/ wget https://repo.huaweicloud.com/apache/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.tar.gz tar -xvf apache-maven-3.8.3-bin.tar.gz -C /usr/local/ cd /usr/local/ mv apache-maven-3.8.3 maven3 cd /usr/local/maven3/conf vi settings.xml
创建本地仓库存储路径 mkdir -p /opt/mvnrepo
1 2 3 4 5 6 7 8 9 10 <localRepository > /opt/mvnrepo</localRepository > <mirrors > <mirror > <id > aliyun-maven</id > <mirrorOf > *,!dxrj-maven</mirrorOf > <name > aliyun-maven</name > <url > https://maven.aliyun.com/repository/public</url > </mirror > </mirrors >
配置环境变量
vi /etc/profile
1 2 3 4 export JAVA_HOME=/usr/java/jdk8 export MAVEN_HOME=/usr/local/maven3 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
source /etc/profile
安装nodejs 下载地址 https://registry.npmmirror.com/binary.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 cd ~/ 【node14】过时,不推荐 wget https://registry.npmmirror.com/-/binary/node/latest-v14.x/node-v14.21.3-linux-x64.tar.gz tar -xvf node-v14.21.3-linux-x64.tar.gz -C /usr/local/ cd /usr/local/ mv node-v14.21.3-linux-x64 nodejs 【node16】主流,16最后一个版本 wget https://registry.npmmirror.com/-/binary/node/latest-v16.x/node-v16.20.1-linux-x64.tar.gz tar -xvf node-v16.20.1-linux-x64.tar.gz -C /usr/local/ cd /usr/local/ mv node-v16.20.1-linux-x64 nodejs 【node18】改动较大,nuxt3必须大于等于18 wget https://registry.npmmirror.com/-/binary/node/latest-v18.x/node-v18.19.0-linux-x64.tar.gz tar -xvf node-v18.19.0-linux-x64.tar.gz -C /usr/local/ mv node-v18.19.0-linux-x64 nodejs18 #非系统默认,jenkins使用 cd /usr/local/nodejs/bin ./node -v ln -s /usr/local/nodejs/bin/node /usr/bin/node ln -s /usr/local/nodejs/bin/npm /usr/bin/npm ln -s /usr/local/nodejs/bin/npx /usr/bin/npx npm config set registry https://registry.npmmirror.com
https://www.cnblogs.com/yajunLi/p/13850686.html
tengine 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 yum -y install openssl openssl-devel pcre pcre-devel wget http://tengine.taobao.org/download/tengine-2.3.2.tar.gz tar -zxvf tengine-2.3.2.tar.gz cd tengine-2.3.2 ./configure --prefix=/usr/local/nginx make && make install cd /usr/local/nginx/sbin ./nginx https://www.cnblogs.com/zhuwenjoyce/p/10878804.html 以下是安装nginx官方版本 yum install -y pcre pcre-devel gcc zlib zlib-devel openssl openssl-devel wget http://nginx.org/download/nginx-1.20.1.tar.gz tar -zxvf nginx-1.20.1.tar.gz cd nginx-1.20.1 ./configure --prefix=/usr/local/nginx make && make install cd /usr/local/nginx/sbin ./nginx
配置nginx 1 2 mkdir -p /usr/local/nginx/conf/cert mkdir -p /usr/local/nginx/conf/vhosts
安装docker 1 2 3 4 5 6 7 sudo yum install -y yum-utils device-mapper-persistent-data lvm2 sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo sudo yum makecache fast sudo yum -y install docker-ce sudo service docker start systemctl enable docker systemctl daemon-reload
设置国内源 vi /etc/docker/daemon.json
1 2 3 4 5 6 7 { "registry-mirrors": [ "https://registry.docker-cn.com", "http://hub-mirror.c.163.com", "https://docker.mirrors.ustc.edu.cn" ] }
安装portainer-ce(docker可视化) 1 2 3 docker pull portainer/portainer-ce docker volume create portainer_data docker run -d -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce