______ __ __
/\__ _\ __/\ \__ /\ \
\/_/\ \/ ___ /\_\ \ ,_\ \_\ \
\ \ \ /' _ `\/\ \ \ \/ /'_` \
\_\ \__/\ \/\ \ \ \ \ \_ __/\ \L\ \
/\_____\ \_\ \_\ \_\ \__\/\_\ \___,_\
\/_____/\/_/\/_/\/_/\/__/\/_/\/__,_ /
Batch scripts for Ruby production environment install on Ubuntu Server.
- Ubuntu Server 14.04, 16.04, 18.04
大多数情况下,服务器部署不应用 root 账户直接进行操作,所以如果你的服务器本身未创建非 root 账户(如 yxprod),你应该先创建一个非 root 账户。
注意将
yxprod替换成你希望创建的用户名。
adduser yxprod输入密码,确认密码后,一路回车即可创建成功。接下来,再将该账户设为sudo用户组,让它可以进行高级操作。
usermod -aG sudo yxprod安装系统常见需要的基本软件包,包括中文环境、Node.js、imagemagick、git、zsh、vim、unzip、htop及编译基础库。
sudo apt-get update
sudo apt-get install -y curl
curl -sSL https://jihulab.com/ivanlee/init.d/-/raw/master/install_packages | bash用 root 账号修改端口号(默认为 2345 端口,注意要在云服务器安全组放行):
sed -i 's/^.*Port.*/Port 2345/g' /etc/ssh/sshd_config禁用密码登陆:
sed -i 's/^.*PasswordAuthentication.*/PasswordAuthentication no/g' /etc/ssh/sshd_config防火墙放行 2345 端口:
ufw allow 2345/tcp使用如下命令重启ssh服务即可使用root账号和新的端口号登录ssh:
service ssh restart可以通过以上命令可以通过:
curl -sSL https://jihulab.com/ivanlee/init.d/-/raw/master/ssh_security | bashNginx official package
curl -sSL https://jihulab.com/ivanlee/init.d/-/raw/master/install_nginx | bashcurl -sSL https://jihulab.com/ivanlee/init.d/-/raw/master/install_rvm_ruby | bashDefault Use Ruby China mirror site for RubyGems and Ruby
curl -sSL https://jihulab.com/ivanlee/init.d/-/raw/master/install_postgresql | bashcurl -sSL https://jihulab.com/ivanlee/init.d/-/raw/master/install_mysql | bashcurl -sSL https://jihulab.com/ivanlee/init.d/-/raw/master/install_mongodb | bashcurl -sSL https://jihulab.com/ivanlee/init.d/-/raw/master/install_redis | bashcurl -sSL https://jihulab.com/ivanlee/init.d/-/raw/master/install_elasticsearch | bashcurl -sSL https://jihulab.com/ivanlee/init.d/-/raw/master/install_docker | bash
sudo docker info一键安装并启动 traefik 及 Portainer:
docker swarm init
curl https://jihulab.com/ivanlee/init.d/-/raw/master/docker-swarm/init-with-traefik-and-portainer > init-with-traefik-and-portainer
source init-with-traefik-and-portainer提前映射 dokku.xxx.com 和 *.dokku.xxx.com 两个 A 记录到指定服务器 IP。
在执行以下命令安装 Dokku 需要先 su root 切换到 root 用户。
$ curl -sSL https://jihulab.com/ivanlee/init.d/-/raw/master/install_dokku | bash
# Configure your server domain
$ dokku domains:set-global dokku.xxx.com
# and your ssh key to the dokku user
$ PUBLIC_KEY="your-public-key-contents-here"
$ echo "$PUBLIC_KEY" | dokku ssh-keys:add admin可以登录 dokku.xxx.com 完成剩下工作(如果访问是 nginx 默认页面,记得删掉 /etc/nginx/conf.d/default.conf 后 nginx -s reload)。
常见插件:
dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
dokku plugin:install https://github.com/dokku/dokku-mysql.git mysql
dokku plugin:install https://github.com/dokku/dokku-redis.git redis