• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Nginx Configuration With include Directive For WordPress

By Abhishek Ghosh July 28, 2015 10:48 pm Updated on July 28, 2015

Nginx Configuration With include Directive For WordPress

Advertisement

Specially for HSTS WordPress configuration, the configuration file which is, by default /etc/nginx/sites-available/default gets quite bigger. Nginx Configuration With include Directive Can Make the default of nginx.conf file less bloated specially for WordPress W3C like plugins. There are some stuffs to keep in mind for this work.

 

What To Remember For Using Nginx Configuration With include Directive

 

Too much include can make the front end slower. It becomes like, go and read from /etc/nginx/sites-available/default, then go to /etc/nginx/w3c.conf (example); if file ownership and permission is right, then read it, else print error. It is very minute, sometimes invisible change for using too many includes, but logically it can happen when the memory is at margin or server load is higher.

In other words, we will ONLY use the include directive for adding the extras. There is other advantage specially for WordPress W3C Plugin. If we place the W3C settings specific file at location which is readable and writable to W3C, if the location of configuration is corrected from W3C Plugin’s dashboard, it becomes “automatic” for the changes. Same goes for WordPress SEO like common plugins.

Advertisement

---

We can not include the major directions like :

Vim
1
2
3
4
5
6
7
8
9
  server {
    listen       80;
    server_name  jima.in;
    access_log   logs/jima.access.log  main;
    location ~ ^/(images|javascript|js|css|flash|media|static)/  {
      root    /var/www/virtual/jima/htdocs;
      expires 30d;
    }

The nginx.conf file by default includes /etc/nginx/conf.d/ directory. If we place the conf files there, we actually need no separate addition of one line on /etc/nginx/sites-available/default but it probably will be not writeable by PHP (or rather WordPress plugins) in a secured setup.

It is not a great idea to place files in /usr/share/nginx/html (default public root location) or equivalent publicly accessible location.

 

Nginx Configuration With include Directive

 

We have a NGINX configuration as example in GitHub. If you see the default file there, it is hugely big. It is difficult to find a line and manage. Line number 209 to 342 is of WordPress W3C Plugin. You can see this gist here.

We could name it as w3c instead of w3c.conf. If we put that file in /etc/nginx/conf.d/ location, nginx.conf will pick it up without doing anything :

Vim
1
include /etc/nginx/conf.d/*.conf;

In other words, in that case of placing in /etc/nginx/conf.d/ location, we have no work with /etc/nginx/nginx.conf or /etc/nginx/sites-available/default like file. Simply running the config test ( nginx -t ) and restarting nginx should work fine.

BUT, that can get loaded prior to a direction we wanted. Instead, exactly like the SSL certs, we will create a separate directory and chown, chmod it for reading :

Vim
1
2
3
4
mkdir -p /var/nginx/myconfig
sudo chown www-data:nginx /var/nginx/myconfig -R
sudo chmod g+w /var/nginx/myconfig -R
nano /var/nginx/myconfig/w3c.conf

Now, in our example, we are picking up the lines from /etc/nginx/sites-available/default file counting number 209 to 342. We have to vanish the lines first there. Then on line number 209, we will add :

/etc/nginx/sites-available/default
Vim
1
include /var/nginx/myconfig/w3c.conf;

If it throws error after running the config test ( nginx -t ), we will comment the line and add the line within active server block :

Vim
1
2
3
4
5
server {
  listen 443 default spdy;
  server_name thecustomizewindows.com;
include /var/nginx/myconfig/w3c.conf;
...

Nginx Configuration With include Directive For WordPress

 

Nginx Configuration With include Directive Throwing Errors

 

There can never be any error if you follow this method. Nginx is not a herbal product that there will be no logic, most common reason of getting error is too many commented out lines. Nano is a dangerous text editor, if you do not know vim at all, we will suggest to learn vi a bit.

One day I casually opened a XML file of a git (of our company’s one software under development) with nano and nano added line breaks on each line. If it was nginx, the situation became :

Vim
1
2
include
/var/nginx/myconfig/w3c.conf;

Now, obviously nginx will read the empty include first and throw error. It is not very easy to locate such line break on server from SSH and use sed and/or tr to remove the line breaks. Always, when a thing is working, take multiple backups in multiple ways first.

Tagged With nginx include , nginx include file , nginx windows include , nginx includes , nginx include conf , nginx config include ssl , nginx include config , nginx include directive , ngix include , nginx include server directive

This Article Has Been Shared 555 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Nginx Configuration With include Directive For WordPress

  • Nginx PHP5-FPM WordPress : Major Tweaks

    Here is a Short Yet More Than Enough Guide For the Most To Tweak Nginx PHP5-FPM WordPress Setup Running on Ubuntu 14.04 on Rackspace Cloud Server.

  • HHVM WordPress (Nginx Ubuntu Server) Tweaks

    Here are some special HHVM Wordpress (Nginx Ubuntu Server) Tweaks for Page Speed optimization, Compatibility of WordPress Themes and Plugins.

  • Zend Opcache Optimization for Nginx Ubuntu (HP Cloud)

    Here is Full Guide to Zend Opcache Optimization for Nginx PHP5-FPM for Ubuntu Server Running on HP Cloud. We Suggest to Use Zend Opcache over APC.

  • Nginx Cache Purge Module For fastcgi_cache WordPress

    Nginx Plus by Default Supports Cache Purging. Nginx Cache Purge Module For fastcgi_cache Exists Can Be Used For Community Edition of Nginx.

  • Nginx WWW to No WWW & HTTP to HTTPS

    Basic, Yet Many New Users Fight With Nginx WWW to No WWW & HTTP to HTTPS Rules on Cloud Server Instance Running Debian/Ubuntu GNU/Linux.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • What Online Casinos Have No Deposit Bonus in Australia March 30, 2023
  • Four Foolproof Tips To Never Run Out Of Blog Ideas For Your Website March 28, 2023
  • The Interactive Entertainment Serving as a Tech Proving Ground March 28, 2023
  • Is it Good to Run Apache Web server and MySQL Database on Separate Cloud Servers? March 27, 2023
  • Advantages of Cloud Server Over Dedicated Server for Hosting WordPress March 26, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Nginx Configuration With include Directive For WordPress," in The Customize Windows, July 28, 2015, March 31, 2023, https://thecustomizewindows.com/2015/07/nginx-configuration-with-include-directive-for-wordpress/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT