Install NGINX
Last updated
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:
- From your project's overview page, navigate to Operations ➜ Runbooks, and click ADD RUNBOOK.
- Give the runbook a name and click SAVE.
- Click DEFINE YOUR RUNBOOK PROCESS, and then click ADD STEP.
- Click Script, and then select the Run a Script step.
- Give the step a name.
- Choose the Execution Location on which to run this step.
- 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.
Need support? We're here to help.