Want to subscribe to topics you're interested in?
Become a Member

Wordpress How to Enable FCGI Cache on WordPress ?

Discussion in 'Blogs & CMS usage' started by Yohan, Oct 2, 2015.

Tags:
  1. eva2000

    eva2000 Administrator Staff Member

    59,291
    12,509
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,142
    Local Time:
    6:18 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    you need to create it yourself - from guide


     
  2. negative

    negative Active Member

    415
    50
    28
    Apr 11, 2015
    Ratings:
    +98
    Local Time:
    11:18 PM
    1.9.10
    10.1.11
    @eva2000

    I applied all instructions (fastcgi cache configuration) correctly on my wordpress hosted nginx configuration and i'm sure that. nginx restarting without error and website works but post pages gives 404 error. Homepage works

    Wordpress is in root location /

    What may effect that error ?
     
  3. eva2000

    eva2000 Administrator Staff Member

    59,291
    12,509
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,142
    Local Time:
    6:18 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    if following the guide at Nginx Wordpress Configuration - CentminMod.com LEMP Nginx web stack for CentOS make sure you're using right php include file and that it's only one in use for each web app/script.
    phpwpcache.conf enabled with php.conf disabled/commented out
    Code (Text):
    include /usr/local/nginx/conf/phpwpcache.conf;
    #include /usr/local/nginx/conf/php.conf;
    

    So if you have multiple scripts installed - you may have wordpress directory/script locations use phpwpcache.conf include file. If you have non-wordpress script, you'd use php.conf include. And ensure you don't have
    location ~ \.php$ { context in same nginx vhost if they are used by other web app/scripts as you'll have php requests matched to unintended web apps within same nginx vhost.

    If unsure, create a test dummy single wordpress site with no other script and test fastcgi_cache wordpress config first to ensure that config is working before trying to mix with other scripts on same site domain name.
     
  4. negative

    negative Active Member

    415
    50
    28
    Apr 11, 2015
    Ratings:
    +98
    Local Time:
    11:18 PM
    1.9.10
    10.1.11
    I did as your CODE block my domain.conf file and website at root domain and only works wordpress.

    When i put the include phpwpcache.php and wpsecure files, post pages returns 404. I'm sure that i made all instructions same and carefully what you write and i did over again it 2-3 times.
     
  5. eva2000

    eva2000 Administrator Staff Member

    59,291
    12,509
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,142
    Local Time:
    6:18 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    check your nginx access/error logs and php-fpm error logs for clues
     
  6. negative

    negative Active Member

    415
    50
    28
    Apr 11, 2015
    Ratings:
    +98
    Local Time:
    11:18 PM
    1.9.10
    10.1.11
    error log looks like that;
    Code (Text):
    "/home/nginx/domains/domain.com/public/wordpress-post.html/index.php" is not found (2: No such file or directory), client: xx.xx.xx.xx, server: domain.com, request: "GET /wordpress-post.html/?gclid=EAIaIQobChMI4ZmLlPbn6QIVCOJ3Ch2Smw1yEAAYBCACEgLzdvD_BwE HTTP/1.1", host: "domain.com", referrer: "https://www.google.com.tr/"


    I think problem is that my wordpress urls because normally it is like that wordpress-post.html but nginx tries to get it as "wordpress-post.html/index.php" after i modified the fastcgi cache ? (so it gives 404) It looks like rewrite problem
     
  7. eva2000

    eva2000 Administrator Staff Member

    59,291
    12,509
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,142
    Local Time:
    6:18 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    Are you using Wordpress permalinks or Nginx rewrite rules which have urls/links with .html extensions ?

    Centmin Mod default static files include file at /usr/local/nginx/conf/staticfiles.conf handles .html files via Nginx. But by using wordpress with .html extensions you tell Nginx not to serve .html files and serve via PHP-FPM (not ideal as it reduces performance if you use permalinks with .html extensions and thus use PHP-FPM to server .html files)

    If you must use .html extension permalinks, you need to comment out the .html location context from /usr/local/nginx/conf/staticfiles.conf and restart Nginx server as illustrated below with hash # in front
    Code:
        location ~* \.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
            gzip_static off;
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
        location ~* \.(js)$ {
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
        location ~* \.(css)$ {
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
        #location ~* \.(html|htm|txt)$ {
            #add_header Pragma public;
            #add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            #access_log off;
            #expires 1d;
           # break;
           # }
    
        location ~* \.(eot|svg|ttf|woff)$ {
            #add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            expires 30d;
            break;
            }
    
    You can also use SSH command shortcut below to launch nano linux text editor and edit file /usr/local/nginx/conf/staticfiles.conf
    Code:
    statfilesinc
     
  8. negative

    negative Active Member

    415
    50
    28
    Apr 11, 2015
    Ratings:
    +98
    Local Time:
    11:18 PM
    1.9.10
    10.1.11
    I tried my another wordpress website which ending the permalinks with /
    So, with my same configuration, domain.com/wordpress-post/ doesn't work too (gives 404 error)

    Btw, I know the static files edits about ending .html url's already.
     
  9. eva2000

    eva2000 Administrator Staff Member

    59,291
    12,509
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,142
    Local Time:
    6:18 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    When you create a new nginx vhost domain via centmin.sh menu option 2 or menu option 22 or via /usr/bin/nv cli command line, you will create the Nginx vhost files and directories. You will get an outputted the path location where it will create the domain name's vhost conf file named newdomain.com.conf (and newdomain.com.ssl.conf if you selected yes to self signed SSL)
    • Nginx vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.conf
    • Nginx HTTP/2 SSL vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf
    • Nginx Self-Signed SSL Certificate Directory at /usr/local/nginx/conf/ssl/newdomain.com
    • Vhost public web root will be at /home/nginx/domains/newdomain.com/public
    • Vhost log directory will be at /home/nginx/domains/newdomain.com/log
    Please post the contents of /usr/local/nginx/conf/conf.d/newdomain.com.conf and if applicable /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf wrapped in CODE tags (outlined at How to use forum BBCODE code tags)
     
  10. negative

    negative Active Member

    415
    50
    28
    Apr 11, 2015
    Ratings:
    +98
    Local Time:
    11:18 PM
    1.9.10
    10.1.11
    @eva2000 What you think about nginx adding the index.php end of the URL's? Because when i look the error logs, post page trying to calling the domain.com/wordpress-post/index.php instead of right url domain.com/wordpress-post/

    After remove the fastcgi configurations, post pages works well.
     
  11. eva2000

    eva2000 Administrator Staff Member

    59,291
    12,509
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,142
    Local Time:
    6:18 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+