" name="sm-site-verification"/>
侧边栏壁纸
博主头像
PySuper博主等级

千里之行,始于足下

  • 累计撰写 203 篇文章
  • 累计创建 14 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录
Web

CentOS7 服务器初始化

PySuper
2020-12-26 / 0 评论 / 0 点赞 / 13 阅读 / 11003 字
温馨提示:
所有牛逼的人都有一段苦逼的岁月。 但是你只要像SB一样去坚持,终将牛逼!!! ✊✊✊

一、配置静态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远程开发

点击这里查看如何配置Pycharm的远程连接


Django DeleteView 源码解析

Django CreateView、UpdateView 源码解析

Django ContentTypes 框架

Linux 下升级 Python 版本

Django WebSocket (一):WebSocket 概念及原理

Django WebSocket (二):Channels 概念及原理

Django WebSocket (三):Channels + WebSocket 实现在线聊天

Python 对数器实现与使用

Django Redis 缓存优化

Django ORM优化 和 SQL优化

Python 应用部署

代理 IP 抓取及使用(自动重连)

使用 pandas、xlrd、xlwt 读写 Excel

cookiecutter 火速创建 Django项目

Ngrok 实现 内网穿透

蓝绿部署、滚动部署、金丝雀发布(灰度发布)、A/B测试

冒泡排序、选择排序、插入排序

递归分析、归并排序

Python 自定义比较器

经典快排、随机快排、Python代码实现

堆排序、Python实现堆排序

桶排序、计数排序、基数排序

Crontab + Celery 定时处理异步任务

Django 信号机制、消息框架

分布式文件系统 NFS 配置(Deepin)

Kubernetes | Pod

Kubernetes | 资源清单

Kubernetes | 资源控制器

Kubernetes | Service

Kubernetes | 存储

Kubernetes | 集群调度

Kubernetes | 安全

Python 项目代码规范

MySQL 数据库拆分

实践:Crontab、Celery 分布式 异步

MySQL 创建用户与权限管理

GitLab、Jenkins、Harbor 安装 | CentOS、Docker

Nginx 常用配置

JetBrains | PyCharm 链接 GitLab | GitHub

DevOps | Docker | Harbor 安装与配置 | 踩坑

DevOps | GitLab CI/CD | Runner | Pipline | gitlab-ci.yml

0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区