最近有接下公司配管的活,有一些环境需要安装,记录下来:
### 遇到问题1 ``` Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Setting up Install Process No package gcc available. Error: Nothing to do ``` #### 没有网络, ping一下,发现可以ping通,可能是yum源没用了, 将yum源改到阿里云 ##### 1. 备份 ``` mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup ``` ##### 2. 下载新的CentOS-Base.repo 到/etc/yum.repos.d/ ``` cd /etc/yum.repos.d wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 或者 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo ``` ##### 3. 运行 yum makecache生成缓存 ``` yum clean all ``` ### 2. 安装Python3.7 #### 一、安装依赖包 ``` yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make ``` #### 二、再执行安装一个工具,不安装会导致pip安装失败 ``` yum install libffi-devel -y ``` #### 三、下载python3.7的包 ##### 1. wget安装 ``` wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz ``` ##### 2. 安装python3.7 ``` tar -zxvf Python-3.7.0.tgz cd Python-3.7.0 ./configure make&&make install ``` ##### 3. 配置环境变量 ``` mv /usr/bin/python /usr/bin/python.bak ln -s /usr/local/bin/python3 /usr/bin/python mv /usr/bin/pip /usr/bin/pip.bak // 这一步好多人报错,可以省略。 ln -s /usr/local/bin/pip3 /usr/bin/pip ``` ##### 4. 配置yum 因为系统自带2.7,这时你使用yum是使用不了的 修改一下 ``` vim /usr/libexec/urlgrabber-ext-down ``` 在/usr/bin/python后面加上2.7 ``` vi /usr/bin/yum ``` 同上,就可以了 ### 安装Java1.7 #### 1. 下载Java1.7 #### 2. 查看CentOS自带JDK是否已安装。 ``` yum install list | grep java ``` #### 3. 卸载Java环境 ``` yum -y remove java-1.7.0 yum -y remove tzdata-java.noarch ``` #### 4. 安装 ``` mkdir /usr/local/java/ tar -zxvf jdk-7u80-linux-x64.tar.gz -C /usr/local/java/ ``` #### 5. 设置环境变量 ``` vim /etc/profile 末尾添加 export JAVA_HOME=/usr/local/java/jdk1.8.0_171 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH source /etc/profile ln -s /usr/local/java/jdk1.8.0_171/bin/java /usr/bin/java ``` java -version检查是否成功
### 3. c++安装