### Install OpenCPU Server on Ubuntu Source: https://github.com/opencpu/opencpu-server/blob/master/cloudserver.md Installs OpenCPU server and its dependencies on an Ubuntu 16.04 system. Requires updating package lists, adding a PPA, and installing the opencpu-server package. ```bash sudo apt-get update sudo apt-get dist-upgrade # Add user (interactive) sudo adduser jeroen sudo visudo # Change hostname sudo echo "dev.opencpu.org" > /etc/hostname # Reboot sudo apt-get install byobu software-properties-common sudo add-apt-repository ppa:opencpu/opencpu-2.2 && sudo apt-get update sudo apt-get install opencpu-server # test it curl http://localhost/ocpu/info ``` -------------------------------- ### Install and Configure Java for R Source: https://github.com/opencpu/opencpu-server/blob/master/cloudserver.md Installs the OpenJDK 8 JDK and configures R to use it. Includes a workaround for rApache to load the JVM library. ```bash sudo apt-get install openjdk-8-jdk sudo R CMD javareconf # However rApache doesn't read javaconf. The easiest workaround is just sudo ln -s /usr/lib/jvm/default-java/jre/lib/amd64/server/libjvm.so /usr/lib/ ``` -------------------------------- ### Setup OpenCPU Cache Server with Nginx Source: https://github.com/opencpu/opencpu-server/blob/master/cloudserver.md Installs and configures the OpenCPU cache server using Nginx. Includes steps for installing certbot for HTTPS, configuring Nginx virtual hosts, and restarting the Nginx service. ```bash sudo add-apt-repository ppa:opencpu/opencpu-dev sudo apt-get update sudo apt-get install opencpu-cache # Setup HTTPS sudo apt-get install certbot sudo certbot certonly --manual -d *.ocpu.io -d *.opencpu.org # To auto-renew, add a sudo (root) crontab: # 0 0 1 * * /usr/bin/certbot renew # Configure the back-end server ip address: # Update opencpu server sudo vi /etc/nginx/conf.d/opencpu.conf # Also set rstudio back-end server sudo vi /etc/nginx/opencpu.d/rstudio.conf # Enable the ocpu.io site sudo ln -s /usr/lib/opencpu/ocpu.io/ocpu-io /etc/nginx/sites-available/ocpu-io sudo /usr/lib/opencpu/scripts/nginx_ensite ocpu-io sudo /usr/lib/opencpu/scripts/nginx_ensite opencpu-homepage # Now also update the cert in the main site (default uses snakeoil): sudo vi /etc/nginx/sites-available/opencpu # And restart sudo service nginx restart ``` -------------------------------- ### Copy OpenCPU Apps from Old Server Source: https://github.com/opencpu/opencpu-server/blob/master/cloudserver.md Copies installed OpenCPU applications from a remote server using rsync. This is useful when migrating or setting up a new server with existing applications. ```bash sudo -i cd /usr/local/lib/opencpu rsync -avz -e ssh jeroen@dev.opencpu.org:/usr/local/lib/opencpu/apps . ``` -------------------------------- ### Install TensorFlow for Python Source: https://github.com/opencpu/opencpu-server/blob/master/cloudserver.md Installs TensorFlow and h5py for Python 3 using pip. This enables machine learning capabilities within the OpenCPU environment. ```bash sudo apt-get install python3-pip python3-dev python3-virtualenv sudo pip3 install --upgrade tensorflow h5py ``` -------------------------------- ### Run OpenCPU Docker Container Source: https://github.com/opencpu/opencpu-server/blob/master/docker/rocky-8/README.md Commands to start an OpenCPU server container. The first example runs the base image in the foreground, while the second demonstrates running an RStudio-enabled container with a custom name. ```bash docker run -t -p 80:80 -p 8004:8004 opencpu/base docker run --name mybox -t -p 80:80 opencpu/rstudio ``` -------------------------------- ### Run OpenCPU with RStudio Source: https://github.com/opencpu/opencpu-server/blob/master/docker/rocky-9/README.md Starts a container that includes both the OpenCPU server and RStudio server. Apache is configured to proxy requests to both services. ```bash docker run -t -p 80:80 -p 8004:8004 opencpu/rstudio ``` -------------------------------- ### Configure Postfix Mail Server Relay Source: https://github.com/opencpu/opencpu-server/blob/master/cloudserver.md Sets up Postfix to relay mail through Mailgun. This involves installing Postfix, configuring SASL authentication, and setting the relay host in main.cf. ```bash sudo apt-get install postfix libsasl2-modules # Then edit the file /etc/postfix/sasl_passwd and add a (replace PASSWORD with plaintext password): # smtp.mailgun.org mail@ocpu.io:PASSWORD sudo postmap /etc/postfix/sasl_passwd sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db # Now edit /etc/postfix/main.cf and set: # Set by Jeroen # relayhost = smtp.mailgun.org # At the end if the fuke # smtp_sasl_auth_enable = yes # smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd # smtp_sasl_security_options = noanonymous sudo service postfix restart ``` -------------------------------- ### Run OpenCPU Docker Container Source: https://github.com/opencpu/opencpu-server/blob/master/docker/rocky-9/README.md Commands to start an OpenCPU server container. It maps host ports to container ports for HTTP access. ```bash docker run -t -p 80:80 -p 8004:8004 opencpu/base ``` -------------------------------- ### Configure R Profile for RSPM Source: https://github.com/opencpu/opencpu-server/blob/master/cloudserver.md Sets the CRAN repository to use RStudio's Package Manager (RSPM) for R packages. This ensures consistent and up-to-date package installations. ```r options(repos = c(CRAN = "https://packagemanager.rstudio.com/all/__linux__/focal/latest")) options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version$platform, R.version$arch, R.version$os))) ``` -------------------------------- ### Custom Port Mapping Source: https://github.com/opencpu/opencpu-server/blob/master/docker/rocky-9/README.md Example of mapping specific ports when the default port 80 is already in use on the host machine. ```bash docker run -t -p 8004:8004 opencpu/base ``` -------------------------------- ### Install SELinux Troubleshooting Tools Source: https://github.com/opencpu/opencpu-server/blob/master/rpm/readme.md Installs the setroubleshoot packages to provide detailed logging and diagnostic information for SELinux permission issues. ```bash yum install setroubleshoot setroubleshoot-server ``` -------------------------------- ### Manage Docker Containers Source: https://github.com/opencpu/opencpu-server/blob/master/docker/rocky-8/README.md Commands to list running containers and execute a root shell inside a specific container instance. This is useful for system maintenance and installing additional libraries. ```bash docker ps docker exec -i -t [container-id] /bin/bash docker exec -i -t mybox /bin/bash ``` -------------------------------- ### Run OpenCPU with a Named Container Source: https://github.com/opencpu/opencpu-server/blob/master/docker/base/README.md Starts a new OpenCPU container, assigning it the name 'mybox' and mapping port 80. This allows easy access to the container using its name instead of its ID for subsequent commands like 'docker exec'. ```bash # This starts a new container on port 80 docker run --name mybox -t -p 80:80 opencpu/rstudio # In another window, start a root bash docker exec -i -t mybox /bin/bash ``` -------------------------------- ### Get a Root Shell in a Running Container Source: https://github.com/opencpu/opencpu-server/blob/master/docker/base/README.md Connects to a running Docker container to obtain a root shell. This is useful for installing system libraries or performing administrative tasks within the container. Replace '[container-id]' with the actual ID or name of your container. ```bash # Get the Container ID of your machine docker ps # Starts a root shell docker exec -i -t [container-id] /bin/bash ``` -------------------------------- ### Access Container Root Shell Source: https://github.com/opencpu/opencpu-server/blob/master/docker/rocky-9/README.md Instructions for obtaining a bash shell inside a running Docker container. This is typically used for system administration or installing additional libraries. ```bash # List containers to find ID docker ps # Start a root shell using container ID docker exec -i -t [container-id] /bin/bash # Start a root shell using a named container docker run --name mybox -t -p 80:80 opencpu/rstudio docker exec -i -t mybox /bin/bash ``` -------------------------------- ### Configure Apache for Localhost Access Source: https://github.com/opencpu/opencpu-server/blob/master/cloudserver.md Restricts access to the OpenCPU Apache site to only allow connections from the local machine. This is a security measure to prevent external access to the backend. ```bash sudo vi /etc/apache2/sites-enabled/opencpu # Insert the IP address where it says `require local`, e.g. `require ip 123.123.123.123`. # Also make sure to close port 80. ``` -------------------------------- ### Inspect SELinux Booleans Source: https://github.com/opencpu/opencpu-server/blob/master/rpm/readme.md Lists all available SELinux booleans related to the httpd service to help identify and resolve permission-related issues. ```bash /usr/sbin/getsebool -a | grep httpd ``` -------------------------------- ### Configure Firewall for HTTP Traffic Source: https://github.com/opencpu/opencpu-server/blob/master/rpm/readme.md Commands to open port 80 in the system firewall to allow incoming HTTP traffic on RHEL and CentOS systems. ```bash sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT sudo service iptables save ``` -------------------------------- ### Configure Directory Permissions for OpenCPU User API Source: https://github.com/opencpu/opencpu-server/blob/master/rpm/readme.md Commands to modify directory permissions to allow the OpenCPU user API to access home directories on RedHat systems. These commands grant read and execute access to the specified user home directories. ```bash chmod +rx ~ sudo chmod +rx /home/username ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.