Skip to content

Commit

Permalink
made minor revisions to shiny server documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
angelchen7 committed Sep 15, 2023
1 parent 21d7aaf commit effa589
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions _freeze/shiny-server/execute-results/html.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"hash": "f9de842cbe94dd51d451b6bff019a34e",
"hash": "e7f27b4540a1cd8130d897690e1a3ed4",
"result": {
"markdown": "---\ntitle: \"Deploy Shiny Apps\"\nengine: knitr\n---\n\n:::callout-note\nPlease note that the following instructions for deploying Shiny apps are meant to serve as internal documentation and will only work if you have `sudo` power on the SciComp team's Shiny server.\n\nFeel free to [contact us](https://nceas.github.io/scicomp.github.io/staff.html) if you have a LTER-related Shiny app that you would like to deploy on our server!\n:::\n\nSciComp team members can deploy LTER-related Shiny apps on our server at: [https://shiny.lternet.edu/](https://shiny.lternet.edu/)\n\nTo deploy your working app, first make sure that all the files live at a GitHub repository. Once our sysadmin Nick Outin has made you an account on the server, you can log in via SSH. \n\n## Log In\n\nFor Mac users, open the Terminal app and type the following command, replacing `<YOUR-USERNAME>` with your own username. \n\n::: {.cell}\n\n```{.bash .cell-code}\nssh <YOUR-USERNAME>@shiny.lternet.edu\n```\n:::\n\n\nWindows users can log in with [PuTTY](https://www.chiark.greenend.org.uk/~sgtatham/putty/), using shiny.lternet.edu as the host name. \n\nCheck out [NCEAS' guide to using SSH](https://help.nceas.ucsb.edu/NCEAS/Computing/connecting_to_linux_using_ssh) for additional help. \n\n## Set Up Proper Permissions\n\n### Join `shiny-apps`\n\nA `shiny-apps` user group has been created in this server. Set up the proper permissions for your account by adding yourself to this group with this command. \n\n::: {.cell}\n\n```{.bash .cell-code}\nsudo usermod -aG shiny-apps <YOUR-USERNAME>\n```\n:::\n\n\nTo decipher this command a bit: `sudo` will enable you to run commands as a user with full control and privileges. The `usermod` command is used to modify user account details. The basic syntax is:\n\n::: {.cell}\n\n```{.bash .cell-code}\nusermod [OPTIONS] <YOUR-USERNAME>\n```\n:::\n\n\nThe `-G` option will add the user to a supplementary group. The `-aG` combined options will add the user to the new supplementary group while also leaving them in the other supplementary group(s) they were already a part of.\n\n:::callout-note\nAs an FYI, the apps on the server will run as the user `shiny`, so `shiny` is also in the `shiny-apps` user group. \n:::\n\n### Allow Access to Your Home Directory\n\nAdditionally, you need to allow `shiny` access to your user home directory by running:\n\n::: {.cell}\n\n```{.bash .cell-code}\nchmod a+x /home/<YOUR-USERNAME>\n```\n:::\n\n\nThis `chmod` (change mode) command is used to control file permissions. Basic syntax:\n\n::: {.cell}\n\n```{.bash .cell-code}\nchmod [OPTIONS] MODE FILE/DIRECTORY\n```\n:::\n\n\nThere are two \"modes\" that you can use to set permissions: Symbolic and Octal mode. The Symbolic mode uses operators and letters. For example, the `a` option denotes all the owner/groups the file/directory belongs to. The `+` operator grants the permission, and the letter `x` stands for the execute permission. \n\n\n## Tell `git` Who You Are\n\nNow that your account has the proper permissions, use the `git config` commands to tell `git` who you are.\n\n\n::: {.cell}\n\n```{.bash .cell-code}\ngit config --global user.name \"<YOUR-GITHUB-USERNAME>\"\ngit config --global user.email \"<YOUR-GITHUB-EMAIL>\"\n```\n:::\n\n\nReplace `<YOUR-GITHUB-USERNAME>` and `<YOUR-GITHUB-EMAIL>` with your own credentials. You can check to see if you entered your details correctly by entering `git config --list`.\n\n## Copy Your App to the Server\n\nThe easiest way to get all the files for your app to the server is by `git clone`. \n\nIf you like, you can create a folder named \"github\" to store all your future apps. For example, in the screenshot below, I created a \"github\" folder using the `mkdir` command in my home directory.\n\nTo check that the folder was created, I can list all the files/folders in my current directory with `ls`. Since I want my app to be inside the \"github\" folder, I used the `cd` command to change into that directory. \n\nFinally, `git clone` the GitHub repo that has all the files for your app. Here, I am cloning the [`lterpalettefinder-shiny`](https://github.com/lter/lterpalettefinder-shiny) repo to my local directory on the virtual machine as `lterpalettefinder`.\n\n<img src=\"images/shiny-server/shiny-server-1.png\" align=\"center\" width=\"100%\"/>\n\n:::callout-tip\nYou can go one level above the current directory by typing `cd ..`\n:::\n\n## Install Necessary R Packages\n\nAfter you cloned the repository for your app, you can start installing the necessary R packages! To make these packages available for all users, you will want to execute commands with the `root` user's privileges by typing the `sudo -i` command. Then open R by simply typing \"R\" and install packages with the usual `install.packages()` function. \n\n<img src=\"images/shiny-server/shiny-server-2.png\" align=\"center\" width=\"100%\"/>\n\n### Missing Dependencies? \n\nIf you run into an error installing a R package, it's likely because the server does not have the required dependencies installed yet. \n\nFor example, I wanted to install the `lterpalettefinder` R package, but I got lots of errors on missing dependencies instead. \n\n<img src=\"images/shiny-server/shiny-server-3.png\" align=\"center\" width=\"100%\"/>\n\nI saw that the `curl` dependency was missing, so I attempted to install that. However, R gives me another error. \n\n<img src=\"images/shiny-server/shiny-server-4.png\" align=\"center\" width=\"100%\"/>\n\nLooking closer, it asks me to install `libcurl4-openssl-dev` first. To install this Ubuntu package, I exited R with `q()` and logged off `root` with `exit`. Once I'm back in my own user profile, I can use the `sudo apt-get install` command to install `libcurl4-openssl-dev`.\n\n<img src=\"images/shiny-server/shiny-server-5.png\" align=\"center\" width=\"100%\"/>\n\nIf you get these prompts to restart services, you can tap Return/Enter to continue the installation. \n\n<img src=\"images/shiny-server/shiny-server-6.png\" align=\"center\" width=\"100%\"/>\n\n<img src=\"images/shiny-server/shiny-server-7.png\" align=\"center\" width=\"100%\"/>\n\nAfterwards, `libcurl4-openssl-dev` installed successfully, and then I can finally install the missing `curl` dependency in R! \n\n<img src=\"images/shiny-server/shiny-server-8.png\" align=\"center\" width=\"100%\"/>\n\nYou can repeat a similar process to find and install the rest of the required dependencies before you are able to install certain R packages. \n\n## Symlink to Deployed Folder\n\nSince all the Shiny apps are located under **<span style=\"color:blue\">/srv/shiny-server/</span>**, how can we deploy the app we have in our local directory? We can create a symlink (symbolic link) between the local directory and **<span style=\"color:blue\">/srv/shiny-server/</span>**. A symlink is essentially a pointer to other folders.\n\nCreate the link by running this command:\n\n::: {.cell}\n\n```{.bash .cell-code}\nln -s <LOCAL-DIRECTORY-OF-APP> <SHINY-SERVER-DIRECTORY-OF-APP>\n```\n:::\n\n\nReplace `<LOCAL-DIRECTORY-OF-APP>` with your own directory and replace `<SHINY-SERVER-DIRECTORY-OF-APP>` with the file path of where you would like your app to deploy. \n\nFor example, the actual `lterpalettefinder` app lives under my home directory, but it needs to be deployed under **<span style=\"color:blue\">/srv/shiny-server/</span>**, so I ran this command to link the two:\n\n<img src=\"images/shiny-server/shiny-server-9.png\" align=\"center\" width=\"100%\"/>\n\nNow **<span style=\"color:blue\">/srv/shiny-server/lterpalettefinder</span>** points to **<span style=\"color:blue\">/home/anchen/github/lterpalettefinder</span>**! \n\nYou can check the current symlinks by navigating to **<span style=\"color:blue\">/srv/shiny-server/</span>** and typing `ls -l`. \n\n:::callout-note\nThe name of the deployed folder corresponds to the URL: https://shiny.lternet.edu/\\<YOUR-APP\\>/\n:::\n\n## Debug App and Check its Live Link\n\nIf everything goes right, your app will be live at https://shiny.lternet.edu/\\<YOUR-APP\\>/! If not, don't worry and try troubleshooting what went wrong. Remember to check file paths and required R packages. ",
"markdown": "---\ntitle: \"Deploy Shiny Apps\"\nengine: knitr\n---\n\n:::callout-note\nPlease note that the following instructions for deploying Shiny apps are meant to serve as internal documentation and will only work if you have `sudo` power on the SciComp team's Shiny server.\n\nFeel free to [contact us](https://nceas.github.io/scicomp.github.io/staff.html) if you have a LTER-related Shiny app that you would like to deploy on our server!\n:::\n\nSciComp team members can deploy LTER-related Shiny apps on our server at: [https://shiny.lternet.edu/](https://shiny.lternet.edu/)\n\nTo deploy your working app, first make sure that all the files live at a GitHub repository. Once our sysadmin Nick Outin has made you an account on the server, you can log in via SSH. \n\n## Log In\n\nFor Mac users, open the Terminal app and type the following command, replacing `<YOUR-USERNAME>` with your own username. \n\n::: {.cell}\n\n```{.bash .cell-code}\nssh <YOUR-USERNAME>@shiny.lternet.edu\n```\n:::\n\n\nWindows users can log in with [PuTTY](https://www.chiark.greenend.org.uk/~sgtatham/putty/), using shiny.lternet.edu as the host name. \n\nCheck out [NCEAS' guide to using SSH](https://help.nceas.ucsb.edu/NCEAS/Computing/connecting_to_linux_using_ssh) for additional help. \n\n## Set Up Proper Permissions\n\n### Join `shiny-apps`\n\nA `shiny-apps` user group has been created in this server. Set up the proper permissions for your account by adding yourself to this group with this command. \n\n::: {.cell}\n\n```{.bash .cell-code}\nsudo usermod -aG shiny-apps <YOUR-USERNAME>\n```\n:::\n\n\nTo decipher this command a bit: `sudo` will enable you to run commands as a user with full control and privileges. The `usermod` command is used to modify user account details. The basic syntax is:\n\n::: {.cell}\n\n```{.bash .cell-code}\nusermod [OPTIONS] <YOUR-USERNAME>\n```\n:::\n\n\nThe `-G` option will add the user to a supplementary group. The `-aG` combined options will add the user to the new supplementary group while also leaving them in the other supplementary group(s) they were already a part of.\n\n:::callout-note\nAs an FYI, the apps on the server will run as the user `shiny`, so `shiny` is also in the `shiny-apps` user group. \n:::\n\n### Allow Access to Your Home Directory\n\nAdditionally, you need to allow `shiny` access to your user home directory by running:\n\n::: {.cell}\n\n```{.bash .cell-code}\nsudo chmod a+x /home/<YOUR-USERNAME>\n```\n:::\n\n\nThis `chmod` (change mode) command is used to control file permissions. Basic syntax:\n\n::: {.cell}\n\n```{.bash .cell-code}\nchmod [OPTIONS] MODE FILE/DIRECTORY\n```\n:::\n\n\nThere are two \"modes\" that you can use to set permissions: Symbolic and Octal mode. The Symbolic mode uses operators and letters. For example, the `a` option denotes all the owner/groups the file/directory belongs to. The `+` operator grants the permission, and the letter `x` stands for the execute permission. \n\n\n## Tell `git` Who You Are\n\nNow that your account has the proper permissions, use the `git config` commands to tell `git` who you are.\n\n\n::: {.cell}\n\n```{.bash .cell-code}\ngit config --global user.name \"<YOUR-GITHUB-USERNAME>\"\ngit config --global user.email \"<YOUR-GITHUB-EMAIL>\"\n```\n:::\n\n\nReplace `<YOUR-GITHUB-USERNAME>` and `<YOUR-GITHUB-EMAIL>` with your own credentials. You can check to see if you entered your details correctly by entering `git config --list`.\n\n## Copy Your App to the Server\n\nThe easiest way to get all the files for your app to the server is by `git clone`. \n\nIf you like, you can create a folder named \"github\" to store all your future apps. For example, in the screenshot below, I created a \"github\" folder using the `mkdir` command in my home directory.\n\nTo check that the folder was created, I can list all the files/folders in my current directory with `ls`. Since I want my app to be inside the \"github\" folder, I used the `cd` command to change into that directory. \n\nFinally, `git clone` the GitHub repo that has all the files for your app. Here, I am cloning the [`lterpalettefinder-shiny`](https://github.com/lter/lterpalettefinder-shiny) repo to my local directory on the virtual machine as `lterpalettefinder`.\n\n<img src=\"images/shiny-server/shiny-server-1.png\" align=\"center\" width=\"100%\"/>\n\n:::callout-tip\nYou can go one level above the current directory by typing `cd ..`\n:::\n\n## Install Necessary R Packages\n\nAfter you cloned the repository for your app, you can start installing the necessary R packages! To make these packages available for all users, you will want to execute commands with the `root` user's privileges by typing the `sudo -i` command. Then open R by simply typing \"R\" and install packages with the usual `install.packages()` function. \n\n<img src=\"images/shiny-server/shiny-server-2.png\" align=\"center\" width=\"100%\"/>\n\n### Missing Dependencies? \n\nIf you run into an error installing a R package, it's likely because the server does not have the required dependencies installed yet. \n\nFor example, I wanted to install the `lterpalettefinder` R package, but I got lots of errors on missing dependencies instead. \n\n<img src=\"images/shiny-server/shiny-server-3.png\" align=\"center\" width=\"100%\"/>\n\nI saw that the `curl` dependency was missing, so I attempted to install that. However, R gives me another error. \n\n<img src=\"images/shiny-server/shiny-server-4.png\" align=\"center\" width=\"100%\"/>\n\nLooking closer, it asks me to install `libcurl4-openssl-dev` first. To install this Ubuntu package, I exited R with `q()` and logged off `root` with `exit`. Once I'm back in my own user profile, I can use the `sudo apt install` command to install `libcurl4-openssl-dev`.\n\n<img src=\"images/shiny-server/shiny-server-5.png\" align=\"center\" width=\"100%\"/>\n\nIf you get these prompts to restart services, you can tap Return/Enter to continue the installation. \n\n<img src=\"images/shiny-server/shiny-server-6.png\" align=\"center\" width=\"100%\"/>\n\n<img src=\"images/shiny-server/shiny-server-7.png\" align=\"center\" width=\"100%\"/>\n\nAfterwards, `libcurl4-openssl-dev` installed successfully, and then I can finally install the missing `curl` dependency in R! \n\n<img src=\"images/shiny-server/shiny-server-8.png\" align=\"center\" width=\"100%\"/>\n\nYou can repeat a similar process to find and install the rest of the required dependencies before you are able to install certain R packages. \n\n## Symlink to Deployed Folder\n\nSince all the Shiny apps are located under **<span style=\"color:blue\">/srv/shiny-server/</span>**, how can we deploy the app we have in our local directory? We can create a symlink (symbolic link) between the local directory and **<span style=\"color:blue\">/srv/shiny-server/</span>**. A symlink is essentially a pointer to other folders.\n\nCreate the link by running this command:\n\n::: {.cell}\n\n```{.bash .cell-code}\nsudo ln -s <LOCAL-DIRECTORY-OF-APP> <SHINY-SERVER-DIRECTORY-OF-APP>\n```\n:::\n\n\nReplace `<LOCAL-DIRECTORY-OF-APP>` with your own directory and replace `<SHINY-SERVER-DIRECTORY-OF-APP>` with the file path of where you would like your app to deploy. \n\nFor example, the actual `lterpalettefinder` app lives under my home directory, but it needs to be deployed under **<span style=\"color:blue\">/srv/shiny-server/</span>**, so I ran this command to link the two:\n\n<img src=\"images/shiny-server/shiny-server-9.png\" align=\"center\" width=\"100%\"/>\n\nNow **<span style=\"color:blue\">/srv/shiny-server/lterpalettefinder</span>** points to **<span style=\"color:blue\">/home/anchen/github/lterpalettefinder</span>**! \n\nYou can check the current symlinks by navigating to **<span style=\"color:blue\">/srv/shiny-server/</span>** and typing `ls -l`. \n\n:::callout-note\nThe name of the deployed folder corresponds to the URL: https://shiny.lternet.edu/\\<YOUR-APP\\>/\n:::\n\n## Debug App and Check its Live Link\n\nIf everything goes right, your app will be live at https://shiny.lternet.edu/\\<YOUR-APP\\>/! If not, don't worry and try troubleshooting what went wrong. Remember to check file paths and required R packages. ",
"supporting": [],
"filters": [
"rmarkdown/pagebreak.lua"
Expand Down
Binary file modified images/shiny-server/shiny-server-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/shiny-server/shiny-server-9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions shiny-server.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ As an FYI, the apps on the server will run as the user `shiny`, so `shiny` is al

Additionally, you need to allow `shiny` access to your user home directory by running:
```{bash, eval = F}
chmod a+x /home/<YOUR-USERNAME>
sudo chmod a+x /home/<YOUR-USERNAME>
```

This `chmod` (change mode) command is used to control file permissions. Basic syntax:
Expand Down Expand Up @@ -103,7 +103,7 @@ I saw that the `curl` dependency was missing, so I attempted to install that. Ho

<img src="images/shiny-server/shiny-server-4.png" align="center" width="100%"/>

Looking closer, it asks me to install `libcurl4-openssl-dev` first. To install this Ubuntu package, I exited R with `q()` and logged off `root` with `exit`. Once I'm back in my own user profile, I can use the `sudo apt-get install` command to install `libcurl4-openssl-dev`.
Looking closer, it asks me to install `libcurl4-openssl-dev` first. To install this Ubuntu package, I exited R with `q()` and logged off `root` with `exit`. Once I'm back in my own user profile, I can use the `sudo apt install` command to install `libcurl4-openssl-dev`.

<img src="images/shiny-server/shiny-server-5.png" align="center" width="100%"/>

Expand All @@ -125,7 +125,7 @@ Since all the Shiny apps are located under **<span style="color:blue">/srv/shiny

Create the link by running this command:
```{bash, eval = F}
ln -s <LOCAL-DIRECTORY-OF-APP> <SHINY-SERVER-DIRECTORY-OF-APP>
sudo ln -s <LOCAL-DIRECTORY-OF-APP> <SHINY-SERVER-DIRECTORY-OF-APP>
```

Replace `<LOCAL-DIRECTORY-OF-APP>` with your own directory and replace `<SHINY-SERVER-DIRECTORY-OF-APP>` with the file path of where you would like your app to deploy.
Expand Down

0 comments on commit effa589

Please sign in to comment.