• 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 PHP5-FPM WordPress : Major Tweaks

By Abhishek Ghosh September 1, 2014 6:21 pm Updated on September 1, 2014

Nginx PHP5-FPM WordPress : Major Tweaks

Advertisement

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. The same settings might not work if you are not using at least a 2 GB PVHVM Instance. It is a potentially bad habit to use an underpowered server with swap memory on cloud setup.

 

Nginx PHP5-FPM WordPress : Understand The Infrastructure Before Major Tweaks

 

If suddenly the visitor increase over week, your server will crash like a hell making SSH impossible. Most importantly, if this bad habit of using underpowered server combined with too much caching is continued, on dedicated server or bare metal it can catch fire. There are two commands to test – top (Q to exit) and uptime. Without second user, for Nginx, there will be two users – root and www-data. Load average is expressed in this way – 0.05, 0.07, 0.05. This are fully and kernel related. If the traffic analogy goes to 1.00, it means it is exactly at capacity and should probably either double the RAM or add more nodes. There are parameters like multicore versus multiprocessor to consider. For this reason, high end website should use the full managed service of Rackspace. Infrastructure Level Support will kill huge time just to optimize.

We are assuming that the reader is following our method – WordPress Nginx php5 fpm Installation on Rackspace Cloud followed by Optimizing Nginx and better to Setup Separate Database Server. Two server is minimum configuration separating application server and general purpose web server.

Advertisement

---

There is no meaning if you are using a 512 MB server to save money on Rackspace for production website. There are different qualities of web masters and websites. Nginx needs lesser RAM never means you’ll not use a powerful web server. Apache2 is too heavy plus with load condition of Apache2 usually goes more bad.

Nginx PHP5-FPM WordPress Major Tweaks

 

Nginx PHP5-FPM WordPress : Major Tweaks

 

This is a generalized guide assuming a 2 GB instance. You must test load and page loading time to get the best result. We are mentioning the files and name of the string indicates “need some tweak”. Always perform config test with nginx -t on production server before reloading.

/etc/nginx/nginx.conf :

We have discussed before, if something is remains :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# middle of the file
http {
 
    ##
    # Basic Settings
    ##
 
    sendfile on;
    tcp_nopush on;
    tcp_nodelay off;
    keepalive_timeout 15;
        keepalive_requests 2000;
    types_hash_max_size 2048;
    server_tokens off;
        server_name_in_redirect off;
 
    open_file_cache max=1000 inactive=300s;
    open_file_cache_valid 360s;
    open_file_cache_min_uses 2;
    open_file_cache_errors off;
 
    server_names_hash_bucket_size 64;
    # server_name_in_redirect off;
 
        client_body_buffer_size 128K;
        client_header_buffer_size 1k;
        client_max_body_size 2m;
        large_client_header_buffers 4 8k;
 
        client_body_timeout   10m;
        client_header_timeout 10m;
        send_timeout          10m;
 
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
 
    ##
    # Logging Settings
    ##
 
    error_log /var/log/nginx/error.log;
        access_log off;
    # Gzip Settings
    ##
 
    gzip on;
    gzip_disable "msie6";
 
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 9;
        gzip_min_length  1000;
        gzip_proxied     expired no-cache no-store private auth;
    gzip_buffers 32 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
 
    ## skipped stuffs
 
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
# end of the file
}

Run nginx-t and then its OK, do service nginx reload.

/etc/nginx/fastcgi_params :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
fastcgi_param   QUERY_STRING        $query_string;
fastcgi_param   REQUEST_METHOD      $request_method;
fastcgi_param   CONTENT_TYPE        $content_type;
fastcgi_param   CONTENT_LENGTH      $content_length;
 
fastcgi_param   SCRIPT_FILENAME     $request_filename;
fastcgi_param   SCRIPT_NAME     $fastcgi_script_name;
fastcgi_param   REQUEST_URI     $request_uri;
fastcgi_param   DOCUMENT_URI        $document_uri;
fastcgi_param   DOCUMENT_ROOT       $document_root;
fastcgi_param   SERVER_PROTOCOL     $server_protocol;
 
fastcgi_param   GATEWAY_INTERFACE   CGI/1.1;
fastcgi_param   SERVER_SOFTWARE     nginx/$nginx_version;
 
