kb

You only live once. Be free.

Have a Question?

If you have any question you can ask below or enter what you are looking for!

Install nginx and secure it with let’s encrypt – all in one script

The following script will install nginx and php 7.2 and will also secure the installation with let’s encrypt. You need to save this script and make it executable:

vi install.sh

Paste the script and save:

#!/bin/bash

/usr/bin/apt update
/usr/bin/apt upgrade -y
/usr/bin/apt install nginx -y
/usr/sbin/ufw allow 'Nginx Full'
/usr/sbin/ufw allow 'OpenSSH'
/bin/echo "y" | /usr/sbin/ufw enable
/bin/systemctl enable nginx
/bin/systemctl restart nginx
/bin/mkdir /var/www/x.yolobefree.com -p
/bin/chown www-data:www-data /var/www/x.yolobefree.com -R
/bin/chmod g+w /var/www/x.yolobefree.com -R
/bin/echo "" > /var/www/x.yolobefree.com/index.php
cd /etc/nginx/sites-available/
git clone https://github.com/yolobefree/kb.git
cd kb
/bin/cp x.yolobefree.com /etc/nginx/sites-available/
/bin/systemctl restart nginx
/usr/bin/add-apt-repository ppa:certbot/certbot
/usr/bin/apt install python-certbot-nginx php7.2-fpm php7.2-gd php7.2-intl php7.2-json php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-readline php7.2-soap php7.2-xml php7.2-xmlrpc php7.2-zip php7.2-mysqli -y
/usr/bin/certbot --nginx -d x.yolobefree.com

Make the script executable

chmod +x install.sh

Run the script

./install.sh

Follow the messages as your input is needed. You need to specify the email address for the renewal notifications.

Leave a Reply

Your email address will not be published. Required fields are marked *