Last active
June 3, 2024 11:49
-
-
Save dosanauthor/435eed8c2f469c04d6314d1e47847c45 to your computer and use it in GitHub Desktop.
Deploying PDF Tools Nextjs app On VPS using Docker, FileZilla, Nginx and Let's Encrypt SSL Certificates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get Source code: https://codecanyon.net/item/pdf-tools-high-quality-pdf-tools-nextjs-react-web-application/44924651 | |
WARNING: This item is exclusively sold on CodeCanyon under Envato Market licenses. Please do not purchase it from other sources, as they might be attempting to scam you. | |
#DNS Configuration | |
Add these two records to your DNS records: | |
Record 01: | |
Type: A Record, Host: @, Value: ip_address | |
Record 02: | |
Type: CNAME Record, Host: www, Value: domain-name | |
#Login to VPS | |
/ ssh root@ip_address | |
enter your password | |
#Configuring VPS | |
/ sudo apt update && apt upgrade | |
/ sudo apt install nginx certbot python3-certbot-nginx | |
/ sudo apt install ufw | |
/ sudo ufw allow "Nginx Full" | |
/ ufw allow OpenSSH | |
/ ufw enable | |
#Check if docker is installed | |
/ docker version | |
#If not found type the next commands to install it. | |
#Installing Docker on VPS | |
/ sudo apt install apt-transport-https ca-certificates curl software-properties-common | |
/ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | |
/ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
/ sudo apt update | |
/ sudo apt install docker-ce docker-ce-cli containerd.io | |
/ sudo systemctl start docker | |
/ sudo usermod -aG docker $USER | |
/ docker version | |
#Uploading files to server using FTP Client FileZilla: | |
#FileZilla Client Download Link: https://filezilla-project.org/download.php?type=client | |
#Create a zip file of the project files. | |
#Open FileZilla, enter ip address, username (root), password, port (22) and access | |
#the directory /var/www/ in server, drag and drop the project zip file from your | |
#local directory to the /var/www/ directory and wait for the uplaod to finish | |
#Afer uploading the project zip file from local machine to server using FTP Client | |
/ sudo apt install unzip | |
/ cd /var/www | |
/var/www# ls | |
/var/www# unzip pdf-tools-all-in-one.zip | |
/var/www# ls | |
/var/www# rm pdf-tools-all-in-one.zip | |
/var/www# ls | |
/var/www# cd pdf-tools-all-in-one | |
/var/www/pdf-tools-all-in-one# docker build -t pdftoolsimage . | |
/var/www/pdf-tools-all-in-one# docker run -d -p 8080:3000 --name pdftools_c pdftoolsimage | |
/var/www/pdf-tools-all-in-one# cd /etc/nginx/ | |
/etc/nginx# ls | |
/etc/nginx# cd sites-available | |
/etc/nginx/sites-available# ls | |
#Make sure to change domain-name with your domain name | |
/etc/nginx/sites-available# touch domain-name | |
/etc/nginx/sites-available# ls | |
#Make sure to change domain-name with your domain name | |
/etc/nginx/sites-available# nano domain-name | |
#Copy and past this config in domain-name file, make sure to change domain-name.com with your domain name | |
server { | |
listen 80; | |
server_name domain-name.com www.domain-name.com; | |
location / { | |
proxy_pass http://localhost:8080; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
} | |
} | |
#Save file CTRL+S | |
#Exit file CTRL+X | |
/etc/nginx/sites-available# ls | |
/etc/nginx/sites-available# rm default | |
/etc/nginx/sites-available# cd .. | |
#Make sure to change domain-name with your domain name | |
/etc/nginx# sudo ln -s /etc/nginx/sites-available/domain-name /etc/nginx/sites-enabled/ | |
/etc/nginx# ls | |
/etc/nginx# cd sites-enabled | |
/etc/nginx/sites-enabled# ls | |
/etc/nginx/sites-enabled# rm default | |
/etc/nginx/sites-enabled# ls | |
/etc/nginx/sites-enabled# cd .. | |
#Open the Nginx configuration file in a text editor. | |
/etc/nginx# nano nginx.conf | |
#Inside the http block, add or modify the client_max_body_size directive to set the desired limit. | |
client_max_body_size 1G; | |
#Save Nginx configuration file CTRL+S | |
#Exit Nginx configuration file CTRL+X | |
#Restart the Nginx service to apply the new configuration | |
/etc/nginx# systemctl restart nginx | |
/etc/nginx# nginx -t | |
#Make sure to change domain-name.com with your domain name | |
/etc/nginx# sudo certbot --nginx -d domain-name.com -d www.domain-name.com | |
#After let's encrypt certificates are installed successfully you can add your domain to cloudflare. | |
#========================= Update Project & Redeploy App======================= | |
#After making changes to the project. Upload updated project zip file to the server and | |
#run the following commands to redeploy the PDF Tools app on your VPS. | |
#Upload files to server using FTP Client FileZilla: | |
#Download FileZilla Client. Link: https://filezilla-project.org/download.php?type=client | |
#Create a zip file of the updated project files. | |
#Open FileZilla, enter ip address, username (root), password, port (22) and access | |
#the directory /var/www/ in server, drag and drop the project zip file from your | |
#local directory to the /var/www/ directory and wait for the uplaod to finish | |
#Open a terminal | |
/ ssh root@ip_address | |
enter your password | |
/ cd /var/www | |
/var/www# ls | |
/var/www# cd pdf-tools-all-in-one | |
/var/www/pdf-tools-all-in-one# docker stop pdftools_c | |
/var/www/pdf-tools-all-in-one# docker container rm pdftools_c | |
/var/www/pdf-tools-all-in-one# cd .. | |
/var/www# rm -r pdf-tools-all-in-one | |
/var/www# ls | |
/var/www# unzip pdf-tools-all-in-one.zip | |
/var/www# ls | |
/var/www# rm pdf-tools-all-in-one.zip | |
/var/www# ls | |
/var/www# cd pdf-tools-all-in-one | |
/var/www/pdf-tools-all-in-one# docker build -t pdftoolsimage . | |
/var/www/pdf-tools-all-in-one# docker run -d -p 8080:3000 --name pdftools_c pdftoolsimage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment