我自己搭服务器的偏好是 CentOS,每次开新服都要执行一遍环境配置,步骤繁多难免遗漏,总是发现缺东西了再去安装。备个忘,再不烦恼。
本文介绍的组件包括:git
, nginx
, nodejs
, fishshell
,环境是 DigitalOcean 的 CentOS 7 镜像(6就不管了,初建服务器你还不用最新版是何居心?)。
小安利下,我的DigitalOcean 推荐链接,注册即得10美元(推荐双方都有),开服愉快!
CentOS 新服务器
首先安装 epel-release,各种软件包都依赖于这个软件源
$ yum update -y
$ yum install -y epel-release
$ yum install -y git
一点安全措施
启用 SSH 密钥登陆。编辑
~/.ssh/authorized_keys
,添加自己的公钥进去。禁用密码登陆。编辑
/etc/ssh/sshd_config
,启用以下几行:
PubkeyAuthentication yes
AuthorizedKeyFile .ssh/authorized_keys
PasswordAuthentication no
ChallengeResponseAuthentication no
然后重启 sshd 服务:
$ service sshd reload
https://www.liberiangeek.net/2014/07/enable-ssh-key-logon-disable-password-password-less-logon-centos/
http://serverfault.com/questions/285800/how-to-disable-ssh-login-with-password-for-some-users
http://askubuntu.com/questions/387892/how-to-deny-root-ssh-login-require-ssh-key-for-user
nginx 启动!
$ yum install nginx -y
http://www.rackspace.com/knowledge_center/article/centos-adding-an-nginx-init-script
Node 和它的朋友们
$ yum install nodejs -y
$ curl https://www.npmjs.com/install.sh | sh
$ npm install -g n pm2
最后,需要在 ghost 的 nginx 配置中添加一行 client_max_body_size 10G;
像这样:
server {
listen 80;
server_name ~b(log)*.amio.us$;
client_max_body_size 256M;
# ...
}
Oh-my-fish!
下面是一些个人喜好,装个 fish shell。
$ yum install yum-utils
$ yum-config-manager --add-repo http://fishshell.com/files/linux/RedHat_RHEL-6/fish.release:2.repo
# CentOS 7 用这个地址:
# http://download.opensuse.org/repositories/shells:fish:release:2/CentOS_7/shells:fish:release:2.repo
$ yum install fish -y
# 把默认 shell 改为 fish
$ chsh -s /usr/bin/fish
如果 fish 报告错误:
fish: Tried to print invalid wide character string
则编辑此文件:
$ vim /etc/sysconfig/i18n
# 把其中的 LANG=C 改为 LANG=en_GB.UTF-8
http://serverfault.com/questions/275403/how-do-i-change-my-locale-to-utf-8-in-centos