{"id":6207,"date":"2021-04-03T13:24:20","date_gmt":"2021-04-03T07:54:20","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=6207"},"modified":"2026-12-01T14:06:19","modified_gmt":"2026-12-01T08:36:19","slug":"nginx-missing-sites-available-directory-in-the-nginx-configuration-directory","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/nginx-missing-sites-available-directory-in-the-nginx-configuration-directory\/","title":{"rendered":"Nginx Missing Sites-Available Directory in the Nginx Configuration Directory"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong><strong>Post Date:<\/strong><\/strong> April 3, 2021<strong><br><strong>Last Updated:<\/strong> <\/strong>December 01, 2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When <a href=\"https:\/\/nginx.org\/en\/linux_packages.html\" target=\"_blank\" rel=\"noopener\">installing Nginx on CentOS 7<\/a>, you may notice that the Nginx sites-available directory is missing from the default <code>\/etc\/nginx\/<\/code> configuration directory. This can make managing virtual hosts different from the standard Ubuntu and Debian Nginx configuration structure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Unlike Ubuntu and Debian, the default Nginx installation on CentOS 7 generally uses the <code>conf.d<\/code> directory to manage additional server configuration files. However, if you prefer the <code>sites-available<\/code> and <code>sites-enabled<\/code> directory structure, you can manually create and configure these directories.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this guide, we will explain how to create the missing Nginx directories, configure the main Nginx configuration file, enable virtual hosts using symbolic links, and alternatively manage virtual host configurations directly through the <code>conf.d<\/code> directory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Are Sites-Available and Sites-Enabled Directories Missing in Nginx?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>sites-available<\/code> and <code>sites-enabled<\/code> directories are not included by default in every Nginx installation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These directories are commonly used in Debian and Ubuntu-based distributions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>sites-available:<\/strong> Stores all available virtual host configuration files.<\/li>\n\n\n\n<li><strong>sites-enabled:<\/strong> Contains symbolic links to the virtual host configurations that should be active.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">On CentOS 7, Nginx typically uses the <code>\/etc\/nginx\/conf.d\/<\/code> directory to load additional configuration files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can manually configure the <code>sites-available<\/code> and <code>sites-enabled<\/code> directories by following the steps below.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Create Sites-Available and Sites-Enabled Directories in Nginx on CentOS 7<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Create the Missing Directories<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">First, create the <code>sites-available<\/code> and <code>sites-enabled<\/code> directories inside the Nginx configuration directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run the following commands:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkdir -p \/etc\/nginx\/sites-available\nmkdir -p \/etc\/nginx\/sites-enabled<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Setup-Terminal.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"400\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Setup-Terminal-1024x400.png\" alt=\"Create Nginx sites-available and sites-enabled directories on CentOS 7.Nginx sites-available directory configuration on CentOS 7\" class=\"wp-image-14183\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Setup-Terminal-1024x400.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Setup-Terminal-300x117.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Setup-Terminal-768x300.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Setup-Terminal-1536x600.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Setup-Terminal.png 2007w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Set the appropriate directory ownership and permissions:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chown -R root:root \/etc\/nginx\/sites-available\nchown -R root:root \/etc\/nginx\/sites-enabled\n\nchmod 755 \/etc\/nginx\/sites-available\nchmod 755 \/etc\/nginx\/sites-enabled<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">These directories will now be available for managing your Nginx virtual host configuration files.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Permissions-Terminal.png\"><img decoding=\"async\" width=\"1024\" height=\"341\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Permissions-Terminal-1024x341.png\" alt=\"Set root ownership and 755 permissions for Nginx sites-available and sites-enabled directories on CentOS 7.\" class=\"wp-image-14184\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Permissions-Terminal-1024x341.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Permissions-Terminal-300x100.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Permissions-Terminal-768x256.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Permissions-Terminal-1536x512.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Directory-Permissions-Terminal-2048x683.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Configure the Nginx Main Configuration File<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Open the main Nginx configuration file:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">vi \/etc\/nginx\/nginx.conf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Locate the <code>http<\/code> block and add the following include directive inside it:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">include \/etc\/nginx\/sites-enabled\/*;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http {\n    include       \/etc\/nginx\/mime.types;\n    default_type  application\/octet-stream;\n\n    include \/etc\/nginx\/conf.d\/*.conf;\n    include \/etc\/nginx\/sites-enabled\/*;\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save the file and exit the editor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> If your existing configuration already includes the <code>conf.d<\/code> directory, do not add the same include directive again.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Adding-Sites-Enabled-to-Nginx.png\"><img decoding=\"async\" width=\"1024\" height=\"341\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Adding-Sites-Enabled-to-Nginx-1024x341.png\" alt=\"Configure Nginx nginx.conf to include the sites-enabled directory inside the HTTP block on CentOS 7.\" class=\"wp-image-14185\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Adding-Sites-Enabled-to-Nginx-1024x341.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Adding-Sites-Enabled-to-Nginx-300x100.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Adding-Sites-Enabled-to-Nginx-768x256.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Adding-Sites-Enabled-to-Nginx-1536x512.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Adding-Sites-Enabled-to-Nginx-2048x683.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Create a Virtual Host Configuration File<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now, create a separate virtual host configuration file inside the <code>sites-available<\/code> directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">vi \/etc\/nginx\/sites-available\/example.com<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following sample configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">server {\n    listen 80;\n    server_name example.com www.example.com;\n\n    root \/var\/www\/html;\n    index index.html index.htm;\n\n    location \/ {\n        try_files $uri $uri\/ =404;\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>example.com<\/code> with your actual domain name and update the document root according to your website directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Save the configuration file.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Virtual-Host-Configuration-Guide.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"419\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Virtual-Host-Configuration-Guide-1024x419.png\" alt=\"Create an Nginx virtual host configuration file for example.com in CentOS 7.\" class=\"wp-image-14186\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Virtual-Host-Configuration-Guide-1024x419.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Virtual-Host-Configuration-Guide-300x123.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Virtual-Host-Configuration-Guide-768x314.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Virtual-Host-Configuration-Guide-1536x628.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Virtual-Host-Configuration-Guide.png 1961w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Enable the Virtual Host Using a Symbolic Link<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To activate the virtual host, create a symbolic link from the <code>sites-available<\/code> directory to the <code>sites-enabled<\/code> directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ln -s \/etc\/nginx\/sites-available\/example.com \/etc\/nginx\/sites-enabled\/example.com<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This allows you to maintain all virtual host configurations in <code>sites-available<\/code> and enable or disable individual websites through symbolic links.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before applying the configuration, test the Nginx configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nginx -t<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the configuration is valid, reload Nginx:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl reload nginx<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If necessary, you can restart the service using:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl restart nginx<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Your virtual host configuration should now be active.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Service-Running-Successfully.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"341\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Service-Running-Successfully-1024x341.png\" alt=\"Test Nginx configuration using nginx -t and reload or restart the Nginx service on CentOS 7.\" class=\"wp-image-14187\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Service-Running-Successfully-1024x341.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Service-Running-Successfully-300x100.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Service-Running-Successfully-768x256.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Service-Running-Successfully-1536x512.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Service-Running-Successfully-2048x683.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Alternative Method: Use the Conf.d Directory Without Symbolic Links<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you do not want to manage virtual host configurations using <code>sites-available<\/code> and <code>sites-enabled<\/code>, you can use the default Nginx <code>conf.d<\/code> directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is the standard approach commonly used in CentOS 7 Nginx installations.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Create the Conf.d Directory<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Check whether the directory already exists:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ls -ld \/etc\/nginx\/conf.d<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If it does not exist, create it:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkdir -p \/etc\/nginx\/conf.d<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Set the appropriate permissions:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chown root:root \/etc\/nginx\/conf.d\nchmod 755 \/etc\/nginx\/conf.d<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-Directory-Setup.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"341\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-Directory-Setup-1024x341.png\" alt=\"Create the Nginx conf.d directory and configure root ownership and 755 permissions on CentOS 7.\" class=\"wp-image-14188\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-Directory-Setup-1024x341.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-Directory-Setup-300x100.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-Directory-Setup-768x256.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-Directory-Setup-1536x512.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-Directory-Setup-2048x683.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Configure the Nginx Include Directive<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Open the Nginx configuration file:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">vi \/etc\/nginx\/nginx.conf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Inside the <code>http<\/code> block, make sure the following include directive is present:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">include \/etc\/nginx\/conf.d\/*.conf;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http {\n    include       \/etc\/nginx\/mime.types;\n    default_type  application\/octet-stream;\n\n    include \/etc\/nginx\/conf.d\/*.conf;\n}<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Include-Directive-in-HTTP-Block.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"418\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Include-Directive-in-HTTP-Block-1024x418.png\" alt=\"Add the Nginx conf.d include directive inside the HTTP block of nginx.conf on CentOS 7.\" class=\"wp-image-14189\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Include-Directive-in-HTTP-Block-1024x418.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Include-Directive-in-HTTP-Block-300x122.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Include-Directive-in-HTTP-Block-768x314.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Include-Directive-in-HTTP-Block-1536x627.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Include-Directive-in-HTTP-Block.png 1962w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Important:<\/strong> If this directive already exists, you do not need to add it again.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Our DevOps and Cloud infrastructure experts can help you install, configure, and manage Nginx web servers, troubleshoot server configuration issues, set up virtual hosts, configure SSL certificates, and optimize web server performance. We also provide professional Linux server administration, Nginx migration, website deployment, server security, and cloud infrastructure management services.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/devops-cloud\/\">Explore our DevOps &amp; Cloud Services<\/a>.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Create a Separate Virtual Host Configuration File<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a configuration file for your domain inside the <code>conf.d<\/code> directory:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">vi \/etc\/nginx\/conf.d\/example.com.conf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following sample virtual host configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">server {\n    listen 80;\n    server_name example.com www.example.com;\n\n    root \/var\/www\/html;\n    index index.html index.htm;\n\n    location \/ {\n        try_files $uri $uri\/ =404;\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save the file after updating the domain name and website document root.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Annotated-Nginx-Configuration-Terminal.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"432\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Annotated-Nginx-Configuration-Terminal-1024x432.png\" alt=\"Create an Nginx virtual host configuration file in the conf.d directory using CentOS 7 terminal.\" class=\"wp-image-14190\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Annotated-Nginx-Configuration-Terminal-1024x432.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Annotated-Nginx-Configuration-Terminal-300x127.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Annotated-Nginx-Configuration-Terminal-768x324.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Annotated-Nginx-Configuration-Terminal-1536x649.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Annotated-Nginx-Configuration-Terminal.png 1930w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Test and Restart Nginx<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before restarting Nginx, verify that the configuration syntax is correct:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nginx -t<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the test is successful, reload the Nginx service:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl reload nginx<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also check the service status:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl status nginx<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Your virtual host configuration is now loaded directly from the <code>conf.d<\/code> directory without requiring symbolic links.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-and-Service-Status.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"422\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-and-Service-Status-1024x422.png\" alt=\"Test Nginx configuration using nginx -t, reload the Nginx service, and verify service status on CentOS 7.\" class=\"wp-image-14191\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-and-Service-Status-1024x422.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-and-Service-Status-300x124.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-and-Service-Status-768x316.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-and-Service-Status-1536x633.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Configuration-and-Service-Status.png 1954w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">How to Verify the Nginx Virtual Host Configuration<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After enabling your virtual host, you can verify that Nginx has loaded the configuration correctly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nginx -T<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command displays the complete Nginx configuration, including the files loaded through the include directives.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also check the Nginx service status:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl status nginx<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To test your website locally, run:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">curl -I http:\/\/example.com<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>example.com<\/code> with your actual domain name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure your domain DNS records point to the correct server IP address and that the required firewall ports are open.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>sites-available<\/code> and <code>sites-enabled<\/code> directories are not created automatically in every Nginx installation, particularly on CentOS 7. This is because CentOS commonly follows a different Nginx configuration structure and uses the <code>conf.d<\/code> directory to manage virtual hosts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you prefer the Ubuntu-style configuration structure, you can manually create the missing directories and configure the appropriate include directive in <code>nginx.conf<\/code>. Alternatively, you can use the default <code>conf.d<\/code> directory to manage separate virtual host configuration files without creating symbolic links.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Both approaches work for managing multiple websites on an Nginx server. Choose the directory structure that best suits your server administration and configuration management requirements.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Frequently Asked Questions (FAQs)<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Why is the sites-available directory missing in Nginx on CentOS 7?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>sites-available<\/code> directory is not created by default in many CentOS 7 Nginx installations. Unlike Ubuntu and Debian, CentOS generally uses the <code>\/etc\/nginx\/conf.d\/<\/code> directory to manage virtual host configuration files. You can manually create <code>sites-available<\/code> and <code>sites-enabled<\/code> directories and configure them in <code>nginx.conf<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. How do I enable sites-available and sites-enabled in Nginx?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create both directories inside <code>\/etc\/nginx\/<\/code> and add the following directive inside the <code>http<\/code> block of <code>\/etc\/nginx\/nginx.conf<\/code>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">include \/etc\/nginx\/sites-enabled\/*;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Create your virtual host configuration inside <code>sites-available<\/code> and use a symbolic link to enable it in <code>sites-enabled<\/code>. Then test and reload Nginx.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Can I configure Nginx virtual hosts without using sites-available and sites-enabled?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. You can use the default <code>\/etc\/nginx\/conf.d\/<\/code> directory instead. Create separate virtual host configuration files with a <code>.conf<\/code> extension, such as <code>example.com.conf<\/code>, and ensure that <code>nginx.conf<\/code> includes:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">include \/etc\/nginx\/conf.d\/*.conf;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Test the configuration using <code>nginx -t<\/code> and reload Nginx to apply the changes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-install-lets-encrypt-with-apache-on-centos-7\/\">How to Install Let\u2019s Encrypt with Apache on CentOS 7<\/a><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-block-ips-via-htaccess-file\/\">How to Block IPs via .htaccess File<\/a><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Nginx Server Configuration and DevOps Support<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Managing Nginx web servers, configuring virtual hosts, resolving server configuration errors, and maintaining reliable Linux infrastructure are essential for website availability and performance. At <a href=\"https:\/\/pheonixsolutions.com\/devops-cloud\/\">Pheonix Solutions<\/a>, our DevOps experts help businesses configure Nginx servers, troubleshoot web server issues, manage virtual hosts, configure SSL certificates, and maintain secure cloud infrastructure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can help you with:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/pheonixsolutions.com\/devops-cloud\/\">DevOps and Cloud Services<\/a> for Nginx server administration, virtual host configuration, Linux server management, SSL setup, server troubleshooting, and cloud infrastructure management.<\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/web-development\/\">Website Development<\/a> to build secure, responsive, and high-performing websites with reliable Nginx hosting and deployment environments.<\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/software-maintenance-and-support\/\">Software Maintenance and Support<\/a> to troubleshoot website and server issues, maintain application environments, optimize web server performance, and ensure smooth operations.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Need help configuring Nginx virtual hosts, resolving missing configuration directories, setting up SSL certificates, or managing your Linux web server? <a href=\"https:\/\/pheonixsolutions.com\/contact\/\">Talk to our DevOps and Cloud experts<\/a> to discuss your requirements.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post Date: April 3, 2021Last Updated: December 01, 2026 Introduction When installing Nginx on CentOS 7, you may notice that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":14192,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[840,271,841],"class_list":["post-6207","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-architecture","tag-missing-sites-available","tag-nginx","tag-vhost-file","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1C7","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/04\/Nginx-Sites-Available-on-CentOS-7.png","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=6207"}],"version-history":[{"count":2,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6207\/revisions"}],"predecessor-version":[{"id":14194,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6207\/revisions\/14194"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media\/14192"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=6207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=6207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=6207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}