{"id":21478,"date":"2017-02-08T07:41:07","date_gmt":"2017-02-08T13:41:07","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=21478"},"modified":"2022-06-03T03:42:20","modified_gmt":"2022-06-03T08:42:20","slug":"how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/","title":{"rendered":"How to Set up Nginx Server Blocks on Ubuntu and CentOS"},"content":{"rendered":"<div id=\"bsf_rt_marker\"><\/div><p><img decoding=\"async\" class=\"alignnone size-full wp-image-24942\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1.jpg\" alt=\"How to Set up Nginx Server Blocks on Ubuntu and CentOS\" width=\"1200\" height=\"600\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1.jpg 1200w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1-150x75.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1-300x150.jpg 300w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1-768x384.jpg 768w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1-1024x512.jpg 1024w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1-860x430.jpg 860w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1-680x340.jpg 680w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1-500x250.jpg 500w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1-400x200.jpg 400w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1-200x100.jpg 200w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1-50x25.jpg 50w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p>In this tutorial, we are going to provide you with step by step instructions on how to set up nginx server blocks on <a href=\"https:\/\/www.rosehosting.com\/ubuntu-hosting.html\">Ubuntu 16.04 <\/a> and\u00a0\u00a0<a href=\"https:\/\/www.rosehosting.com\/centos-hosting.html\">CentOS 7.<\/a> Nginx server blocks are often used to run multiple websites on a single IP address.<\/p>\n<p><!--more--><\/p>\n<p><em>Note that this tutorial is for <a href=\"https:\/\/www.rosehosting.com\/nginx-hosting.html\">Nginx<\/a> only. If you use Apache, you&#8217;ll need to <\/em><a href=\"https:\/\/www.rosehosting.com\/blog\/apache-virtual-hosts-on-centos\/\"><em>set up virtual hosts<\/em> <\/a><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69e4d8a14e263\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e4d8a14e263\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/#1-Install-Nginx-on-Ubuntu\" >1. Install Nginx on Ubuntu<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/#2-Install-Nginx-on-CentOS\" >2. Install Nginx on CentOS<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/#3-Configure-nginx-and-set-up-nginx-server-blocks\" >3. Configure nginx and set up nginx server blocks<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/#4-Test-the-Nginx-configuration\" >4. Test the Nginx configuration<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"1-Install-Nginx-on-Ubuntu\"><\/span>1. Install Nginx on Ubuntu<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Make sure your server OS packages are fully up-to-date:<\/p>\n<pre>apt-get update \r\napt-get upgrade<\/pre>\n<p>Stop and remove Apache, then install nginx using the following commands:<\/p>\n<pre>service apache2 stop\r\napt-get remove apache2\r\napt-get autoremove\r\napt-get install nginx<\/pre>\n<p>Remove the default nginx configuration file:<\/p>\n<pre>rm \/etc\/nginx\/sites-enabled\/default<\/pre>\n<p>Enable nginx service to start on boot and start it:<\/p>\n<pre>systemctl enable nginx\r\nsystemctl start nginx.service<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"2-Install-Nginx-on-CentOS\"><\/span>2. Install Nginx on CentOS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Make sure that all OS packages are up to date by running the following commands:<\/p>\n<pre>yum clean all\r\nyum update<\/pre>\n<p>Stop and remove Apache if it is installed and running on your virtual server:<\/p>\n<pre>systemctl stop httpd\r\nsystemctl disable httpd\r\nyum remove httpd<\/pre>\n<p>Install nginx:<\/p>\n<pre>yum install nginx<\/pre>\n<p>Also, you may want to install PHP and MariaDB, so run the following command:<\/p>\n<pre>yum install nginx mariadb mariadb-server php php-fpm php-cli php-curl php-gd php-mbstring php-mysql php-xml<\/pre>\n<p>Edit the \/etc\/php-fpm.d\/www.conf configuration file and change:<\/p>\n<pre>user = apache\r\ngroup = apache<\/pre>\n<p>to:<\/p>\n<pre>user = www-data\r\ngroup = www-data<\/pre>\n<p>Run the following command:<\/p>\n<pre>chown www-data: -R \/var\/lib\/php\/session<\/pre>\n<p>Start the PHP-FPM, Nginx and MariaDB services and enable them to start on boot:<\/p>\n<pre>systemctl start php-fpm\r\nsystemctl start nginx\r\nsystemctl start mariadb<\/pre>\n<pre>systemctl enable php-fpm\r\nsystemctl enable nginx\r\nsystemctl enable mariadb<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"3-Configure-nginx-and-set-up-nginx-server-blocks\"><\/span>3. Configure nginx and set up nginx server blocks<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Let&#8217;s configure the core directives in the main nginx configuration file named &#8216;nginx.conf&#8217;. It should be located in the \/etc\/nginx\/ directory on your server.<\/p>\n<pre>vi \/etc\/nginx\/nginx.conf<\/pre>\n<pre>user www-data;\r\nworker_processes 4;\r\npid \/var\/run\/nginx.pid;<\/pre>\n<p><strong>user<\/strong> &#8211; a user which will own and run the nginx server.<\/p>\n<p><strong>worker_processes<\/strong> &#8211; in general, it is best to set the nginx worker_processes config to the number of CPUs. If for example you are using our <a href=\"https:\/\/www.rosehosting.com\/managed-vps-hosting.html\">SSD 4 VPS<\/a> plan, set worker_processes to 4.<\/p>\n<p>To check the number of CPUs on your server, you may use the following command:<\/p>\n<pre>#cat \/proc\/cpuinfo | grep processor | wc -l\r\n\r\n4<\/pre>\n<p><strong>pid<\/strong> &#8211; the location where nginx will write its master process ID, or PID.<\/p>\n<p>If you use CentOS, create a new Nginx configuration file for your website:<\/p>\n<pre>vi \/etc\/nginx\/conf.d\/domain1.com.conf<\/pre>\n<p>Add the following content:<\/p>\n<pre>server {\r\n    server_name www.domain1.com domain1.com;\r\n    listen 80;\r\n    root \/var\/www\/html\/domain1.com;\r\n    access_log \/var\/log\/nginx\/domain1.com-access.log;\r\n    error_log \/var\/log\/nginx\/domain1.com-error.log;\r\n    index index.php;\r\n \r\n    location \/ {\r\n        try_files  $uri $uri\/ \/index.php?$args;\r\n    }\r\n\r\n    location ~* \\.(jpg|jpeg|gif|css|png|js|ico|html)$ {\r\n        access_log off;\r\n        expires max;\r\n    }\r\n\r\n    location ~ \\.php$ {\r\n        try_files $uri = 404;\r\n        fastcgi_split_path_info ^(.+\\.php)(\/.+)$;\r\n        fastcgi_pass 127.0.0.1:9000;\r\n        fastcgi_index index.php;\r\n        include \/etc\/nginx\/fastcgi_params;\r\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n    }\r\n\r\n    location ~ \/\\.ht {\r\n        deny all;\r\n    }\r\n\r\n}<\/pre>\n<p>If you need to host more than one website on the same server (using the same IP address), you can create a new server block. It is best to create a new configuration file for each website.<\/p>\n<p>For example, create a second nginx configuration file named \/etc\/nginx\/conf.d\/domain2.com.conf and add the same content as \/etc\/nginx\/conf.d\/domain1.com.conf , but make sure to replace domain1.com with the second domain name including the document root of your website, location of log files etc.:<\/p>\n<pre>server {\r\n    server_name www.domain2.com domain2.com;\r\n    listen 80;\r\n    root \/var\/www\/html\/domain2.com;\r\n    access_log \/var\/log\/nginx\/domain2.com-access.log;\r\n    error_log \/var\/log\/nginx\/domain2.com-error.log;\r\n    index index.php;\r\n \r\n    location \/ {\r\n        try_files  $uri $uri\/ \/index.php?$args;\r\n    }\r\n\r\n    location ~* \\.(jpg|jpeg|gif|css|png|js|ico|html)$ {\r\n        access_log off;\r\n        expires max;\r\n    }\r\n\r\n    location ~ \\.php$ {\r\n        try_files $uri = 404;\r\n        fastcgi_split_path_info ^(.+\\.php)(\/.+)$;\r\n        fastcgi_pass 127.0.0.1:9000;\r\n        fastcgi_index index.php;\r\n        include \/etc\/nginx\/fastcgi_params;\r\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n    }\r\n\r\n    location ~ \/\\.ht {\r\n        deny all;\r\n    }\r\n\r\n}<\/pre>\n<p>If you use Ubuntu OS, create the &#8216;domain1.com.conf&#8217; nginx configuration file to the \/etc\/nginx\/sites-available directory.<\/p>\n<pre>vi \/etc\/nginx\/sites-enabled\/domain1.com.conf<\/pre>\n<p>(add the same content as the content listed above, i.e. \/etc\/nginx\/conf.d\/domain1.com.conf on a CentOS server).<\/p>\n<p>Then, create a symbolic link from this file to the sites-enabled directory:<\/p>\n<pre>ln -s \/etc\/nginx\/sites-available\/example.com \/etc\/nginx\/sites-enabled\/<\/pre>\n<p>Repeat the same procedure and create new configuration files for all other websites hosted on the server.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"4-Test-the-Nginx-configuration\"><\/span>4. Test the Nginx configuration<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre>nginx -t<\/pre>\n<p>It the test is successful, restart the Nginx service:<\/p>\n<pre>systemctl restart nginx<\/pre>\n<p>Upload your website files to the \/var\/www\/html\/domain1.com , \/var\/www\/html\/domain2.com \/var\/www\/html\/domainN.com directories.<\/p>\n<p>The web server user (www-data) needs to have access to \/var\/www\/html\/domain1.com , \/var\/www\/html\/domain2.com , \/var\/www\/html\/domainN.com directories. It can easily be accomplished by executing the following command:<\/p>\n<pre>chown -R www-data:www-data \/var\/www\/html\/<\/pre>\n<p>Of course you don&#8217;t have to How to Set up Nginx Server Blocks on Ubuntu and CentOS,\u00a0 if you use one of our <a href=\"https:\/\/www.rosehosting.com\/nginx-hosting.html\">Nginx VPS Hosting services<\/a>, in which case you can simply ask our expert Linux admins to <strong>set up nginx server blocks<\/strong> for you. They are available 24&#215;7 and will take care of your request immediately.<\/p>\n<p><span style=\"color: #ff0000;\"><strong>PS.<\/strong><\/span> If you liked this post, on how to set up Nginx Server Blocks on Ubuntu and CentOS,\u00a0 please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we are going to provide you with step by step instructions on how to set up nginx &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"How to Set up Nginx Server Blocks on Ubuntu and CentOS\" class=\"read-more button\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/#more-21478\" aria-label=\"Read more about How to Set up Nginx Server Blocks on Ubuntu and CentOS\">Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":24942,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1699,13,1698,1707],"tags":[34,49,1510,59],"class_list":["post-21478","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-tutorials","category-ubuntu","category-web-servers","tag-centos","tag-nginx","tag-server-blocks","tag-ubuntu","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Set up Nginx Server Blocks on Ubuntu and CentOS | RoseHosting<\/title>\n<meta name=\"description\" content=\"How to Set up Nginx Server Blocks on Ubuntu and CentOS | RoseHosting\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Set up Nginx Server Blocks on Ubuntu and CentOS\" \/>\n<meta property=\"og:description\" content=\"How to Set up Nginx Server Blocks on Ubuntu and CentOS | RoseHosting\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/\" \/>\n<meta property=\"og:site_name\" content=\"RoseHosting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/RoseHosting\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/rosehosting.helpdesk\" \/>\n<meta property=\"article:published_time\" content=\"2017-02-08T13:41:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-06-03T08:42:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jeff Wilson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:site\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeff Wilson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\\\/\"},\"author\":{\"name\":\"Jeff Wilson\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\"},\"headline\":\"How to Set up Nginx Server Blocks on Ubuntu and CentOS\",\"datePublished\":\"2017-02-08T13:41:07+00:00\",\"dateModified\":\"2022-06-03T08:42:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\\\/\"},\"wordCount\":649,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1.jpg\",\"keywords\":[\"centos\",\"nginx\",\"server blocks\",\"ubuntu\"],\"articleSection\":[\"CentOS\",\"Tutorials\",\"Ubuntu\",\"Web Servers\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\\\/\",\"name\":\"How to Set up Nginx Server Blocks on Ubuntu and CentOS | RoseHosting\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1.jpg\",\"datePublished\":\"2017-02-08T13:41:07+00:00\",\"dateModified\":\"2022-06-03T08:42:20+00:00\",\"description\":\"How to Set up Nginx Server Blocks on Ubuntu and CentOS | RoseHosting\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1.jpg\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1.jpg\",\"width\":1200,\"height\":600,\"caption\":\"How to Set up Nginx Server Blocks on Ubuntu and CentOS\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Set up Nginx Server Blocks on Ubuntu and CentOS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"name\":\"RoseHosting.com\",\"description\":\"Premium Linux Tutorials Since 2001\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\",\"name\":\"RoseHosting\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"width\":192,\"height\":192,\"caption\":\"RoseHosting\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/RoseHosting\",\"https:\\\/\\\/x.com\\\/rosehosting\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/rosehosting\\\/\"],\"description\":\"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.\",\"email\":\"info@rosehosting.com\",\"telephone\":\"(314) 275-0414\",\"legalName\":\"Rose Web Services LLC\",\"foundingDate\":\"2001-04-02\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"11\",\"maxValue\":\"50\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\",\"name\":\"Jeff Wilson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"caption\":\"Jeff Wilson\"},\"description\":\"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.\",\"sameAs\":[\"https:\\\/\\\/www.rosehosting.com\",\"https:\\\/\\\/www.facebook.com\\\/rosehosting.helpdesk\"],\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/author\\\/jwilson\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Set up Nginx Server Blocks on Ubuntu and CentOS | RoseHosting","description":"How to Set up Nginx Server Blocks on Ubuntu and CentOS | RoseHosting","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/","og_locale":"en_US","og_type":"article","og_title":"How to Set up Nginx Server Blocks on Ubuntu and CentOS","og_description":"How to Set up Nginx Server Blocks on Ubuntu and CentOS | RoseHosting","og_url":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/","og_site_name":"RoseHosting","article_publisher":"https:\/\/www.facebook.com\/RoseHosting","article_author":"https:\/\/www.facebook.com\/rosehosting.helpdesk","article_published_time":"2017-02-08T13:41:07+00:00","article_modified_time":"2022-06-03T08:42:20+00:00","og_image":[{"width":1200,"height":600,"url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1.jpg","type":"image\/jpeg"}],"author":"Jeff Wilson","twitter_card":"summary_large_image","twitter_creator":"@rosehosting","twitter_site":"@rosehosting","twitter_misc":{"Written by":"Jeff Wilson","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/#article","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/"},"author":{"name":"Jeff Wilson","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713"},"headline":"How to Set up Nginx Server Blocks on Ubuntu and CentOS","datePublished":"2017-02-08T13:41:07+00:00","dateModified":"2022-06-03T08:42:20+00:00","mainEntityOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/"},"wordCount":649,"commentCount":1,"publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1.jpg","keywords":["centos","nginx","server blocks","ubuntu"],"articleSection":["CentOS","Tutorials","Ubuntu","Web Servers"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/","url":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/","name":"How to Set up Nginx Server Blocks on Ubuntu and CentOS | RoseHosting","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/#primaryimage"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1.jpg","datePublished":"2017-02-08T13:41:07+00:00","dateModified":"2022-06-03T08:42:20+00:00","description":"How to Set up Nginx Server Blocks on Ubuntu and CentOS | RoseHosting","breadcrumb":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/#primaryimage","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1.jpg","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/02\/How-to-Set-up-Nginx-Server-Blocks-on-Ubuntu-and-CentOS-1.jpg","width":1200,"height":600,"caption":"How to Set up Nginx Server Blocks on Ubuntu and CentOS"},{"@type":"BreadcrumbList","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-set-up-nginx-server-blocks-on-ubuntu-and-centos\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.rosehosting.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Set up Nginx Server Blocks on Ubuntu and CentOS"}]},{"@type":"WebSite","@id":"https:\/\/www.rosehosting.com\/blog\/#website","url":"https:\/\/www.rosehosting.com\/blog\/","name":"RoseHosting.com","description":"Premium Linux Tutorials Since 2001","publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.rosehosting.com\/blog\/#organization","name":"RoseHosting","url":"https:\/\/www.rosehosting.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","width":192,"height":192,"caption":"RoseHosting"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/RoseHosting","https:\/\/x.com\/rosehosting","https:\/\/www.linkedin.com\/in\/rosehosting\/"],"description":"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.","email":"info@rosehosting.com","telephone":"(314) 275-0414","legalName":"Rose Web Services LLC","foundingDate":"2001-04-02","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"11","maxValue":"50"}},{"@type":"Person","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713","name":"Jeff Wilson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","caption":"Jeff Wilson"},"description":"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.","sameAs":["https:\/\/www.rosehosting.com","https:\/\/www.facebook.com\/rosehosting.helpdesk"],"url":"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/21478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/comments?post=21478"}],"version-history":[{"count":1,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/21478\/revisions"}],"predecessor-version":[{"id":41896,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/21478\/revisions\/41896"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media\/24942"}],"wp:attachment":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media?parent=21478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/categories?post=21478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/tags?post=21478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}