In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to deploy shiny web tools on a cloud server". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to deploy shiny web tools on a cloud server".
Reason
Our research group has a core collection of rape, which has been published after re-sequencing a few years ago. But many of the projects behind the research group are based on this core collection resource, and laboratory members often need to retrieve and analyze the specific SNP of certain genes, so I tried to build a Shiny app and deploy it on the research group's server using Shiny-server after I studied Shiny for a period of time, but because the Shiny app I developed is slow to open, and many times the server load runs. As a result, the opening speed of the Shiny app is even slower, and sometimes the loading time is too long to open directly. Coincidentally, I followed the update of Shengxin skill tree tweets and learned that I could set up a cloud server to deploy Shiny applications.
Purchase a server
At first @ thinking Bear suggested that I deploy Shiny applications using RStudio's Shinyapp.io. You can see that this is a server specially developed by RStudio to deploy Shiny applications. There are free versions and enterprise editions. The free version is enough for me. You can refer to the official manual for specific use. I will not talk about it here, because my application cannot be deployed. A package I used genetics shows that there is a problem with the source and is not compatible. Specifically, I installed this package from CRAN, but when using rsconnect testing, it shows that the source of genetics is BioConductor, which is very embarrassing. Google found that many users have encountered a similar problem. Some solutions are to install from GitHub to bypass this problem. Genetics seems to be unable to be installed through GitHub, so we have no choice but to abandon it and purchase a CVM for deployment.
There are many server manufacturers. I have also tried to register for foreign AWS. It provides an one-year free trial, but I need to fill in credit card information when registering and activating. I have no choice but to give up and switch to domestic CVM. Domestic servers mainly include Aliyun aliyun, Tencent Cloud Tencent Cloud and Huawei Cloud HUAWEI CLOUD. Shengxin skills tree also has a special tweet introduction. Friends in need pay attention to Shengxin skills tree and read tweets.
I finally chose Aliyun, first enter Aliyun, register and log in, and then student authentication.
After buying a student package for a year, I glanced at it and found that I could get a 20 yuan coupon:
Finally, 94 yuan to buy a year's minimum configuration (1 core 2Ggravity 1m with frame, 40G cloud disk) server, I am mainly used to deploy the server, so it is easy enough. If I choose the region, I choose East China (Hangzhou). I don't remember where I read a blog. The test found that there was little difference between different regions, so I chose the urban area without entanglement. I chose Ubuntu16.04 64-bit for the system (it seems that this is the only Ubuntu version available)
Enter the console after purchase, which contains the details of the CVM. The most useful thing for me is to have a public network IP, so that my Shiny app can be accessed all over the world!
Configure the server
With the CVM, you can make all kinds of troubles. I have already twitched with several servers, so I installed and configured the deployment environment smoothly. For beginners, refer to the post of Shengxin skills tree: what would you do if you had a new server? It can basically get through smoothly.
I will only talk about installing Shiny-server here. By default, you have installed the R language and the Shiny package:
First of all, go to the official website to download, in which there are detailed installation methods:
Sudo apt-get install gdebi-core
Wget https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-1.5.14.948-amd64.deb
Sudo gdebi shiny-server-1.5.14.948-amd64.deb
After installation, shiny users are automatically created.
It should be noted that when you buy the CVM, you are actually logged in by root users. At the beginning of my deployment, because the installed packages were all installed by root users, I modified the configuration problem. Running Shiny-server with root users ran normally at the beginning, but suddenly it couldn't run for no reason, so I finally had to delete all R packages and log in as shiny users.
After the shiny user logs in, I first make some settings, mainly R language and shiny-server settings:
# vi .Rprofile
Sys.setenv (LANG= "en_US.UTF-8")
Options= (repo = c (CRAN = "https://mirrors.tuna.tsinghua.edu.cn/CRAN/")))
Options (BioC_mirror= "https://mirrors.tuna.tsinghua.edu.cn/bioconductor")
# vi .Renviron
R_LIBS=/home/shiny/R_Library
Then the shiny-server configuration file is as follows:
# Instruct Shiny Server to run applications as the user "shiny"
Preserve_logs true
Sanitize_errors false
Run_as shiny
# Define a server that listens on port 3838
Server {
Listen 3838
# Define a location at the base URL
Location / {
# Host the directory of Shiny Apps stored in this directory
Site_dir / srv/shiny-server
# Log all Shiny output to files in this directory
Log_dir / var/log/shiny-server
# When a user visits the base URL rather than a particular application
# an index of the applications available in this directory will be shown.
Directory_index on
}
}
Then is to install a variety of need to use the R package, not to mention here, too many online tutorials, ubuntu apprentice installation of R package failure can be sure to encounter a variety of dependence lack of problems, this time on Google or Baidu, lack of what to make up!
It should be noted that because I bought the lowest-equipped server, some R packages that need to be compiled sometimes fail to compile and install because of insufficient memory. At this time, my suggestion is to install more times, and it will always be successful!
Once all the preparation environments are ready, you can upload the Shiny app file to the / srv/shiny-server directory. You may need to modify the permissions to which the directory belongs:
Sudo chown-R shiny:shiny shiny-server
The last step is left. The CVM has an additional security group, which needs to be set in the console: (left sidebar) Network and security-security group. After entering, you can manually add and activate port 3838. At this point, the browser opens the ip:3838/app name of the http:// public network and you can see the application you have deployed! This time, I have deployed two applications, http://121.41.229.126:3838/bnasnpdb and http://121.41.229.126:3838/gwas, which are running well and the opening speed is OK!
At this point, I believe you have a deeper understanding of "how to deploy the shiny web tool on the cloud server". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.