Einfache Anleitungen über Linux und etwas Python-Programmierung.
How to run cachify on docker with nginx and php
Case:
If you are using memcached in a docker container you will see, that the memcached cache still not grow, on you wordpress dashboard side. You changed your nginx config and you can see your site, but the cache is still empty.
Simple Solution:
1.) Go into the wordpress path where the plugin is installed for example: ovks_de/wp-content/plugins/cachify/inc/
If you are using docker-compose, you can do it the easy way. The network section can be deleted, if you are not using your own network section. If you use your own, memcached has to be a part of the network of nginx and php, too.
You CAN NOT use the example of the config page of the plugin. WordPress –> Plugin –> Cachify –> Preferences –> Second Tab You have to change the „localhost“ from „memcached_pass“ to the name of the docker container: from: memcached_pass localhost:11211; to: memcached_pass memcached:11211;
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
error_page 404 405 = @nocache;
if ( $query_string ) {
return 405;
}
if ( $request_method = POST ) {
return 405;
}
if ( $request_uri ~ "/wp-" ) {
#rewrite try_files $uri $uri/ /index.php?$args;
return 405;
}
if ( $http_cookie ~ (wp-postpass|wordpress_logged|comment_author)_ ) {
return 405;
}
default_type text/html;
add_header X-Powered-By Cachify;
set $memcached_key $http_host$request_uri;
memcached_pass memcached:11211;
}
## NOCACHE LOCATION
location @nocache {
try_files $uri $uri/ /index.php?$args;
}
3.) Does php and memcached work correctly?
1.) Lets test it! Just create a PHP file in your WordPress-Directory and name it.
In the array, you have to change the „127.0.0.1“ to „memcached“.
Hurray! You did it! Now, go to your Website and surf a little bit on it and you can see in the wordpress backed that the cache amount still grow. You can find that on the dashboard site „At A Glance“.