So we’ve already installed Litespeed, PHP5, and eAccelerator. The final step is to optimize our Litespeed and PS settings.
First, make sure that ALL of your domains on the Dreamhost PS are proxied through Litespeed. This allows Dreamhost’s Apache to only use 6MB of RAM per thread, instead of the usual 8MB. This is a huge memory savings. Each domain must be forwarded to a different internal port within Dreamhost’s proxy interface. A new listener with the corresponding port and a new virtual host must be defined within Litespeed’s configuration for each domain.
Next, in Dreamhost’s “Manage Domains,” “Extra Web Security” should be turned off since Apache is no longer used. When it is on, mod_security is loaded, which wastes RAM. Security and request filters can be tuned in the Litespeed web console. This can possibly reduce server load from spam bots. In Server/Request Filter, turn on “Enable Request Filtering” and “Scan Request Body.” Disable the “XSS attack” rule set because it breaks certain applications such as Wordpress.
In Litespeed’s Server/Tuning/GZIP Compression, turn on compression, but leave dynamic compression off. There is insufficient CPU on a downscaled Dreamhost PS to perform dynamic compression for each request, and if it is on, the web server will suffer. If you have a larger Dreamhost PS, you can turn it on, but should leave the compression level at 1 for best performance.
In Litespeed’s Server/Tuning, reduce the Connection Timeout, Keep-Alive Timeout, Max Request URL Length, and Max Request Header Size, using the values in the tooltips as a guide. Again, this may reduce load from spam bots and DOS attacks.
In Litespeed’s Server/General/General settings, turn on “Use Client IP in Header” becaue we are behind a proxy server. This will allow Litespeed to read the HTTP 1.1 X-Forwarded-For header, which contains the actual IP address of the web connection.
In Litespeed’s Server/External App/phpLsapi, set Max Connections to 3, Persistent Connection to Yes, Instances to 1, Max Idle Time to 60, Connection Keepalive Timeout to 60, and use these lines in Environment:
PHP_LSAPI_MAX_REQUESTS=10000
PHP_LSAPI_CHILDREN=3
LSAPI_AVOID_FORK=1
If the server has more than 512MB of RAM, set Max Connections to 5 and PHP_LSAPI_CHILDREN=5. If it has more than 1024MB of RAM, use 10, and so on. This will help the concurrency of busy servers.
In Dreamhost’s Stats/Site Statistics, uncheck the “Run Analog Reports” box for all of your domains. The calculation of the stats uses up a lot of server resources each day, and although you will no longer see useful information about individual requests and bots, a non-server-log-parsing tracker such as Mint or Statcounter is preferable.
Tune Dreamhost PS’s CPU/Memory settings, maintaining at least 200MB free swap memory AND keeping the 15-minute load average below 1. After a short burst of CPU Usage or Memory past your limits, the speed of the CPU or memory will be throttled greatly. If PHP decides to use those slow resources, it can cause a chain reaction that starts too many Apache threads, possibly bringing the server down.
Mem: 307200k total, 253608k used, 53592k free
Swap: 307200k total, 0k used, 307200k free
That’s all! Your Dreamhost PS should now be running in top shape.