ourfor / blog

利用GitHub的Issues记录
https://github.com/ourfor/blog/issues
1 stars 0 forks source link

备份一下VPS设置 #15

Open ourfor opened 5 years ago

ourfor commented 5 years ago

安装ffmpeg,运行后老是出现符号未定义,后来新开了一台vps发现全新的系统上面没有这个问题,所以我打算重装,得备份一下,这服务器我主要是弄了一些web服务,还有一些上网的东西,还好这些东西我都放在/root目录下的,这样我新开一台主机,把备份的恢复过去,原来的主机重装之后,再用sftp把重要的文件get过来。

安装ffmpeg FFmpeg包在RPMfusion存储库中可用,使用以下命令将其添加到Fedora系统中:

sudo dnf -y install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf -y install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
dnf install ffmpeg ffmpeg-devel
ourfor commented 5 years ago

管理服务器的一些好习惯:(web方面)

SELINUX=enforcing

SELINUX=disabled

ourfor commented 5 years ago
ourfor commented 5 years ago

平时我经常用到的软件有很多,记下来,一键安装,脚本以后再写:

sudo dnf install -y caddy zsh curl nmap wget vim youtube-dl git screen neofetch
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

安装mysql链接

ourfor commented 5 years ago

caddy在系统服务中打开ProtectHome=true,这样就有资格访问/home目录了

ourfor commented 5 years ago

安装php

dnf install -y php-fpm php php-json

启动php-fpm

systemctl start php-fpm

监听9000配合caddy

vim /etc/php-fpm.d/www.conf

listen = /tmp/php-cgi.sock下一行加上:

listen = 127.0.0.1:9000

重启php-fpm

systemctl restart php-fpm
ourfor commented 5 years ago

设置ssh验证,免密码登陆:

scp .ssh/id_rsa.pub root@ip.ourfor.top:~/.ssh

如果服务器没有authorized_keys

cp  id_rsa.pub  authorized_keys

否则:

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ourfor commented 5 years ago

配置Minecraft后台自动运行,来自agowa338

# Source: https://github.com/agowa338/MinecraftSystemdUnit/
# License: MIT
[Unit]
Description=Minecraft Server %i
After=network.target

[Service]
WorkingDirectory=/opt/minecraft/%i
PrivateUsers=true # Users Database is not available for within the unit, only root and minecraft is available, everybody else is nobody
User=minecraft
Group=minecraft
ProtectSystem=full # Read only mapping of /usr /boot and /etc
ProtectHome=true # /home, /root and /run/user seem to be empty from within the unit. It is recommended to enable this setting for all long-running services (in particular network-facing ones).
ProtectKernelTunables=true # /proc/sys, /sys, /proc/sysrq-trigger, /proc/latency_stats, /proc/acpi, /proc/timer_stats, /proc/fs and /proc/irq will be read-only within the unit. It is recommended to turn this on for most services.
# Implies MountFlags=slave
ProtectKernelModules=true # Block module system calls, also /usr/lib/modules. It is recommended to turn this on for most services that do not need special file systems or extra kernel modules to work
# Implies NoNewPrivileges=yes
ProtectControlGroups=true # It is hence recommended to turn this on for most services.
# Implies MountAPIVFS=yes

ExecStart=/bin/sh -c '/usr/bin/screen -DmS mc-%i /usr/bin/java -server -Xms512M -Xmx2048M -XX:+UseG1GC -XX:+CMSIncrementalPacing -XX:+CMSClassUnloadingEnabled -XX:ParallelGCThreads=2 -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -jar $(ls -v | grep -i "FTBServer.*jar\|minecraft_server.*jar" | head -n 1) nogui'

ExecReload=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "reload"\\015'

ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "say SERVER SHUTTING DOWN. Saving map..."\\015'
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "save-all"\\015'
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "stop"\\015'
ExecStop=/bin/sleep 10

Restart=on-failure
RestartSec=60s

[Install]
WantedBy=multi-user.target

#########
# HowTo
#########
#
# Create a directory in /opt/minecraft/XX where XX is a name like 'survival'
# Add minecraft_server.jar into dir with other conf files for minecraft server
#
# Enable/Start systemd service
#    systemctl enable minecraft@survival
#    systemctl start minecraft@survival
#
# To run multiple servers simply create a new dir structure and enable/start it
#    systemctl enable minecraft@creative
# systemctl start minecraft@creative