WordPress and PHP tuning

WordPress

Setup the memory limit used by WordPress in wp-config.php. The figures should not exceed the memory_limit of php

define('WP_MEMORY_LIMIT', '128M');
define('WP_MAX_MEMORY_LIMIT', '256M');

Secure the cookie in wp-config.php:

@ini_set('session.cookie_httponly', true); 
@ini_set('session.cookie_secure', true); 
@ini_set('session.use_only_cookies', true);

PHP

Edit php.ini

upload_max_filesize = 20M
post_max_size = 20M
memory_limit = 256M
session.cookie_secure = 1
session.cookie_httponly = 1

The path of php.ini:

  • Usually: /etc/php.ini
  • LiteSpeed: /usr/local/lsws/lsphp82/etc/php.ini

Note:

  • If using php-fpm, the configurations in /etc/php-fpm.d/www.conf overwrites php.ini
  • If using LiteSpeed, need killall lsphp to make the settings effective.

Reference

2 Comments

  1. Pingback: How to install OpenLiteSpeed for WordPress – 美丽传说365

  2. Pingback: How to migrate WordPress on CentOS8 – 美丽传说365

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

Back to Top