Redis (PRO PACK)
This is a ** PRO-PACK FEATURE **
Redis functions as a simple database/cache for Users. This can be useful for offloading some of the stress from your database into memory, if you have the memory available to support it.
To install redis:
cd /usr/local/directadmin/custombuild
./build set redis yes
./build redis
Enabling for users
All Reseller/User packages and reseller.conf/user.conf files will have redis=OFF
by default.
The Admin account reseller.conf will have redis=ON
by default.
All accounts that need redis must have it enabled like so:
- Enable redis in the packages and re-save as needed
- Enable redis in the accounts and save as needed.
CMD_REDIS JSON
Checking the status for a user
To check the current status for the current User, use a GET request with no options. The return should look similar to this:
{
"enabled": "0",
"global": "1"
}
- "enabled" refers to
redis=ON
in the user.conf - "global" is the service check to ensure it's installed on the system
Enabling Redis for a user
Submit a POST request with the following:
action=enable
Disabling Redis for a user
Submit a POST request with the following:
action=disable
API usage
CMD_API_REDIS
does exist and will always be use JSON mode for output.
Relative Skin changes
The following files were modified:
/usr/local/directadmin/data/skins/enhanced/admin/create_customized_reseller.html
/usr/local/directadmin/data/skins/enhanced/admin/modify_reseller.html
/usr/local/directadmin/data/skins/enhanced/admin/show_reseller_package.html
/usr/local/directadmin/data/skins/enhanced/lang/en/lf_standard.html
/usr/local/directadmin/data/skins/enhanced/reseller/create_customized_user.html
/usr/local/directadmin/data/skins/enhanced/reseller/modify_user.html
/usr/local/directadmin/data/skins/enhanced/reseller/show_user_package.html
to support the relative global tokens including:
RESELLERREDIS=ON
USERREDIS=ON
HAVE_REDIS=ON
(which is enabled in license and installed on system)
POST values for packages/reseller/user include redis=ON
or redis=OFF
, and omission altogether implies OFF
.
How to Use Redis With WordPress
- Install Redis and php_redis extension:
cd /usr/local/directadmin/custombuild
./build set redis yes
./build redis
./build php_redis
- Enable redis for your user by going to user level -> Advanced Features -> Redis. Take note of the Path to redis socket file value. This will be used in step 3. Note that you may need to first enable Redis in this user's user options before the "Redis" feature will appear. Additionally, the reseller that owns this user needs to have it enabled in reseller options.
Refer to this source for more information about redis connection configuration.
- Install the "Redis Object Cache" plugin.
- Login to WordPress as admin.
- At the left sidebar of the dashboard, click Plugins, and then click Add New
- Enter "Redis Object Cache" into the search bar, install and activate this plugin.
- WordPress should automatically redirect you to Redis settings page. Once there, click "Enable Object Cache". With current settings, the connection status should be "Not connected".
- If you don't yet have wordpress installed, make use of the WordPress Manager feature. Adjust connection parameters to use a unixsocket connection. This can be done by adding the following content:
define( 'WP_REDIS_SCHEME', 'unix' );
define( 'WP_REDIS_PATH', '/home/<user>/.redis/redis.sock' );
to /home/<user>/domains/<domain>/public_html/wp-config.php
BEFORE the last line which includes wp-settings.php.
**Make sure to replace <user>
** with the DirectAdmin user you're trying to configure. Note that the path defined by WP_REDIS_PATH should be the path mentioned in step 2.
After refreshing the wordpress admin page, you'll notice that the connection status changed to "Connected".