Created
May 22, 2024 09:40
-
-
Save junaidulqayyumqureshi/0b19a236dc630ef9d3b2e69d33118de2 to your computer and use it in GitHub Desktop.
Server management commands
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
Server management commands |
NGINX Configuration for Web Portal
- To deploy a web portal, go to
/etc/nginx/sites-available
, and create a new file. Add following contents to it:
server {
listen 81;
#server_name _; #Uncomment this if you want to keep it on ip
#server_name domain.com www.domain.com; #Uncomment this if you want to deploy on a domain
root /var/www/stg.admin/build; #Path of the webportal
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
If you DO NOT provide a port number, it will host on port 80 and if there is already a website hosted on same port, nginx will present error
-
Make sure that the port you provide is the one you want to host your application on. In this case, port is 81
-
This application will host directly on ip with port, and not on any subdomain
-To host this application on a domain, instructions are given in the above snippet -
After setting the site file, enable it by:
sudo ln -s /etc/nginx/sites-available/[filename] /etc/nginx/sites-enabled/
-
Test nginx configuration:
sudo nginx -t
If there is an error, this command will show the error -
Restart nginx:
sudo systemctl restart nginx
Set folder permissions
sudo chown -R www-data:www-data /var/www/path;
sudo chmod 600 /var/www/path/.env;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NGINX Configuration for Nodejs API
/etc/nginx/sites-available
, and create a new file. Add following contents to it:Make sure that the port you provide is the one you want to host your application on. In this case, port is 3003
This application will host directly on ip with port, and not on any subdomain
-To host this application on a domain, instructions are given in the above snippet
After setting the site file, enable it by:
sudo ln -s /etc/nginx/sites-available/[filename] /etc/nginx/sites-enabled/
Test nginx configuration:
sudo nginx -t
If there is an error, this command will show the error
Restart nginx:
sudo systemctl restart nginx