Something went wrong while trying to load the full version of this site. Try hard-refreshing this page to fix the error.

How to enable fastcgi cache for WordPress with aapanel

aaP_tony

aaP_hareeshnarayan1982 That is what I'm trying to figure out, which WP config/file needs to be changed without reinstalling the site. If nothing works I'll have to try what you suggested.


aaP_hareeshnarayan1982

aaP_tony

Use all in one wp migration 6.7 version which you can find in the internet. it allows you to export the wp installation to a single file. Deploy the wordpress as like kern said. check the fast cgi config and make it working. then import the backup file and check if its working.


aaPanel_Kern

aaP_tony
It is recommended to check whether you need to set url rewirte


aaP_hareeshnarayan1982

aaPanel_Kern When we use wp migration nothing has to be done, i had migrated 4 wp sites from ols to NGINX + Fastcgi without any rewrite.


aaP_tony

aaPanel_Kern
I thought it was something to do with rewrite also, but when I changed back to using enable-php-81.conf instead of enable-php-81-wpfastcgi.conf everything works fine (minus the caching), no 404 error. And since rewrite is configured on nginx level, I don't think there are any rewrites in those php conf files.

I will try to create a new site and test whether fastcgi works on that first, then migrate the old site to see if that helps.


aaPanel_Kern

aaP_tony
enable-php-81-wpfastcgi.conf This is the configuration file dedicated to deploy wordpress. You are advised to check whether there is an Nginx Helper


aaP_tony

aaPanel_Kern
Ok so I think I found the problem, it is to do with url rewrite, but within wordpress itself. It is a problem on my WP permalink settings, if I change it so I don't have index.php in the middle of the url then everything works (after adding URL rewrite rule in aapanal for that site). Thanks for your help.


aaP_tony

aaPanel_Kern
I have a question regarding the enable-php-81-wpfastcgi.conf file, when comparing it to enable-php-81.conf it is missing this line:

include pathinfo.conf;

Is this on purpose? If I add this back to the enable-php-81-wpfastcgi.conf file my site works, no more 404. But there is another problem, all pages are nginx-cache: BYPASS. But that is also because of this clause in enable-php-81-wpfastcgi.conf

if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
    set $skip_cache 1;
}

If I remove index.php from this line, everything is working as intended, nginx-cache: HIT. Why is index.php skipped in the first place?

I know this is specific for my wordpress permalink setup, but I think I didn't change it from the default wordpress setting so this might effect other people too.


aaPanel_Kern

aaP_tony
This is done on purpose. Not sure what your website configuration is causing 404

The index.php rule is a special case in some WordPress websites, because in the URL structure of WordPress, the URLs of many pages end with index.php, such as http://example.com/page1/index.php, http://example.com/page1/index.phpetc. The content of these pages may be dynamically generated, including dynamic data such as user login status and comments, so they cannot be cached.
In addition, index.php may also be an entry file in some plug-ins or themes, and the contents of these files may also be dynamically generated, so they cannot be cached.
Therefore, in order to avoid caching these dynamically generated pages or files, you need to add index.php to the rules for skipping caching.


aaP_tony

aaPanel_Kern
Thank you for the clear explanation about the index.php. I understand it is hard to cater to all wordpress configurations, so I will only share my findings incase someone else have the same configuration as me. The configuration in question here is Settings -> Permalinks, if you this custom structure /index.php/%year%/%monthnum%/%day%/%postname%/ (I presume any permalinks with index.php in the middle will have this issue), you'll need to change the nginx configuration after deploying from aapanel.

The issue I had was getting 404 when trying to load any page other than the homepage, this is fixed by adding include pathinfo.conf; to enable-php-81-wpfastcgi.conf. Then you'll have another issue because of the index.php in the url, your pages won't get cached so you'll have to remove index.php from this line also:

if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
    set $skip_cache 1;
}

But as Kern stated above, this won't work if your wordpress permalinks setting is different than mine.



horasjey

aaPanel_Jose fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_path /dev/shm/fastcgi-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

how to solved this isue


aaPanel_Kern

Hello, the latest installation of nginx has added relevant configuration in the configuration file, if you need to use it, please use
include enable-php-74.conf;
Replaced with:
include enable-php-74-wpfastcgi.conf;

horasjey

zimbabwee


horasjey

zimbabwee yes same problem white me :-(


zimbabwee

horasjey wait jose or aapanelkern.. i use professional edition pls reply mod ๐Ÿ˜„


zimbabwee

aaPanel_Kern my site white screen after try ths,need follow step in original post ?


zimbabwee

aaPanel_Kern works now, how to purge ? try nginx helper failed purge


zimbabwee

aaPanel_Kern Help me, I just replaced the enable-php-73.conf; with include enable-php-73.conf; Cache seems to work well, but I can't do Purge Cache through Nginx Helper. I tried to delete the cache
/dev/shm/nginx-cache/wp but the same WordPress I still display the cache version, it's been 12 hours since I made changes to the theme but never appeared ๐Ÿ™


horasjey

aaPanel_Kern Replaced with:
include enable-php-74-wpfastcgi.conf;

if my website is not wordpress , is it the same as the code line ..?


aaPanel_Kern

zimbabwee
Hello, enter the relevant website plug-ins to clean up



ยซ Previous Page Next Page ยป