一、配置静态IP
1、开启网络、更新
vi /etc/sysconfig/network-scripts/ifcfg-ens33
# 修改:
ONBOOT=on ==> ONBOOT=yes
service network restart
yum update
yum install net-tools
2、网卡配置
vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static # change
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=6efa4e7b-8bae-4998-a044-e7bc127bac2d
DEVICE=ens33
ONBOOT=yes
# 静态IP
IPADDR=111.111.111.151
# 默认网关
GATEWAY=111.111.111.2
# 子网掩码
NETMASK=255.255.255.0
# DNS 配置
DNS1=111.111.111.2
# 谷歌地址
DNS2=8.8.8.8
NM_CONTROLLED=no
# vi /etc/resolv.conf
nameserver 111.111.111.2
nameserver 8.8.8.8
# vi /etc/sysconfig/network-scripts/route-ens33
192.168.247.0 via 192.168.247.2
0.0.0.0 via 192.168.247.2
# vi /etc/sysconfig/static-routes
any net 192.168.247.0 netmask 255.255.255.0 gw 192.168.247.2
any net 0.0.0.0 netmask 0.0.0.0 gw 192.168.247.2
3、配置防火墙
# 重启
service network restart
# 关闭
systemctl stop firewalld
systemctl disable firewalld
二、安装Python
1、安装依赖
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel
yum -y install db4-devel libpcap-devel xz-devel
yum install libffi-devel -y
yum install epel-release -y
yum install gcc -y
yum install wget -y
2、安装Python
wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
tar -xvJf Python-3.7.2.tar.xz
cd Python-3.7.2
./configure --prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
3、安装pipenv
pip3 install pipenv
ln -s /usr/local/python3/bin/pipenv /usr/bin/pipenv
cd project_name
pipenv --python 3.7
4、配置cookiecutter
pip3 install cookiecutter
mkdir project
cd project
git clone https://github.com/pydanny/cookiecutter-django.git
/usr/local/python3/bin/cookiecutter cookiecutter-django
# 然后就是一系列的参数填写
三、配置数据库
MySQL
1、安装MySQL
rpm -qa | grep mariadb
rpm -e mariadb-libs-5.5.68-1.el7.x86_64 --nodeps
rpm -qa | grep mariadb
cd /usr/local/
mkdir mysql
cd mysql/
tar -xvf mysql-8.0.22-1.el7.x86_64.rpm-bundle.tar
rpm -ivh mysql-community-common-8.0.22-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-libs-8.0.22-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-client-8.0.22-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-server-8.0.22-1.el7.x86_64.rpm --nodeps --force
rpm -qa | grep mysql
2、配置MySQL
mysqld --initialize;
chown mysql:mysql /var/lib/mysql -R;
systemctl start mysqld.service;
systemctl enable mysqld;
cat /var/log/mysqld.log | grep pa # 查看密码
mysql -uroot -p
进入数据库修改
-- 修改密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
-- 重登
create user 'root'@'%' identified with mysql_native_password by 'root';
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;
-- 修改加密规则
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER;
flush privileges;
3、配置防火墙
# 安装并配置 iptables 防火墙
yum -y install iptables-services
systemctl enable iptables;
systemctl start iptables;
# 命令编辑防火墙,添加端口
vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8090 -j ACCEPT
# 防火墙重启并自启
systemctl restart iptables.service
systemctl enable iptables.service
Redis
1、安装redis
yum install -y gcc
wget http://download.redis.io/releases/redis-5.0.3.tar.gz
tar -zxvf redis-5.0.3.tar.gz
cd redis-5.0.3
make install PREFIX=/usr/local/redis
2、后台启动
cp /usr/local/redis-5.0.3/redis.conf /usr/local/redis/bin/
vi redis.conf
# 把 daemonize no 改为 daemonize yes
./redis-server redis.conf
4、开机启动
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
vi /etc/systemd/system/redis.service
# 复制粘贴上面的service配置(ExecStart配置成自己的路径)
# 设置开机启动
systemctl daemon-reload
systemctl start redis.service
systemctl enable redis.service
ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis
redis
4、服务操作命令
# 启动redis服务
systemctl start redis.service
# 停止redis服务
systemctl stop redis.service
# 重新启动服务
systemctl restart redis.service
# 查看服务当前状态
systemctl status redis.service
# 设置开机自启动
systemctl enable redis.service
# 停止开机自启动
systemctl disable redis.service
四、配置Pycharm远程开发
Django CreateView、UpdateView 源码解析
Django WebSocket (一):WebSocket 概念及原理
Django WebSocket (二):Channels 概念及原理
Django WebSocket (三):Channels + WebSocket 实现在线聊天
GitLab、Jenkins、Harbor 安装 | CentOS、Docker
JetBrains | PyCharm 链接 GitLab | GitHub
评论区