<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged enable</title>
<link>https://coderlegion.com/tag/enable</link>
<description>Powered by Question2Answer</description>
<item>
<title>Why is Nginx configuration organized as sites-available and sites-enabled?</title>
<link>https://coderlegion.com/14075/why-is-nginx-configuration-organized-as-sites-available-and-sites-enabled</link>
<description>
&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In this article, We will exploring how to do nginx configuration directory structure. Why it is organized in this way?&lt;/p&gt;

&lt;h2&gt;
  
  
  How are ngix config files organized?
&lt;/h2&gt;

&lt;p&gt;Majorly nginx config files are organized in the following way:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Main config file: &lt;code&gt;/etc/nginx/nginx.conf&lt;/code&gt;
This deal with setting up global configuration for nginx.&lt;/li&gt;
&lt;li&gt;Sites available directory: &lt;code&gt;/etc/nginx/sites-available&lt;/code&gt;
This deal with setting up sites configuration for nginx. Where we can write multiple site configuration files.&lt;/li&gt;
&lt;li&gt;Sites enabled directory: &lt;code&gt;/etc/nginx/sites-enabled&lt;/code&gt;
This deal with enabling sites configuration for nginx. Where we can enable sites configuration.&lt;/li&gt;
&lt;li&gt;Logs directory: &lt;code&gt;/var/log/nginx&lt;/code&gt;
This deal with logs configuration for nginx. Where we can see logs of nginx.&lt;/li&gt;
&lt;li&gt;Cache directory: &lt;code&gt;/var/cache/nginx&lt;/code&gt;
This deal with cache configuration for nginx. Where we can see cache of nginx.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How to write site configuration file?
&lt;/h2&gt;

&lt;p&gt;A site configuration file is a file that is used to configure a site for nginx.&lt;/p&gt;

&lt;p&gt;Which you can further read in official documentation &lt;a href=&quot;https://nginx.org/en/docs/&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;https://nginx.org/en/docs/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;These configuration should be written in this directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;/etc/nginx/sites-available
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you write the configuration file. This will not enable the site.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to enable the site?
&lt;/h2&gt;

&lt;p&gt;To enable the site, you need to create a symbolic link from the sites-available directory to the sites-enabled directory.&lt;/p&gt;

&lt;p&gt;For example, if you have a site configuration file named &lt;code&gt;example.com&lt;/code&gt; in the &lt;code&gt;sites-available&lt;/code&gt; directory, you can enable it by running the following command:&lt;/p&gt;

&lt;p&gt;we should always test the configuration file before enabling it.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;nginx &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo ln&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a symbolic link from the sites-available directory to the sites-enabled directory.&lt;/p&gt;

&lt;p&gt;The core reason for using symbolic link is that it will allow us to enable and disable the site without removing the configuration file.&lt;/p&gt;

&lt;p&gt;if we directly put the configuration file in sites-enabled directory, then we need to remove the configuration file to disable the site.&lt;/p&gt;

&lt;p&gt;That means if I want to update small change.&lt;br&gt;
If the configration was copy to sites-enabled directory, then on nginx server restart, the changes will not be reflected.&lt;/p&gt;

&lt;p&gt;so, to make it easier we use symbolic link.&lt;/p&gt;

&lt;p&gt;Now once the site is enabled, we need to restart the nginx server to apply the changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl restart nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finaly we can access the site in browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to disable the site?
&lt;/h2&gt;

&lt;p&gt;To disable the site, you need to remove the symbolic link from the sites-enabled directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo rm&lt;/span&gt; /etc/nginx/sites-enabled/example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By this process it will not delete the configuration file. We can enable and disable the site without removing the configuration file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By this we understood how to enable and disable the site in nginx.&lt;/p&gt;

&lt;p&gt;How configuration file is organized in nginx.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;&lt;img src=&quot;https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png&quot; alt=&quot;git-lrc&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It&amp;rsquo;s online, source-available, and ready for anyone to use. &lt;br&gt;
&amp;#11088; Star it on GitHub: &lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;


</description>
<category>Other</category>
<guid isPermaLink="true">https://coderlegion.com/14075/why-is-nginx-configuration-organized-as-sites-available-and-sites-enabled</guid>
<pubDate>Thu, 16 Apr 2026 23:34:22 +0000</pubDate>
</item>
</channel>
</rss>