CV肉饼王

Talk is cheap. Show me the code.

0%

aws ec2 相关配置

一、环境依赖安装

1.安装git、vim、常用开发包

1
2
3
4
5
6
sudo dnf install -y git vim

sudo yum groupinstall "Development Tools"

#pyenv suggest package : https://github.com/pyenv/pyenv/wiki#suggested-build-environment
sudo yum install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel

2.安装pyenv:docs

1
curl https://pyenv.run | bash

3.path中设置pyenv:docs

1
2
3
4
5
6
7
8
9
# for bash:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile

take effect:

1
exec "$SHELL"

4.安装python 3.10

1
2
3
4
5
6
7
pyenv install 3.10

#检验
pyenv versions

#切换全局python版本
pyenv global 3.10.13

5.安装pdm

1
curl -sSL https://pdm-project.org/install-pdm.py | python3 -

初始化项目并安装依赖

1
2
3
pdm init
pdm use
pdm install

6.安装doppler

1
2
3
sudo rpm --import 'https://packages.doppler.com/public/cli/gpg.DE2A7741A397C129.key'
curl -sLf --retry 3 --tlsv1.2 --proto "=https" 'https://packages.doppler.com/public/cli/config.rpm.txt' | sudo tee /etc/yum.repos.d/doppler-cli.repo
sudo yum update && sudo yum install doppler

登录doppler

1
doppler login

二、安装redis及安全配置

参考:

How to install and configure Redis server on Amazon Linux 2023 (AL2023)

Redis配置文件详解

Setup redis-cli on AWS EC2

1.安装server端

1
2
3
4
5
6
sudo dnf install -y redis6
sudo systemctl start redis6
sudo systemctl enable redis6
sudo systemctl is-enabled redis6
redis6-server --version
redis6-cli ping

2.安装client端

1
2
3
sudo yum install -y gcc wget
wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make
sudo cp src/redis-cli /usr/bin/

3.安全配置

(1)强密码设置
1
2
# 生成requirepass
echo "xxxxxxxxxxxxxx" | sha256sum
(2)只允许本地访问
1
2
3
bind 127.0.0.1 -::1

protected-mode yes
(3)maxmemory设置
1
maxmemory 512MB
(4)重命名特殊指令
1
2
3
4
5
6
7
# `FLUSHDB, FLUSHALL, KEYS, PEXPIRE, DEL, CONFIG, SHUTDOWN, BGREWRITEAOF, BGSAVE, SAVE, SPOP, SREM, RENAME, DEBUG, EVAL`
rename-command CONFIG b840fc02d52404542994115f59e41cb7be6c522
rename-command FLUSHDB b840fc02d52404542994115f59e41cb7be6c533
rename-command FLUSHALL b840fc02d52404542994115f59e41cb7be6c544
rename-command EVAL b840fc02d52404542994115f59e41cb7be6c555
rename-command DEBUG b840fc02d52404542994115f59e41cb7be6c566
rename-command SHUTDOWN b840fc02d52404542994115f59e41cb7be6c77