If you want to optimize the speed of your website, switching to FastCGI (nginx+php-fpm) can be an effective solution. This method can significantly speed up websites with various CMSs, such as Opencart, WordPress. However, in addition to the advantages, there are some nuances that are important to know about.
One such aspect is the loss of functionality of the .htaccess file because we are removing Apache from the relationship. If you have rules in your .htaccess file, you will need to convert them using a specialized service.
For example, winginx.com/ru/htaccess and add them to the configuration file.
Step 1: Configuring the ISPmanager 6 panel
Go to the www-domains section and select the site, change the operation mode to FastCGI (Nginx + PHP-FPM) and install the same PHP version that is used on your site. Once installed, click “OK”.
Migrating the site to FastCGI (nginx + php-fpm)
Step 2: Troubleshooting 404 errors
After switching to FastCGI, you will encounter a 404 error for all pages except the main one. To solve this problem, you need to write additional redirects.
In the www-domains section, select the domain and click the “Config” button.
Depending on the CMS you are using, apply the appropriate redirect settings.
Opencart add after location / {
if (!-e $request_filename) {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
WordPress add after location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
It is important that if your site uses an SSL certificate, you must specify separate redirect settings for both HTTP and HTTPS blocks.