aaP_hareeshnarayan1982
look confing PHP conf
How to enable fastcgi cache for WordPress with aapanel
aaP_hareeshnarayan1982
/www/server/nginx/conf
Modify this file. Pay attention to backup first
aaPanel_Kern Worked perfectly. Thanks for your help. I think you can add this into the guide.
Hello, I have done the steps here:
- Added these 4 lines in nginx configuration
fastcgi_cache_key "$scheme$request_method$host$request_uri"; fastcgi_cache_path /dev/shm/nginx-cache/wp levels=1:2 keys_zone=WORDPRESS:100m inactive=60m max_size=1g; fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
- Changed the site configuation from
include enable-php-81.conf;
toinclude enable-php-81-wpfastcgi.conf;
- Installed Nginx Helper plugin in Wordpress
- Added
define('RT_WP_NGINX_HELPER_CACHE_PATH','/dev/shm/nginx-cache/wp');
to wp-config.php
And everything seems to work, I get cache HIT in the header response for the wordpress site main page. Except when I try to go to any other page, I get 404. I notice that the url that doesn't work follows index.php
routing page forexample: https://domain.com/index.php/contact/
to go to contact page. What am I missing here? Any ideas?
Regards,
Tony
aaP_tony
Hello, if the website is brand new, it is recommended to use the website -- add site -- Wordpress deploy to deploy
aaPanel_Kern
Unfortunately it is not. I could try to add a new site and copy the content to this new site to test, will that work?
It is recommended to try it yourself
aaPanel_Kern
I added a new site using the wordpress deploy option. Then copy the old contents over to the new site. Unfortunately, I still have the same issue, meaning it is not the configuration? May be there is some settings/plugins that affect this fastCGI setting?
aaP_tony
Is your site brand new? If it is, you can directly deploy Wordpress deploy
Otherwise, you can only add related plug-ins by yourself
aaP_tony use wp migrate plugin, if you copy the files php fastcgi config file will be replaced.
aaPanel_Kern It is not a new site, that is why I want to add it after the fact. Everything seems to be working for the main page, I get Cache HIT but for other pages I get 404.
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.
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.
aaP_tony
It is recommended to check whether you need to set url rewirte
- Edited
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.
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.
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
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.
- Edited
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.