Rstudio网页在本地正确呈现,但不是从服务器

时间:2017-03-28 20:28:48

标签: r apache rstudio r-markdown

  • Dev Environment:R 3.3.2 / R Studio 0.99.1266 / Windows 7
  • Web服务器:Kubuntu;阿帕奇/ 18年2月14日
  • 浏览器:Firefox 52.0.1

上下文: 我有一套简单的网页,我在R Studio中创建了一个简短的课程系列。我在Windows机器上开发它,然后将_site文件夹复制到服务器。这是我第一次在R Studio中完成网页,但我的服务器最近也被替换了。

因此,我不知道这是一个RStudio问题还是我的Apache配置。而且我不知道如何诊断下面描述的问题所在。

问题

  • 在我的Windows计算机上看起来很好用Firefox作为file://网址

  • 当我在服务器上打开网站时,
  • 看起来也很好, 但是作为一个file:// URL(我有一个samba共享到服务器,让我把它看作另一个驱动器。)

  • 同样,如果我使用服务器计算机上的命令行工具xdg-open index.html打开网站,看起来还不错

  • 但是,当我在Windows机器或服务器机器上使用服务器http:// URL在Firefox中打开它时,没有渲染任何样式或其他属性正确。

为了说明:这是我看到的从我的Windows机器打开网站,file://网址

enter image description here

服务器网址为Introduction to R Graphics 看起来像这样:

enter image description here _site.yml文件很简单:

name: "RGraphics"
exclude: ["notes/", "sources/", "*.pptx", "*.bak"]
navbar:
  title: "An Introduction to R Graphics"
  type: inverse
  left:
    - text: "Home"
      icon: fa-home fa-2x   # handy way to use FontAwesome icons in nav!
      href: index.html
    - text: "Abstract"
      icon: fa-file  fa-2x
      href: abstract.html
    - text: "Resources"
      icon: fa-book  fa-2x
      href: resources.html

各种.Rmd文件也是如此,例如index.Rmd:

---
title: "An Introduction to R Graphics"
author: "Michael Friendly, SCS Short Course"
date: "March, 2017"
---

## Session 1: Overview

- Lecture notes: [1up PDF](R-Graphics1.pdf); [4up PDF](R-Graphics1-2x2.pdf)

#### Topics:

  + Getting started: R, R Studio
  + The roles of graphics in data analysis (exploration, analysis, presentation)
  + What can I do with R graphics: Anything! 
...

1 个答案:

答案 0 :(得分:0)

问题根源的诊断来自上面提到的403(禁止)错误。但问题的原因site_libs/的文件夹权限未正确设置。该文件夹以及包含javascript库的所有子文件夹都需要设置为755 (drwxr-xr-x),即允许所有用户对文件夹的读取和执行权限。

为什么会发生这种情况:R Studio在Windows上生成的site_libs/文件的属性不能很好地映射到Web服务器所需的Unix权限。

解决:在服务器上,cd到此网络树的顶层。然后,使用类似

的内容
 find . -type d -exec chmod 755  {} \;