手机版
你好,游客 登录 注册
背景:
阅读新闻

如何在 FreeBSD 10.2 上安装使用 Nginx 的 Ghost

[日期:2016-03-17] 来源:Linux中国  作者:Linux [字体: ]

第五步 - 为 Ghost 安装和配置 Nginx

默认情况下,ghost 会以独立模式运行,你可以不用 Nginx、apache 或 IIS web 服务器直接运行它。但在这篇指南中我们会安装和配置 nginx 和 ghost 一起使用。

用 pkg 命令从 freebsd 库中安装 nginx:

  1. pkg install nginx

下一步,进入 nginx 配置目录并为 virtualhost 配置创建新的目录。

  1. cd/usr/local/etc/nginx/
  2. mkdir virtualhost/

进入 virtualhost 目录,用 nano 编辑器创建名为 ghost.conf 的新文件:

  1. cd virtualhost/
  2. nano-c ghost.conf

粘贴下面的 virtualhost 配置:

  1. server {
  2. listen 80;
  3. #YourDomain
  4. server_name ghost.me;
  5. location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff)$ {
  6. access_log off;
  7. expires 30d;
  8. add_header Pragmapublic;
  9. add_header Cache-Control"public, mustrevalidate, proxy-revalidate";
  10. proxy_pass http://127.0.0.1:2368;
  11. }
  12. location /{
  13. add_header X-XSS-Protection"1; mode=block";
  14. add_header Cache-Control"public, max-age=0";
  15. add_header Content-Security-Policy"script-src 'self' ; font-src 'self' ; connect-src 'self' ; block-all-mixed-content; reflected-xss block; referrer no-referrer";
  16. add_header X-Content-Type-Options nosniff;
  17. add_header X-Frame-Options DENY;
  18. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  19. proxy_set_header Host $http_host;
  20. proxy_set_header X-Forwarded-Proto $scheme;
  21. proxy_pass http://127.0.0.1:2368;
  22. }
  23. location =/robots.txt { access_log off; log_not_found off;}
  24. location =/favicon.ico { access_log off; log_not_found off;}
  25. location ~/\.ht {
  26. deny all;
  27. }
  28. }

保存并退出。

要启用 virtualhost 配置,你需要把那个文件添加到 nginx.conf。进入 nginx 配置目录并编辑 nginx.conf 文件:

  1. cd/usr/local/etc/nginx/
  2. nano-c nginx.conf

在最后一行的前面,包含 virtualhost 配置目录:

  1. [......]
  2. include virtualhost/*.conf;
  3. }

保存并退出。

用命令 "nginx -t" 测试 nginx 配置,如果没有错误,用 sysrc 添加 nginx 到开机启动:

  1. sysrc nginx_enable=yes

并启动 nginx:

  1. service nginx start

现在测试所有 nginx 和 virtualhost 配置。请打开你的浏览器并输入: ghost.me

ghost.me 成功运行

ghost.me 成功运行

Ghost.me 正在成功运行。

如果你想要检查 nginx 服务器,可以使用 "curl" 命令。

测试 ghost 和 nginx

测试 ghost 和 nginx

Ghost 正在 nginx 上运行。

 

总结

Node.js 是 Ryan Dahl 为创建和开发可扩展服务器端应用程序创建的运行时环境。Ghost 是使用 node.js 编写的开源博客平台,它有漂亮的外观设计并且易于使用。默认情况下,ghost 是可以单独运行的 web 应用程序,并不需要类似 apache、nginx 或 IIS 之类的 web 服务器,但我们也可以和 web 服务器集成(在这篇指南中使用 Nginx)。Sqlite 是 ghost 默认使用的数据库,它还支持 msql/mariadb 和 postgresql。Ghost 能快速部署并且易于使用和配置。


via: http://linoxide.com/linux-how-to/install-ghost-nginx-freebsd-10-2/

作者:Arul 译者:ictlyh 校对:wxy

本文由 LCTT 原创编译,Linux中国 荣誉推出

本文永久更新链接地址http://www.linuxidc.com/Linux/2016-03/129259.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款