Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tutorial] What are webservers? #292

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update readme.md
  • Loading branch information
ayshanimra authored Apr 12, 2023
commit abaab6013cb6c2ce67c568f205900a1b6b0934c0
25 changes: 13 additions & 12 deletions learning/dashboard/webserver/readme.md
Original file line number Diff line number Diff line change
@@ -76,35 +76,36 @@ Although the service starts automatically after installing Nginx, before you can
The most popular method for creating iptables' ingress and egress rules. Uncomplicated Firewall, or ufw, is a user-friendly wrapper for iptables that is available in Ubuntu 20.04. Although it comes installed with Ubuntu 20.04 but to make sure that it is appropriately installed, install it manually. After installing Nginx, follow the instructions below to set up the firewall

Step 1: Install ufw:
'''sudo apt install ufw'''
```sudo apt install ufw```

Step 2: Check if ufw is working fine:
'''sudo ufw status'''
```sudo ufw status```

Step 3: Allow traffic over HTTP and recheck the status:
'''sudo ufw allow ‘Nginx HTTP’ '''
```sudo ufw allow ‘Nginx HTTP’ ```

Step 4: Allow traffic over TCP (OpenSSH) too if you want to log into the machine again:
'''sudo ufw allow ‘OpenSSH’ '''
```sudo ufw allow ‘OpenSSH’ ```

Step 5: If the status was inactive when you checked earlier, activate it:
'''sudo ufw enable'''
```sudo ufw enable```

The choice of whether to implement the changes or not will be presented to you. Be aware that you won't be able to enter into the machine again if you deactivate TCP traffic or add a deny OpenSSH rule to the firewall. Let’s now cover some crucial Nginx commands for administration and management

## Nginx Installation and Management :

Step 1: Check the status of the Nginx server:
''' sudo systemctl status nginx '''
``` sudo systemctl status nginx ```

Step 2: You can also check if Nginx is working by accessing your website using the browser. Visit the following link:
http://servermania_server_ip
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using the markdown link format [Title](url)


Step 3: Use systemctl to start, stop, or restart your Nginx server:
'''sudo systemctl stop nginxsudo systemctl start nginxsudo systemctl restart nginx'''
my
```sudo systemctl stop nginxsudo systemctl start```
``` nginxsudo systemctl restart nginx```

Step 4: The Nginx configuration file is found at /etc/nginx/nginx.conf. If you make changes to the configuration, you can either restart the Nginx server or reload the configuration file.
'''systemctl reload nginx # reloads Nginx configuration'''
```systemctl reload nginx # reloads Nginx configuration```

Use the reload command rather than the restart command whenever possible because it doesn't affect any current connections you may have to Nginx.

@@ -118,15 +119,15 @@ Create a directory, one for each domain:

Nginx only creates one server block by default, and it points to the /var/www/html directory. If you simply had one site, this would function flawlessly. All of the website's content is housed in the html subdirectory. For both of your domains, create the html subdirectories.

'''sudo mkdir -p /var/www/domainone.com/htmlsudo mkdir -p /var/www/domaintwo.com/html'''
```sudo mkdir -p /var/www/domainone.com/htmlsudo mkdir -p /var/www/domaintwo.com/html```

Step 1: Change ownership of the directories:
Doing this will enable the user to create and edit the contents of these new directories.
'''sudo chown -R $user:$user /var/www/domainone.com/htmlsudo chown -R $user:$user /var/www/domaintwo.com/html'''
```sudo chown -R $user:$user /var/www/domainone.com/htmlsudo chown -R $user:$user /var/www/domaintwo.com/html```

Step 2: Modify permissions for both the domain directories:
This step is important to make sure that you don’t need root privileges to make changes to any of the sites.
'''sudo chmod -R 755 /var/www'''
```sudo chmod -R 755 /var/www```

Step 3: Create sample web pages for each domain/site:
Create a landing page index.html for both domains. Create a basic HTML snippet for a welcome page for both sites.