centos7基本环境安装

centos7基本环境安装

前置准备工作

yum update
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install -y libffi-devel zlib1g-dev
yum install zlib* -y

Nginx安装配置

yum install nginx -y  # yum里有自带的,方便安装
systemctl start nginx.service  # 启动Nginx
systemctl enable nginx.service  # 开机自启
systemctl disable nginx.service  # 关闭自启

Redis安装配置

首先下载你想安装的版本,默认官网最新
wget https://download.redis.io/releases/redis-6.2.4.tar.gz
tar xvf redis-6.2.4.tar.gz
cd redis-6.2.4
make
make install PREFIX=/usr  # 自定义安装目录
cp redis.conf /etc/  # 复制redis.conf配置文件到/etc/目录下。记得更改daemonize为yes
安装至此结束,以下配置redis服务
vim /usr/lib/systemd/system/redis.service  # 先创建服务名
复制以下内容

[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/redis-server /etc/redis.conf # 上面make install 的自定义目录你如果修改,这里也需要该
PrivateTmp=true

[Install]
WantedBy=multi-user.target

至此你可以通过systemctl来管理你的redis
systemctl start redis.service  # 启动Redis
systemctl enable redis.service  # 开机自启
systemctl disable redis.service  # 关闭自启

MySQL安装配置

首先前往MySQL官网下载yum配置包,只针对于yum
https://dev.mysql.com/downloads/repo/yum/
有centos7和8的选项,根据自己服务版本选择(我是centos7)
yum install https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm -y
yum update
yum install mysql-server # 可以看到安装的版本时最新的8.0版本,如需下载5.7版本,可以在上面下载yum源里选择
安装结束以后查看mysql默认密码
grep "A temporary password" /var/log/mysqld.log
mysql -u root -p
输入上面查询到的密码
修改mysql密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your password';  # 这里没有更改密码等级,如需修改弱密码,请自行Google
远程连接数据管理工具
。。。。待更新
启动、管理mysql
systemctl start mysqld.service  # 启动mysql
systemctl enable mysqld.service  # 开机自启
systemctl disable mysqld.service  # 关闭自启

postgresql安装配置

以下来自官网安装教程
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql13-server
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13

sqlite更新

官网下载最新sqlite
https://www.sqlite.org/download.html
wget https://www.sqlite.org/2021/sqlite-autoconf-3360000.tar.gz
tar xvf sqlite-autoconf-3360000.tar.gz
cd sqlite-autoconf-3360000
./configure --prefix=/usr
make && make install
查看当前sqlite版本
sqlite3 -version

python3更新

注意:如果使用Django框架运行sqlite数据库的项目会导致一个sqlite版本过低的问题,先更新sqlite在进行python的编译,不然无法解决这个问题
官网下载最新的python版本上传至服务器
tar -xvJf  Python.tar.xz
cd Python
./configure --prefix=/usr --enable-optimizations --with-ssl # 在centos7可能需要去掉--enable-optimizations才可能正常make
make && make install
安装结束
ln -s /usr/bin/pip3.9 /usr/bin/pip  # pip 软链接
workon环境配置
pip install virtualenvwrapper
添加环境变量内容
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
source /usr/bin/virtualenvwrapper.sh
poetry环境配置
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python3 -
添加环境变量内容
export PATH="$HOME/.local/bin:$PATH"
记得source .bashrc
至此python3最新版本安装完成

docker安装

curl -fsSL https://get.docker.com -o get-docker.sh
chmod u+x get-docker.sh
./get-docker.sh  # 等待安装完成
systemctl start docker.service  # 启动docker
systemctl enable docker.service  # 开机自启
systemctl disable docker.service  # 关闭自启
上一篇:PostgreSQL13 安装 psycopg2


下一篇:一键部署MySQL及自动补全功能