• 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
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

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud

    Here is a Step by Step Guide on Setting Up WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud with All Commands and the Configuration.

  • XCache Admin Page on Nginx-PHP5-FPM (Ubuntu, HP Cloud)

    Here is How to Setup a XCache Admin Page on Nginx-PHP5-FPM on Ubuntu Instance Running on HP Cloud. It Gives a Clear Graphical Idea of Caching.

  • Nginx WordPress Configuration Sample File

    Here is Ready to Use Nginx Wordpress Configuration Sample File Which Can Used With Either Community Edition of Nginx or Nginx Plus & PHP5-FPM.

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

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
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