How to Change the swap directory for OpenLitespeed and DirectAdmin

1. Create swap folder

By default OpenLiteSpeed use /tmp/lshttpd/swap for temp files. If your /tmp partition is small, disk may get full.

To move OpenLiteSpeed swap partition to / partition do the following.

mkdir -p /lswstmp/lshttpd/swap
chmod 750 /lswstmp/lshttpd
chmod 700 /lswstmp/lshttpd/swap
chown -R apache:apache /lswstmp/lshttpd

2. Copy configuration file

In order to change these options will need to edit the httpd-defaults.conf file located in the /usr/local/lsws/conf/ directory. However, if we edited this file directly it would be overwritten by custombuild when either the ./build openlitespeed or ./build rewrite_confs commands are issued.

To make use of the feature integrated into custombuild, which allows us to employ a custom configuration file, you can create a dedicated OpenLiteSpeed configuration directory and include the httpd-defaults.conf template file. To initiate this process, you should start by executing the following commands:

cd /usr/local/directadmin/custombuild/
mkdir -p custom/openlitespeed/conf 

Next, we’ll generate the customized httpd-defaults.conf file by duplicating the existing httpd-defaults.conf template and placing it in the /custom/openlitespeed/conf/ directory. Execute the following command to achieve this:

cp -p configure/openlitespeed/conf/httpd-defaults.conf custom/openlitespeed/conf/ 

3. Edit the configuration file

We can now modify httpd-defaults.conf file to set our custom folder path. Open the file using following command

nano /usr/local/directadmin/custombuild/custom/openlitespeed/conf/httpd-defaults.conf

edit the value of swappingDir to the folder created in step 1. After change the line should look as follows

swappingDir                      /lswstmp/lshttpd/swap

save and exit nano by pressing ctrl+x or command+x

4. Rebuild Configuration

Once you’ve saved the custom httpd-defaults.conf file, you’ll need to instruct DirectAdmin to regenerate the OpenLiteSpeed configuration files and implement the customized compression types. You can achieve this by running the following command:

cd /usr/local/directadmin/custombuild/
./build rewrite_confs

That’s it. You have successfully changed a custom httpd-defaults.conf file and set your own path to swap files in OpenLitespeed. You now have an understanding of how to change the swap directory in OpenLitespeed and how to adjust them using DirectAdmin.

Leave a Comment