0

I have a LAMP stack with PHP FPM and multiple virtual hosts with Wordpress sites on.

I have tried to install memcashed using this tutorial.

In Wordpress sitehealth I get: "You should use a persistent object cache".

In /etc/memcached.conf I have:

-l my IP address
-l ::1

I have set this ufv rule:

sudo ufw allow from client_system_private_IP/32 to any port 11211

In /var/log/apache2/error.log I get:

Got error 'PHP message: PHP Fatal error:  Cannot redeclare wp_cache_add() (previously declared in...

EDIT:

I just found this.

It appears that:

The function is defined in two separate files or

The function is defined in two places in the same file

And can be fixed by using include_once instead of include when including my PHP file.

Now I just need to figure how to do so?

How to enable memcached on Wordpress?

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
newcat1000
  • 101
  • 2

1 Answers1

0

The error you are seeing is not related to your memcached installation at all.

There is something wrong with your WordPress installation. Maybe you have installed/activated two separate cache plugins, and therefore the function is defined twice.

Without further information of your WordPress installation, I cannot give any more detailed answer.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • Hi Tero, thanks for your answer. I have WP-Optimize installed. I just deactivated it without luck. I just deactivated all plugins without luck. I have 9 virtual hosts on 1 droplet. What information do you need? Thanks! – newcat1000 Dec 03 '22 at 19:19
  • The error log message tells where the function is declared and re-declared. You need to check the files and to which entity they belong. – Tero Kilkanen Dec 03 '22 at 19:30
  • The error described earlier is outdated, it came from a plugin I already have deleted. Sorry. I get this error in /var/log/apache2/error.log: AH01630: client denied by server configuration: /var/www/html/example.net/public_html/wp-content/uploads/code-execution.php, referer: https://www.example.net/wp-content/uploads/code-execution.php – newcat1000 Dec 03 '22 at 19:52
  • You should not have PHP files in your `uploads` directory. Now you need to find out why there is such a file in your `uploads` directory. Also, that isn't likely related to memcache in any way. – Tero Kilkanen Dec 03 '22 at 19:58
  • Thanks! Here is another error: AH01071: Got error 'PHP message: [ERROR] : WP_CACHE constant is not present in wp-config.phpPHP message: [ERROR] : WP_CACHE constant is not present in wp-config.phpPHP message: [ERROR] : WP_CACHE constant is not present in wp-config.php', referer: https://www.example.net/wp-admin/plugins.php – newcat1000 Dec 03 '22 at 20:02
  • Last error: AH01276: Cannot serve directory /var/www/html/example.net/public_html/indexing-test/: No matching DirectoryIndex (index.php,index.html,index.cgi,index.pl,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive, referer: https://www.example.net/indexing-test/ – newcat1000 Dec 03 '22 at 20:04
  • There is this: – newcat1000 Dec 03 '22 at 20:07
  • Its from Really Simple SSL WP plugin – newcat1000 Dec 03 '22 at 20:09
  • I just deleted the file in example.net/wp-content/uploads/code-execution.php and still get the 'You should use a persistent object cache' on WP site health. – newcat1000 Dec 03 '22 at 20:14
  • Did you add the caching directives for WordPress? – Tero Kilkanen Dec 03 '22 at 22:11
  • I have tried different plugins like Object Cache, the site crashes when I enable them. I have tried to clean up wp-config.php and .htaccess without luck. – newcat1000 Dec 03 '22 at 23:52
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/141055/discussion-between-newcat1000-and-tero-kilkanen). – newcat1000 Dec 04 '22 at 00:06