2019年刚开始玩 VPS 时候记的笔记。现在看来都是基础到没必要提的东西。
因为天天折腾VPS,折腾坏好几次了,每次都吃屎重装。做个总结,免得下次吃屎时候忘了装一些东西了。
关闭22端口
修改密码:passwd
1
2
3
4
5
6
7
8
| vi /etc/ssh/sshd_config
#PermitUserEnvironment no
#Compression delayed
ClientAliveInterval 30
ClientAliveCountMax 5
#ShowPatchLevel no
#UseDNS yes
|
找到 #Port 22
这行(默认端口22),把前面的 # 去掉,然后再添加一个新的端口(不超过65535),比如 Port 56789:
service sshd restart
接下来,在防火墙 /etc/sysconfig/iptables 里开启此端口:
1
2
| iptables -A INPUT -p tcp -m tcp --dport 56789 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
|
保存并重启防火墙:
1
2
| service iptables save
service iptables restart
|
1
2
3
4
5
6
7
| yum -y update
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
|
BBR 加速
1
| wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
|
输入sysctl net.ipv4.tcp_available_congestion_control
检查
出现net.ipv4.tcp_available_congestion_control = reno cubic bbr
时,说明成功
LNMP 安装
1
| wget -c http://soft.vpser.net/lnmp/lnmp1.6-full.tar.gz && tar -zxf lnmp1.6-full.tar.gz && cd lnmp1.6-full && ./install.sh lnmp
|
修改主页
1
2
3
| cd /home/wwwroot/default
mv phpmyadmin hereispma
mv index.html random-name.html
|
安装缓存优化。在lnmp1.6-full文件夹下:
1
2
3
| ./addons.sh install opcache
./addons.sh install memcached
./addons.sh install imagemagick
|
包管理工具
SSL 证书
Docker 配置
1
2
3
4
| curl -fsSL https://get.docker.com/ | sh
service docker start
docker version
systemctl enable docker
|
PostgreSQL
来自官网,可自行选择对应发行版的安装包。
1
2
3
| yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install postgresql11
yum install postgresql11-server
|
Node.js 和 npm
1
2
3
4
| yum info epel-release
如果没有则
sudo yum install epel-release
sudo yum install nodejs
|
也可以直接在官网上下载最新版本的安装包然后解压缩出来,建立两个软链接。
1
2
| ln -s ~/node-vxxxxx-linux-x64/bin/node /usr/bin/node
ln -s ~/node-vxxxxx-linux-x64/bin/npm /usr/bin/npm
|
Hexo
2019年10月更新:可能是Hexo或者node.js更新后的问题。出了个很奇怪的现象,centOS下输入
后hexo并不会写入/usr/bin,需要手动建立软链接。
而且还会提示有个依赖包在centOS下不给用:
1
2
| npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/hexo-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
|
当然这只是个可选项,实际上hexo本身是能用的,囧。
hexo被安装在nodejs/lib/node_modules/hexo-cli/bin/hexo
,以你安装的位置建立软链接即可。
Git
Ruby
1
2
3
| gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable --ruby
|
rz 命令
Python3
前往https://www.python.org/ftp/python寻找最新版本python的tar包下载,上传到服务器上。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| tar -xf Python-x.x.x.tgz
cd Python-x.x.x
yum install gcc-c++
yum install pcre pcre-devel
yum install zlib zlib-devel
yum install openssl openssl--devel
mkdir /usr/Python3#<=====创建目录
./configure --prefix=/usr/Python3#<====绑定安装目录
make #<=====编译初始化
make install #<====安装
ln -s /usr/Python3/bin/python3 /usr/bin/python3
ln -s /usr/Python3/bin/pip3 /usr/bin/pip3
|
linux 下安装 OpenGL 相关库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| yum install mesa-libGL-devel.x86_64
yum install mesa-libGLU-devel.x86_64
#error: X11/extensions/Xrandr.h: No such file or directory
yum install libXrandr-devel.x86_64
yum install libXinerama-devel.x86_64
yum install libXcursor-devel.x86_64
#解决/usr/bin/ld: cannot find -lXi
ln -s /usr/lib64/libXi.so.6 /usr/lib64/libXi.so
#pkg-config –cflags portaudio-2.0
#Package portaudio-2.0 was not found in the pkg-config search path.
#Perhaps you should add the directory containing `portaudio-2.0.pc’
#to the PKG_CONFIG_PATH environment variable
#No package ‘portaudio-2.0’ found
#pkg-config: exit status 1
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
|
P3terx aria2-pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| docker run -d \
--name aria2-pro \
--restart unless-stopped \
--log-opt max-size=1m \
--network host \
-e PUID=$UID \
-e PGID=$GID \
-e RPC_SECRET=yoursecret \
-e RPC_PORT=6800 \
-p 6800:6800 \
-e LISTEN_PORT=6888 \
-p 6888:6888 \
-p 6888:6888/udp \
-v ~/aria2-config:/config \
-v ~/download:/downloads \
-e SPECIAL_MODE=rclone \
p3terx/aria2-pro
|