然后原来的一元机就换系统了……
0x00.修改主机名
如果在创建实例时高级设置里指定了主机名,则会自动配置
1 | [root@txy ~]# cat /etc/hosts |
否则,手动更改
1 | [root@txy ~]# hostnamectl set-hostname txy.yuangezhizao.cn |
0x01.修改ssh
端口
改成非22
端口防止爆破
1 | [root@txy ~]# vim /etc/ssh/sshd_config |
注意一定要新开个shell
测试新端口是否生效,生效则可关闭旧shell
,否则需重新配置
0x02.软件
1 | yum update -y |
nfs-utils
:暂时10G
免费腾讯云文件系统COSFS
:https://github.com/tencentyun/cosfs直接在本地是相当爽了,可惜 Win 享受不到
0x03.挂载第三方存储
- 腾讯云文件存储即
CFS
- 腾讯云对象存储即
COS
白嫖的一年资源包最终效果可以说是相当爽了
0x04.编译安装python391环境
- 查看现有位置
1
[root@txy ~]# whereis python
现有路径
全新:
1 | [root@txy ~]# whereis python |
安装编译工具
yum groupinstall 'Development Tools' -y
1
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel -y
这里面有一个包很关键
libffi-devel
,因为只有3.7
才会用到这个包,如果不安装这个包的话,在make
阶段会出现如下的报错:# ModuleNotFoundError: No module named '_ctypes'
下载源码包
wget --no-check-certificate https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tar.xz
下载卡爆,jsproxy 启动!
或

1 | CloudFlare: |
- 解压
1
2tar xvJf Python-3.9.1.tar.xz
cd Python-3.9.1 - 编译
注:添加--enable-optimizations
(编译器优化)之后的编译速度会变慢,但理论上编译产物的运行效率?会提高不添加--enable-shared
(生成动态链接库)编译会报错:command 'gcc' failed with exit status 1
rm -rf /usr/local/python3
./configure --prefix=/usr/local/python3 --enable-shared --enable-optimizations
./configure --prefix=/usr/local/python3 --enable-optimizations
make && make install
- 修复
①2020-9-7 23:33:59
:CentOS 8
自带版本已为8
2020-5-22 00:06:54
:CentOS
自带gcc
版本是4
,升级至版本8
即可解决(而之前在ubuntu
编译的时候是版本7
,因此可以直接编译通过
再次编译,成功!
1 | [root@txy Python-3.8.3]# python3 |
②旧法(不推荐使用)添加--enable-shared
编译之后会报找不到so
的错误,此时可利用ldd
工具查看详细
1 | [root@txy ~]# python3 -V |
需要手动将所缺so
库libpython3.8.so.1.0
移至库目录下,具体生效路径为:/usr/lib64/
,这里测试/usr/lib/
、/usr/local/lib/
、/usr/local/lib64/
均无效……
1 | [root@txy ~]# cp libpython3.8.so.1.0 /usr/lib64/ |
- 创建软链接(
python3
&pip3
)
此法不会破坏自带py
环境,因此无需修改任何yum
文件注:更改yum
配置vim /usr/bin/yum
vim /usr/libexec/urlgrabber-ext-down
vim /bin/yum-config-manager
把#! /usr/bin/python
修改为#! /usr/bin/python2
①rm -rf /usr/bin/python3
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
②rm -rf /usr/bin/pip3
ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip3
1 | [root@txy Python 3.9.1]# python -V |
这样就可以通过好了,这下python
/python2
命令使用Python
,python3
来使用Python 3
2
终于彻底没有了
- 升级
pip3
你云环境下会自动配置镜像源pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install --upgrade pip
安装pip3
的另一种方法1
2curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py - 加入环境变量
1
2
3
4
5
6
7
8
9
10
11
12
13[root@txy ~]# cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
export PATH
0x05.安装Docker
- 卸载旧版本
1
2
3
4
5
6
7
8yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine - 使用源安装因国外下载速度过慢不得不去看Docker CE 源使用帮助
1
2
3
4yum install -y yum-utils
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repoCentOS、Fedora
等用户在下载docker-ce.repo
文件后,还需要将该文件中的download.docker.com
地址换成mirrors.ustc.edu.cn/docker-ce
yum clean all
再yum makecache
后开始安装
- 安装
yum install docker-ce docker-ce-cli containerd.io
根据Docker Hub 源使用帮助1
2
3
4
5[root@txy ~]# mkdir /etc/docker
[root@txy ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
} - 启动
systemctl start docker
- 测试
docker run hello-world
输出如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27[root@txy ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:6a65f928fb91fcfbc963f7aa6d57c8eeb426ad9a20c7ee045538ef34847f44f1
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/ - 自启
systemctl enable docker
0x06. 测速工具speedtest-cli
pip3 install speedtest-cli
1 | [root@txy ~]# speedtest-cli |
0x07.安装PHPStudy Linux 面板


一键安装yum install -y wget && wget -O install.sh https://download.xp.cn/install.sh && sh install.sh


0x08.编译安装Nginx
准备mkdir nginx_build && cd nginx_build
下载1.17.3
版本Nginx
源码wget http://nginx.org/download/nginx-1.17.3.tar.gz
tar -xvf nginx-1.17.3.tar.gz
下载0.1.18
版本nginx-module-vts
源码wget https://github.com/vozlt/nginx-module-vts/archive/v0.1.18.tar.gz
tar -xvf v0.1.18.tar.gz
安装依赖yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
编译安装cd nginx-1.17.3/
./configure --add-module=/root/nginx_build/nginx-module-vts-0.1.18
make && make install
修改配置文件vim /usr/local/nginx/conf/nginx.conf
1 | http { |
运行
1 | [root@txy ~]# /usr/local/nginx/sbin/nginx |
自启
将/usr/local/nginx/sbin/nginx
命令加入/etc/rc.d/rc.local
文件并赋予权限chmod +x /etc/rc.d/rc.local
0x09.测试延迟
也就只能凑合看下,不过拿来对比应该是可以的
①cn-py-dl-c7
1 | [root@py ~]# ping jrmkt.jd.com |
②cn-tx-bj1-w2d
1 | C:\LAB>ping jrmkt.jd.com |
③cn-tx-bj3-c8
1 | [root@txy ~]# ping jrmkt.jd.com |
由此可见家里肯定是最慢的了,另外北京一区比北京三区快1ms
0x10.引用
python –enable-shared
CentOS 7 升级gcc/g++编译器
3.7.0 build error with –enable-optimizations