, 3 min read
Installing OpenLiteSpeed on Arch Linux
Original post is here eklausmeier.goip.de/blog/2023/08-13-installing-openlitespeed-on-arch-linux.
Unfortunately the AUR package (dead link) for installing OpenLiteSpeed is broken. Additionally, the manual installation of OpenLiteSpeed via self-compilation is a mess.
1. Downloading rpm. Here we describe using the rpm repository of /edge/centos/8/x86_64/RPMS/.
Essentially, this is a precompiled binary in rpm-form. Our version is openlitespeed-1.7.16-1.el8.x86_64.rpm.
Another good candidate is openlitespeed-1.7.17-1.el9.x86_64.rpm in /centos/9/x86_64/RPMS/.
2. Unpacking rpm. In the following ols stands for the downloaded rpm-file without the rpm-suffix.
- Convert rpm to cpio: rpm2cpio ols.rpm > ols.cpio.zstd
- Uncompress file with unzstd old.cpio.zstd
- Unpack resulting cpio-archive with cpio -idmv < ols.cpio
- Move directory ./usr/local/lswsto/usr/local/lsws, andchown -R root:rootif you haven't created the files as root user
3. Start webserver.
- Create Unix group lsadm, and user lsadmwith/bin/nologinshell
- conf-directory: chown -R lsadm:lsadm /usr/local/lsws/conf
- Check missing libraries: ldd bin/openlitespeed, I had to install missinglibcrypt.so.1library viapacman -S libxcrypt-compat
- Copy systemd-service for start- and stop, enable service:
cp -p /usr/local/lsws/admin/misc/lshttpd.service /usr/lib/systemd/system/lshttpd.service
systemctl enable lshttpd
The litespeed process changes chmod of various config files to be executable. This is just silly, but you have no chance to correct it, as with every restart of litespeed the chmod is changed again. In total OpenLiteSpeed needs 67 MB of disk space under /usr/local/lsws.
4. Admin console. The original installation contains some glitches, which need to be corrected. Though, overall the admin console is not very useful.
- Admin console needs below symbolic links: Go to /usr/local/lsws. Thenmkdir -p lsphp73/bin lsphp74/bin, change to these two directories and create symlinkln -s ../../fcgi-bin/lsphp
- Copy a pem-file to admin/conf/, symlinkwebadmin.crtandwebadmin.keyto this file, as the admin console enforces https. Alternatively you can changeadmin/conf/admin_config.confand editkeyfileandcertfile
- Login to admin console does not work out-of-the-box, therefore edit file admin/html.open/lib/CAuthorizer.phpin line 261 and changereturn $auth;toreturn true;in PHP functionauthUser()to fix the authorization issue
- Admin console logs you out all the time: in PHP function __construct()inlib/CAuthorizer.phpcomment out the entireifclause forif (isset($_SESSION['timeout']) ...
- Admin console floods the log-file with various INFO and NOTICE messages
- Start web-server with /usr/local/lsws/bin/lswsctrl start, webserver listens on port 8088, admin console listens on port 7080
As the admin console is basically useless, I recommend to simply disable it with disableWebadmin  1 in conf/httpd_config.conf. Put it right after the servername line.
Restarting the webserver:
- stop webserver with lswsctrl stop
- remove cache with rm -rf cachedataand any sockets withrm admin/tmp/admin.*
- possibly remove old log file: rm logs/*.log
- start with lswsctrl start.
5. PHP via FastCGI. OpenLiteSpeed comes with PHP 5.6 installed as special LS-API compiled binary. This version is way too old. Below steps configure PHP as FastCGI.
- Edit conf/httpd_config.confand changeuserandgrouptohttpfromnobody. The Linux userhttpis also employed byphp-fpm. Change directory ownershipchown -R lsadm:http conf, and chown -R http:http tmp`.
- Enable PHP-FPM (PHP FastCGI Process Manager): systemctl enable php-fpm
- Start PHP-FPM: systemctl start php-fpm
- Configure extprocessorfor OpenLiteSpeed inconf/httpd_config.conf:
user                      http
group                     http
extprocessor fcgiphp {
   type                    fcgi
   address                 uds://run/php-fpm/php-fpm.sock
   note                    PHP FPM
   maxConns                10
   initTimeout             20
   retryTimeout            10
   respBuffer              0
   autoStart               0
}
Domain socket in extprocessor must match the value in /etc/php/php-fpm.d/www.conf. OpenLiteSpeed should not start php-fpm, therefore autostart 0. The virtual host configuration is as below. The important part is the "context" which relates to fcgi.
# Virtual host config for klmblog
# 13-Aug-2023
docRoot                   /srv/http/
enableGzip                1
enableBr                  1
errorlog $VH_ROOT/logs/error.log {
  useServer               1
  logLevel                DEBUG
  rollingSize             10M
}
accesslog $VH_ROOT/logs/access.log {
  useServer               0
  rollingSize             10M
  keepDays                30
  compressArchive         0
}
context /p/ {
  type                    fcgi
  handler                 fcgiphp
  addDefaultCharset       off
}
context / {
  location                /srv/http/
  allowBrowse             1
  rewrite  {
  }
  addDefaultCharset       off
  phpIniOverride  {
  }
}
6. Tips and tricks.
- The process-id's of the webserver are pidof litespeed
- Before accessing the webserver with any queries, check logs/error.logfor any entries with[ERROR]