Config nginx file for fastcgi cache & Woocommerce;


#1

Hi guys,

It’s my second time experiencing your tutorial in order to build the wordpress site. Rtcamp is awesome and your guide is very detailed & useful. Follow your last guide, this second time I use easy engine to fasten the process. I run these 3 simple commands:
curl -sL rt.cx/ee | sudo bash
ee system install
ee site create example.com –wpfc
Everything works great till today when I met the issue with woocommerce “add to cart” like the first time. I follow your guide again here
But discover that the config file (/etc/nginx/sites-available/site-example.com) looks different than before:

WPSINGLE FAST CGI NGINX CONFIGURATION

server {
server_name escodrugs.com www.escodrugs.com;
access_log /var/log/nginx/escodrugs.com.access.log rt_cache;
error_log /var/log/nginx/escodrugs.com.error.log;
root /var/www/escodrugs.com/htdocs;
index index.php index.htm index.html;
include common/wpfc.conf;
include common/wpcommon.conf;
include common/locations.conf;
}
It looks very simple like the one of the first website I built before. I tried the Nginx Config here . But always get error.
Can you guys please send me a correct config? I have very little knowledge of Nginx or server, so really need your help.

Many thanks


Issue with woocommerce + cache
#2

@minhhuy2212
modify your sites nginx config like this

ee site edit example.com

  
# WPSINGLE FAST CGI NGINX CONFIGURATION  
server {  
server_name escodrugs.com www.escodrugs.com;  
access_log /var/log/nginx/escodrugs.com.access.log rt_cache;  
error_log /var/log/nginx/escodrugs.com.error.log;  
root /var/www/escodrugs.com/htdocs;  
index index.php index.htm index.html;  

include common/wpfc.conf;  

if ( $cookie_woocommerce_items_in_cart = "1" ){  
	set $skip_cache 1;  
}  
if ($args != "") {  
      set $skip_cache 1;  
}  
if ($request_uri ~* "(/translate.*|/store.*|/cart.*|/my-account.*|/checkout.*|/addons.*)") {  
		set $skip_cache 1;  
}  

include common/wpcommon.conf;  
include common/locations.conf;  
}  

#3

Hi Harshad,

I changed the file like you told. But the cart still keep empty if I add product (ajax add to cart) and go check in the cart page.

I tried deactive nginx helper and W3 total cache in turn, and discover that if I don’t use W3 total cache, the problem is solved. Follow your guide, I only use database and object cache (memcache). So, Is it good if i turn the W3 Total cache off?


#4

@minhhuy2212
I have modified above nginx config slightly, make changes in your nginx config accordingle and do following settings in W3 Total cache plugin. screenshots attached for ref.

Attachment Link(s):

http://rtcamp.com/wp-content/uploads/rtMedia/topics/68391/2014/07/Selection_002.png

http://rtcamp.com/wp-content/uploads/rtMedia/topics/68391/2014/07/Selection_004.png


#5

Hi Harshad,
Thank you! The cart works correctly now.

But I just found out another issue. When I visit my website via http://escodrugs.com, the site works well, but via: www.escodrugs.com the browser return the “Welcome Nginx” page.

What should I do?


#6

I think the first lines code you sent me should be:

# WPSINGLE FAST CGI NGINX CONFIGURATION  
server {  
server_name escodrugs.com www.escodrugs.com;  
...  

And below is my site’s gtmetrix report. The result is great. But do you have any more suggestion for me to improve it?
My site gtmetrix report
Many thanks,


#7

Gtmetrix

Attachment Link(s):

http://rtcamp.com/wp-content/uploads/rtMedia/topics/68477/2014/07/gtmetrix-report.jpg


#8

@minhhuy2212,
Glad to know your cart issue solved, and about “Welcome to Nginx” page issue, i think you have resolved that too, great :).
Performance will improve if you use CDN and Minify.
Let me Know if you have any other issue.


#9