Documentation and SupportDocumentation and Support

Install NGINX

NGINX is a popular web server technology used for a number of different scenarios like a standard web server, a reverse proxy, and even load balancing. Configuration for those examples varies, but with a runbook, you can automate the installation of NGINX as a routine operational task.

Create the runbook

To create a runbook to install NGINX on an Ubuntu machine:

  1. From your project’s overview page, navigate to Operations ➜ Runbooks, and click ADD RUNBOOK.
  2. Give the runbook a name and click SAVE.
  3. Click DEFINE YOUR RUNBOOK PROCESS, and then click ADD STEP.
  4. Click Script, and then select the Run a Script step.
  5. Give the step a name.
  6. Choose the Execution Location on which to run this step.
  7. In the Inline source code section, select Bash and add the following code:
# Update repositories
sudo apt-get update

# Install NGINX
sudo apt-get install nginx -y

# Configure firewall
# Uncomment out the line that meets your needs
sudo ufw allow 'Nginx Full' # both ports 80 and 443
# sudo ufw allow 'Nginx HTTP' # port 80 only
# sudo ufw allow 'Nginx HTTPS' # port 443 only

# Uncomment to disable default virtual host
#unlink /etc/nginx/sites-enabled/default
# Update repositories
sudo yum check-update

# Install NGINX
sudo yum install nginx -y

# Configure firewall
# Uncomment out the line that meets your needs
sudo firewall-cmd --permanent --zone=public --add-service=http --add-service=https # both ports 80 and 443
# sudo firewall-cmd --permanent --zone=public --add-service=http # port 80 only
# sudo firewall-cmd --permanent --zone-public --add-service=https  # port 443 only
sudo firewall-cmd --reload

# Start the service
sudo systemctl start nginx

With a small script, you can include the installation of NGINX with your infrastructure provisioning.

Help us continuously improve

Please let us know if you have any feedback about this page.

Send feedback

Page updated on Sunday, January 1, 2023