Skip to content

Commit 4d88cfb

Browse files
committed
Add Check The Syntax Of nginx Files as a devops til.
1 parent 8dd641c commit 4d88cfb

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
4444
### devops
4545

4646
- [Check The Status of All Services](devops/check-the-status-of-all-services.md)
47+
- [Check The Syntax Of nginx Files](devops/check-the-syntax-of-nginx-files.md)
4748
- [Push Non-master Branch To Heroku](devops/push-non-master-branch-to-heroku.md)
4849
- [Reload The nginx Configuration](devops/reload-the-nginx-configuration.md)
4950
- [Wipe A Heroku Postgres Database](devops/wipe-a-heroku-postgres-database.md)
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Check The Syntax Of nginx Files
2+
3+
The syntax of [`nginx`](https://www.nginx.com/) configuration files can be a
4+
bit finicky. On top of that, some `nginx` server commands can fail silently.
5+
Get more confidence by using the following command to check for syntax
6+
errors in those files:
7+
8+
```bash
9+
$ [sudo] nginx -t
10+
```
11+
12+
If there is an error, you might see something like this:
13+
14+
```bash
15+
$ sudo nginx -t
16+
nginx: [emerg] unexpected ";" in /etc/nginx/nginx.conf:16
17+
nginx: configuration file /etc/nginx/nginx.conf test failed
18+
```
19+
20+
If all looks good, then you'll see this:
21+
22+
```bash
23+
$ sudo nginx -t
24+
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
25+
nginx: configuration file /etc/nginx/nginx.conf test is successful
26+
```

0 commit comments

Comments
 (0)