# Nginx: nginx: [emerg] unknown directive "x" in /etc/nginx/sites-enabled/x:12 — configuration file test failed

**Code:** `nginx: [emerg] unknown directive` · **Category:** Nginx / Apache · **Seen on:** Nginx

Nginx found a directive it doesn’t know — a typo, a missing semicolon on the previous line, a directive from a module that isn’t installed, or Apache syntax in an Nginx file.

## Meaning

Always run nginx -t before reload. Missing ; makes the next word look like a directive. Directives like more_set_headers, brotli, geoip2 need dynamic modules loaded.

## Common causes

- Typo or missing semicolon on the previous line
- Module not installed/loaded (headers-more, brotli, geoip2)
- Apache/.htaccess syntax pasted into Nginx
- Hidden characters (BOM, smart quotes)

## Quick fix

1. Run sudo nginx -t and check the reported line and the one before
2. Install/load the module (load_module)
3. Translate Apache rules to Nginx equivalents

## Detailed fix by platform

### Shell

1. 

```nginx
sudo nginx -t
sudo nginx -V 2>&1 | tr ' ' '
' | grep module
```


## How to diagnose

1. **Line** — Reported line and the previous one
2. **Modules** — nginx -V

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/nginx-apache/nginx-emerg-unknown-directive)
