前端 CentOS 7 新服配置参考

发布于 2025-06-10 13:00:40 字数 0 浏览 0 评论 0

我自己搭服务器的偏好是 CentOS,每次开新服都要执行一遍环境配置,步骤繁多难免遗漏,总是发现缺东西了再去安装。备个忘,再不烦恼。

本文介绍的组件包括: git , nginx , nodejs , fishshell ,环境是 DigitalOcean 的 CentOS 7 镜像(6 就不管了,初建服务器你还不用最新版是何居心?)。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。