fastcgi_param   REMOTE_ADDR     $remote_addr;
fastcgi_param   REMOTE_PORT     $remote_port;
fastcgi_param   SERVER_ADDR     $server_addr;
fastcgi_param   SERVER_PORT     $server_port;
fastcgi_param   SERVER_NAME     $server_name;
 
fastcgi_param   HTTPS           $https;
 
fastcgi_send_timeout                    180;
fastcgi_read_timeout                    180;
fastcgi_buffer_size                     128k;
fastcgi_buffers                         256 4k;
 
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param   REDIRECT_STATUS     200;

/etc/php5/fpm/php-fpm.conf :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
open_basedir ="/var/www/"
; commented out three lines
; debug the next
; disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstarus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,dl,system,shell_exec,fsockopen,parse_ini_file,passthru,popen,proc_open,proc_close,shell_exec,show_source,symlink,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec ,highlight_file,escapeshellcmd,define_syslog_variables,posix_uname,posix_getpwuid,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,escapeshellarg,posix_uname,ftp_exec,ftp_connect,ftp_login,ftp_get,ftp_put,ftp_nb_fput,ftp_raw,ftp_rawlist,ini_alter,ini_restore,inject_code,syslog,openlog,define_syslog_variables,apache_setenv,mysql_pconnect,eval,phpAds_XmlRpc,phpA ds_remoteInfo,phpAds_xmlrpcEncode,phpAds_xmlrpcDecode,xmlrpc_entity_decode,fp,fput,virtual,show_source,pclose,readfile,wget
 
expose_php = off
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
display_errors = Off
post_max_size = 2M
allow_url_fopen = off
default_socket_timeout = 60

/etc/php5/fpm/pool.d/www.conf :

Vim
1
2
3
4
5
6
7
8
9
10
user = www-data
group = www-data
listen = /var/run/php5-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 3s;
pm.max_requests = 50

We talked about Nginx default config file a lot, this is the best practice in excerpt for using W3 Total Cache.

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
server {
# many things
# set cache = request
set $cache_uri $request_uri;
# we are serving php files with a query string live
if ($request_method = POST) {
set $cache_uri 'null cache';
}  
# conditional nullifying
if ($query_string != "") {
set $cache_uri 'null cache';
}  
# if has post cache then serve from there else get from WordPress
# kinda logic, "do not waste our visitors time"
location / {
try_files /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$args ;
}
}

Others are written here for W3 Total Cache with SSL. With this setup and a bit minifying, using Cloud files, you’ll get around 93/100 score with A A A A [variable] [variable] [variable] score on Webpage test.

Tagged With AMAY , digital innovation

This Article Has Been Shared 991 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 PHP5-FPM WordPress : Major Tweaks

  • Online Markdown Editor of Your Own : Again Full Cloud Based

    Online Markdown Editor of Your Own can be hosted on Dropbox or Rackspace Cloud Files as practically all the files – javascript, images, CSS are static files.

  • Which CDN is Best for Serving Static Contents and Streaming

    Which CDN is Best has one answer – Akamai. Akamai is the global standard and used by IBM to Microsoft. You have to find someone using their infrastructure.

  • Myths About Private Cloud

    Myths About Private Cloud decreases the chance of expandability for a company or an organization.Both public and hybrid cloud computing can be used selectively.

  • New Trends in Cloud Computing

    New trends in cloud computing means, seeking some new way and finding the answer whether to use it. Cloud computing has become a real trend from the media hype. Cloud Computing is a good option when you know about the points on security, the definite flaws, the weaker sides. There are three related article which […]

  • Cloud computing is Not Equal to the Future of Computing

    Cloud computing is Not Equal to the Future of Computing. Cloud Computing is an marketing term which is closer to the technology of grid computing since decades.

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

  • 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
  • Get Audiophile-Grade Music on Your Smartphone March 25, 2023
  • Simple Windows Security and Privacy Checklist for 2023 March 24, 2023
  • 7 Best Artificial Intelligence (AI) Software March 24, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Nginx PHP5-FPM WordPress : Major Tweaks," in The Customize Windows, September 1, 2014, March 28, 2023, https://thecustomizewindows.com/2014/09/nginx-php5-fpm-wordpress-major-tweaks/.

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