# Daily Hack #day59 - Configure Nginx to Start Automatically on System [re]Boot

To configure Nginx to start automatically on system boot, you typically need to enable the Nginx service using your operating system's service management system. The exact steps can vary depending on the Linux distribution you are using. Here are instructions for some common distributions:

### On Debian-based Systems (e.g., Ubuntu)

1. **Install Nginx** (if not already installed):
   ```bash
   sudo apt update
   sudo apt install nginx
   ```

2. **Enable Nginx to start at boot**:
   ```bash
   sudo systemctl enable nginx
   ```

3. **Start Nginx immediately**:
   ```bash
   sudo systemctl start nginx
   ```

### On Red Hat-based Systems (e.g., CentOS, Fedora)

1. **Install Nginx** (if not already installed):
   ```bash
   sudo yum install nginx
   ```

2. **Enable Nginx to start at boot**:
   ```bash
   sudo systemctl enable nginx
   ```

3. **Start Nginx immediately**:
   ```bash
   sudo systemctl start nginx
   ```

### On Arch-based Systems (e.g., Arch Linux, Manjaro)

1. **Install Nginx** (if not already installed):
   ```bash
   sudo pacman -S nginx
   ```

2. **Enable Nginx to start at boot**:
   ```bash
   sudo systemctl enable nginx
   ```

3. **Start Nginx immediately**:
   ```bash
   sudo systemctl start nginx
   ```

### Verifying the Configuration

1. **Check the status of Nginx**:
   ```bash
   sudo systemctl status nginx
   ```

2. **Verify that Nginx is enabled**:
   ```bash
   sudo systemctl is-enabled nginx
   ```

### Troubleshooting

- **Check Nginx logs for errors**:
  - Access logs: `/var/log/nginx/access.log`
  - Error logs: `/var/log/nginx/error.log`

- **Reload Nginx configuration** (after making changes to the config files):
  ```bash
  sudo systemctl reload nginx
  ```

- **Restart Nginx service**:
  ```bash
  sudo systemctl restart nginx
  ```

By following these steps, you can ensure that Nginx will start automatically whenever your server reboots, keeping your web services running continuously.
