You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS服务器部署自定义Shiny应用启动失败求助

Alright, let's work through this Shiny Server deployment issue on AWS. I've gone through your logs and error messages, and here's a step-by-step breakdown of what's going wrong and how to fix it:

1. Fix the Shiny Server Startup Permission Error

First, the critical error you see when running shiny-server directly:

Error loading config: The user 'ubuntu' does not have permissions to run applications as one of the users in 'shiny'. Please restart shiny-server as one of the users in 'shiny'.

This happens because you're trying to start Shiny Server as root (your log warns about running as root unnecessarily) but your config specifies run_as ubuntu;. Shiny Server enforces that the user starting the service matches the run_as user, or has permission to switch to it safely. Here are two ways to fix this:

Option 1: Run Shiny Server as the ubuntu user directly

  • Stop any running Shiny Server processes first:
    sudo systemctl stop shiny-server
    
  • Switch to the ubuntu user:
    su - ubuntu
    
  • Start Shiny Server:
    shiny-server
    
    If you get permission errors here, skip to step 2 to fix directory permissions.

If you prefer using systemd to manage Shiny Server:

  • Edit the service file:
    sudo nano /etc/systemd/system/shiny-server.service
    
  • Find the line that says User=shiny and change it to User=ubuntu
  • Save the file, then reload systemd and restart the service:
    sudo systemctl daemon-reload
    sudo systemctl restart shiny-server
    

2. Fix Custom Application Directory Permissions

Your sample app works because it's owned by the default shiny user, but your custom app likely has incorrect permissions for the ubuntu user. Let's fix that:

  • Replace your-app with the name of your custom application directory:
    sudo chown -R ubuntu:ubuntu /srv/shiny-server/your-app
    sudo chmod -R 755 /srv/shiny-server/your-app
    

This ensures the ubuntu user can read and execute all files in your app directory.

3. Diagnose the Exact Initialization Error

The generic "application exited during initialization" message isn't helpful. Let's get the real error by running your app directly in R:

  • Switch to the ubuntu user:
    su - ubuntu
    
  • Navigate to your app directory:
    cd /srv/shiny-server/your-app
    
  • Run the app with R:
    R -e "shiny::runApp('.')"
    

This will print specific errors like missing R packages, broken file paths, or syntax errors in your app code—this is the fastest way to pinpoint why the app won't start.

4. Fix Your Incomplete shiny-server.conf

Your provided config file is truncated (it ends mid-sentence: # Log all Shiny output to files in th). A complete, valid config should look something like this:

# Instruct Shiny Server to run applications as the user "ubuntu"
run_as ubuntu;

# 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;
    # Show an index of apps when visiting the base URL
    directory_index on;
  }
}

Fix any missing parts or syntax errors in your config file, then restart Shiny Server.


Start with fixing the config file and permission issues, then run the app directly in R to get the exact error message. That should resolve the initialization failure.

内容的提问来源于stack exchange,提问作者J.Con

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 04:22:00