Skip to content

Commit

Permalink
bash command
Browse files Browse the repository at this point in the history
  • Loading branch information
maglovskiNenad committed Nov 7, 2024
1 parent 1d89eae commit f9d80ae
Showing 1 changed file with 65 additions and 65 deletions.
130 changes: 65 additions & 65 deletions _posts/2024-11-07-nginx.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,40 +53,40 @@ To set up NGINX on your server, follow these steps (using an Ubuntu server as an

1. Install NGINX:

---
sudo apt update
sudo apt install nginx
---
```bash
sudo apt update
sudo apt install nginx
```

2. Set Up Basic Configuration:

- Open the configuration file:

---
```bash
sudo nano /etc/nginx/sites-available/default
---
```

- Enter the following basic configuration:

---
server {
listen 80;
server_name example.com;

location / {
root /var/www/html;
index index.html;
}
```nginx
server {
listen 80;
server_name example.com;
location / {
root /var/www/html;
index index.html;
}
---
}
```

3. Start NGINX:

- After making your changes, start NGINX:

---
sudo systemctl restart nginx
---
```bash
sudo systemctl restart nginx
```

4. Test:

Expand All @@ -101,96 +101,96 @@ NGINX is an incredibly powerful, fast, and efficient tool for managing web traff

- Stopping NGINX

---
sudo systemctl stop nginx
---
```bash
sudo systemctl stop nginx
```

- Restarting NGINX

---
sudo systemctl restart nginx
---
```bash
sudo systemctl restart nginx
```

- Reloading NGINX Configuration

---
sudo systemctl reload nginx
---
```bash
sudo systemctl reload nginx
```

- Checking the Status of NGINX

---
sudo systemctl status nginx
---
```bash
sudo systemctl status nginx
```

- Enabling NGINX on Startup
- Enabing NGINX on Startup

---
sudo systemctl enable nginx
---
```bash
sudo systemctl enable nginx
```

- Disabling NGINX on Startup

---
sudo systemctl disable nginx
---
```bash
sudo systemctl disable nginx
```

- Testing the Configuration for Errors

---
sudo nginx -t
---
```bash
sudo nginx -t
```

- Running NGINX as a Background Process

---
sudo nginx
---
```bash
sudo nginx
```

- Stopping NGINX without systemd

---
sudo nginx -s stop
---
```bash
sudo nginx -s stop
```

- Reloading Configuration without Stopping NGINX

---
sudo nginx -s reload
---
```bash
sudo nginx -s reload
```

- Checking Logs

Access error or access logs to diagnose issues. On Ubuntu, logs are typically located at /var/log/nginx/.
- Error log:

---
tail -f /var/log/nginx/error.log
---
```bash
tail -f /var/log/nginx/error.log
```

- Access log:

---
tail -f /var/log/nginx/access.log
---
```bash
tail -f /var/log/nginx/access.log
```

- Running in Foreground (without systemd)

---
sudo nginx -g "daemon off;"
---
```bash
sudo nginx -g "daemon off;"
```

- Gracefully Shutting Down NGINX
- Shuts down NGINX from the command line without systemctl.

---
sudo nginx -s quit
---
```bash
sudo nginx -s quit
```

- Reopening Log Files

---
sudo nginx -s reopen
---
```bash
sudo nginx -s reopen
```

These commands cover the basics for managing NGINX on a Linux server, including routine maintenance, restarting, testing configurations, and checking the server’s status.

0 comments on commit f9d80ae

Please sign in to comment.