Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
linux-config
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Walmes Marques Zeviani
linux-config
Commits
26b478b6
Commit
26b478b6
authored
1 year ago
by
Walmes Marques Zeviani
Browse files
Options
Downloads
Patches
Plain Diff
Install, configure and publish apps with Shiny.
parent
cc2cc316
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
shiny_server.sh
+153
-0
153 additions, 0 deletions
shiny_server.sh
with
153 additions
and
0 deletions
shiny_server.sh
0 → 100644
+
153
−
0
View file @
26b478b6
#-----------------------------------------------------------------------
# Instalação do Shiny Server no VPS da Hostinger. ----------------------
# 1. Autenticar no servidor VPS. OBS: Já criei chaves para acessar sem
# senha.
ssh root@191.101.70.46
# 2. Atualizar o sistema.
sudo
apt update
# 3. Instalar o R e bibliotecas necessárias.
sudo
apt
install
-y
r-base-dev libssl-dev libcurl4-openssl-dev nginx
# IMPORTANT! Essa instalação do R é para Ubuntu e irá usar Nginx como
# servidor web. Se você estiver usando um sistema operacional diferente
# ou um servidor web diferente (geralmente o Apache2 é o padrão),
# consulte a documentação do Shiny Server para obter instruções de
# instalação específicas.
# 4. Pacotes que serão necessários.
Rscript
-e
"install.packages('shiny', repos = 'https://cran.rstudio.com/')"
Rscript
-e
"install.packages('rmarkdown', repos = 'https://cran.rstudio.com/')"
Rscript
-e
"install.packages('tidyverse', repos = 'https://cran.rstudio.com/')"
# 5. Baixar e instalar o Shiny Server. Abrir a seginte URL.
# firefox https://posit.co/download/shiny-server/
# 6. Baixar o arquivo `*.deb`
wget https://download2.rstudio.org/server/shiny-server-1.7.3-amd64.deb
# 7. Instalar o Shiny Server.
sudo
dpkg
-i
shiny-server-1.7.3-amd64.deb
# 8. Criar um diretório para hospedar as aplicações Shiny.
sudo mkdir
/srv/shiny-server
# 9. Criar um arquivo de serviço para o Shiny Server.
sudo
nano /etc/systemd/system/shiny-server.service
# 10. Insira o seguinte conteúdo no arquivo
# `/etc/systemd/system/shiny-server.service`.
#
# [Unit]
# Description=ShinyServer
#
# [Service]
# Type=simple
# User=shiny
# ExecStart=/usr/lib/shiny-server/shiny-server
# Restart=always
#
# [Install]
# WantedBy=multi-user.target
# 11. Habilitar e iniciar o Shiny Server.
sudo
systemctl
enable
shiny-server.service
sudo
systemctl start shiny-server.service
sudo
systemctl restart shiny-server.service
# 12. Testar a instalação.
#
# Abra um navegador web e acesse o endereço `191.101.70.46:3838`. Você
# deve ver a página inicial do Shiny Server.
#-----------------------------------------------------------------------
# Configurar URL para o serviço. ---------------------------------------
# 1. Na Hostinger, ir no `Editor de Zona de DNS`.
# https://hpanel.hostinger.com/websites/omegadataacademy.com.br/advanced/dns-zone-editor
# 2. Adicionar um registro `A` para o subdomínio
# `shiny.omegadataacademy.com.br`. Preencher para IP o valor
# `191.101.70.46`. Deixar o TTL em 14400 mesmo. Clicar em adicionar
# registro.
# 3. IMPORTANT. No VPS Hostinger, o servidor web padrão foi o Apache2.
# Eu alterei a porta do Apache2 para 8080 para poder usar a porta 80
# com o Nginx. As instruções foram seguidas em
# https://support.posit.co/hc/en-us/articles/213733868-Running-Shiny-Server-with-a-Proxy.
# 4. Mostra se é o Apache ou Nginx que está rodando na porta 80.
netstat
-anp
|
grep
:80
# Altera a porta para 8080. Trocar `Listen 80` por `Listen 8080`.
nano /etc/apache2/ports.conf
# 5. Reiniciar o Apache2.
# sudo systemctl stop apache2
# sudo systemctl start apache2
sudo
systemctl restart apache2
# 6. Abrir o arquivo de configuração do Nginx.
nano /etc/nginx/nginx.conf
# 7. Alterar o conteúdo para o seguinte.
#
# http {
# # < ... outras coisas aqui ... >
# map $http_upgrade $connection_upgrade {
# default upgrade;
# '' close;
# }
#
# server {
# listen 80;
# server_name shiny.omegadataacademy.com.br;
#
# location / {
# proxy_pass http://localhost:3838;
# proxy_redirect / $scheme://$http_host/;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection $connection_upgrade;
# proxy_read_timeout 20d;
# proxy_buffering off;
# }
# }
# }
# 8. Reiniciar o Nginx.
# sudo systemctl stop nginx
sudo
systemctl restart nginx
# 9. Testar a instalação. Abra um navegador web e acesse o endereço
# `shiny.omegadataacademy.com.br`. Você deve ver a página inicial do
# Shiny Server. O endereço
# `shiny.omegadataacademy.com.br/sample-apps/hello` tem que levar
# para a aplicação exemplo.
#-----------------------------------------------------------------------
# Publicar minhas aplicações. ------------------------------------------
# 1. No servidor Shiny, rode o comando para ver as aplicações.
tree /srv/shiny-server
# 2. Fazer um `scp` do computador cliente para o servidor Shiny. O
# diretório com arquivos para uma aplicação é `ORIGDIR`. Este
# diretório deve ser transferido para `/srv/shiny-server/` que é o
# `DESTDIR`.
# 3. Criar variáveis para facilitar as operações.
ORIGDIR
=
"/home/walmes/Projects/Ômega/VIS4DS/ShinyApps/hist_button"
DESTDIR
=
"/srv/shiny-server/"
USER
=
"root"
SERVER
=
"191.101.70.46"
# 4. Transfere os arquivos.
scp
-r
-v
$ORIGDIR
$USER
@
$SERVER
:
$DESTDIR
# 5. Para acessar é ir em
# http://shiny.omegadataacademy.com.br/hist_button/
#-----------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment