{"id":280648,"date":"2021-06-22T14:47:00","date_gmt":"2021-06-22T11:47:00","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-test-your-nginx-config-file-and-why-you-should-cloudsavvy-it\/"},"modified":"2021-06-22T14:47:00","modified_gmt":"2021-06-22T11:47:00","slug":"how-to-test-your-nginx-config-file-and-why-you-should-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-test-your-nginx-config-file-and-why-you-should-cloudsavvy-it\/","title":{"rendered":"#How to Test Your Nginx Config File (and Why You Should) \u2013 CloudSavvy IT"},"content":{"rendered":"<p><strong>&#8220;#How to Test Your Nginx Config File (and Why You Should) \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<figure style=\"width: 1676px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage wp-image-4029 size-full\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/7950f98f.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"NGINX Logo\" width=\"1676\" height=\"748\" src=\"https:\/\/www.nginx.com\/\" data-credittext=\"NGINX\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><figcaption class=\"wp-caption-text\"><span class=\"type:primaryImage imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.nginx.com\/\">NGINX<\/a><\/span><\/figcaption><\/figure>\n<p>If you\u2019re making changes to your nginx configuration files, you are running a huge risk if you restart nginx and you made a mistake, a typo, or copied and pasted from Stackoverflow wrong. Luckily there\u2019s an easy built-in way to test your configuration files to make sure they won\u2019t break everything.<\/p>\n<p>The worst part about making a mistake in your config files is that nginx will stop and it won\u2019t start back up again until you fix the problem. So anybody trying to visit your site will get a fun error page.<\/p>\n<p>So first you\u2019ll want to figure out where nginx is located, which you can always do with a quick <code>ps -ef | grep nginx<\/code> (or many other methods that produce similar output).<\/p>\n<p>So now that we know where the binary is located, just simply run it with the -t argument.<\/p>\n<pre>\/usr\/local\/nginx\/sbin\/nginx -t<\/pre>\n<p>If you made a mistake, you\u2019ll get an error message that indicates it failed.<\/p>\n<p>If it succeeded, you\u2019ll get a message that everything is fine.<\/p>\n<p>So now that you know your syntax is correct, you can restart nginx (gracefully) by using service nginx reload. Or\u2026 you could chain them together so the reload h<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>ens but only if the syntax was correct, using the &amp;&amp; operator like this:<\/p>\n<pre>\/usr\/local\/nginx\/sbin\/nginx -t &amp;&amp; \/usr\/local\/nginx\/sbin\/nginx -s reload<\/pre>\n<p>It\u2019s worth noting that your nginx might be located in a different folder, so you should adjust the path accordingly.\n<\/p><\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/2496\/how-to-test-your-nginx-config-file-and-why-you-should\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Test Your Nginx Config File (and Why You Should) \u2013 CloudSavvy IT&#8221; NGINX If you\u2019re making changes to your nginx configuration files, you are running a huge risk if you restart nginx and you made a mistake, a typo, or copied and pasted from Stackoverflow wrong. Luckily there\u2019s an easy built-in way to&#8230;<\/p>\n","protected":false},"author":1,"featured_media":280649,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/7950f98f.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-280648","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/280648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=280648"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/280648\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/280649"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=280648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=280648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=280648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}