首页 > 解决方案 > What are the nginx configuration settings to host a Rblogdown site on a digital ocean droplet?

问题描述

I'm trying to host a static site on a digital ocean droplet and am having a bit of trouble in deploying the site. I've searched for solutions across the interwebs with limited success and I'm also learning while doing so to speak, so any help would be greatly appreciated. I also apologize if I am using incorrect terms and if I am giving too much or irrelevant information. I'd rather err on the side of too much so it might be easy to spot if I did something wrong.

Goal: To have R, Rstudio, R server on a digital ocean droplet and connect to a domain I have purchased. Use the R blogdown package to create a static website and also deploy this on the droplet.

Completed steps:

1) Installed linux on droplet, installed R, R studio, R server, shinny on droplet. This is working fine.

2) Added nameservers to point to my domain to my digital ocean IP. This is working : www.mysite.com:8787 goes to my Rstudio login, www.mysite.com:3838 goes to shinny server. I'd like to change the 8787 and 3838 to something more descriptive, but I'm sure I can figure this out at a later point.

3) Generated a static test site in blogdown. Location is /home/user/website/public, where website is a R blogdown project and public is the folder which has the index.html file and all the generated files from the blogdown site generation. This works within R studio and files are created.

4) Attempted to change the nginx setttings by altering the default file: /etc/nginx/sites-enabled/default to redirect to the /home/user/website/public directory.

This is where I'm stuck. I've followed a couple of guides and whatever I seem to do www.mysite.com always displays the nginx welcome page.

What I've tried:

chmod - R 0755 /home/user/website/public

I belive this gives recursive permission to the folder where my static site is held.

to edit the default file:

sudo nano /etc/nginx/sites-enabled/default

I've changed the root line to my static site directory and server_name line to www.mysite.com (also tried actual IP address)

root /home/user/website/public

server_name www.mysite.com mysite.com

Following some guides, I have also attempted to make a server block and link it.

created a new file, mysite.com containing the following:

server {
        listen 80;
        listen [::]:80;

        root /home/user/website/public;
        index index.html index.htm index.nginx-debian.html;

        server_name mysite.com www.mysite.com;

        location / {
                try_files $uri $uri/ =404;
        }
}

then link it:

sudo ln -s /etc/nginx/sites-available/mysite.com /etc/nginx/sites-enabled/

I have tried various combinations of these methods from different guides with the same result - a nginx welcome page at www.mysite.com.

Just uninstalled and reinstalled nginx to start with a clean slate.

Am I on the right track here with methodology? Has anyone had success hosting a R blogdown site on a digital ocean droplet and can share some advice or spot what I need to do?

标签: nginxrstudioblogdown

解决方案


推荐阅读