Tag: OpenLiteSpeed

  • systemd service file for openlitespeed

    systemd service file for openlitespeed

    To start/stop OpenLiteSpeed web server, you can use the following systemd service file

    vi /usr/lib/systemd/system/lshttpd.service
    

    Add following content

    [Unit]
    Description=OpenLiteSpeed HTTP Server
    After=network-online.target remote-fs.target nss-lookup.target
    Wants=network-online.target
    
    [Service]
    Type=forking
    PIDFile=/var/run/openlitespeed.pid
    ExecStart=/usr/local/lsws/bin/lswsctrl start
    ExecReload=/usr/local/lsws/bin/lswsctrl restart 
    ExecStop=/usr/local/lsws/bin/lswsctrl delay-stop
    
    KillMode=none
    PrivateTmp=false
    Restart=on-failure
    RestartSec=5
    
    # do not want to be limited in anyway
    CPUAccounting=false
    TasksAccounting=false
    MemoryAccounting=false
    
    [Install]
    WantedBy=multi-user.target
    Alias=lsws.service
    Alias=openlitespeed.service
    

    To start openlitespeed on boot,

    systemctl enable lsws
    

    To start OpenLiteSpeed

    systemctl start lsws
    

    To stop OpenLiteSpeed

    systemctl stop lsws
    

    See OpenLiteSpeed

  • How to Change PHP version in OpenLiteSpeed

    I installed OpenLiteSpeed on a server. The default PHP version was 7.3. I wanted PHP 7.4 on this server.

    To install PHP 7.4, run

    apt install -y lsphp74 lsphp74-apcu lsphp74-common lsphp74-curl lsphp74-dbg lsphp74-dev lsphp74-igbinary lsphp74-imagick lsphp74-imap lsphp74-intl lsphp74-ioncube lsphp74-json lsphp74-ldap lsphp74-memcached lsphp74-modules-source lsphp74-msgpack lsphp74-mysql lsphp74-opcache lsphp74-pear lsphp74-pgsql lsphp74-pspell lsphp74-redis lsphp74-snmp lsphp74-sqlite3 lsphp74-sybase lsphp74-tidy
    

    To change PHP version, i edited file

    vi /usr/local/lsws/conf/httpd_config.conf
    

    Find

    extProcessor lsphp{
        type                            lsapi
        address                         uds://tmp/lshttpd/lsphp.sock
        maxConns                        10
        env                             PHP_LSAPI_CHILDREN=10
        env                             LSAPI_AVOID_FORK=200M
        initTimeout                     60
        retryTimeout                    0
        persistConn                     1
        pcKeepAliveTimeout
        respBuffer                      0
        autoStart                       1
        path                            lsphp73/bin/lsphp
        backlog                         100
        instances                       1
        priority                        0
        memSoftLimit                    2047M
        memHardLimit                    2047M
        procSoftLimit                   1400
        procHardLimit                   1500
    }
    

    In that, find

        path                            lsphp73/bin/lsphp
    

    Replace with

        path                            lsphp74/bin/lsphp
    

    Now restart PHP and openlitespeed

    killall -9 lsphp
    systemctl restart lsws
    

    Now the site will use the new PHP version.

    You can install multiple PHP versions, to find other PHP versions available, run the command.

    apt-cache search lsphp
    

    As of 2023-01, openlitespeed image provided by AWS have PHP versions 7.4, 8.0, 8.1 and 8.2

    root@ip-172-31-22-59:~# apt-cache search lsphp | grep common
    lsphp74-common - Common files for packages built from the PHP source
    lsphp80-common - Common files for packages built from the PHP source
    lsphp81-common - Common files for packages built from the PHP source
    lsphp82-common - Common files for packages built from the PHP source
    root@ip-172-31-22-59:~# 
    

    If you need to install any other available PHP version, use the same apt install command as above, and replace lsphp74 with another version you need. For example, to install PHP 8.2

    apt install -y lsphp82 lsphp82-apcu lsphp82-common lsphp82-curl lsphp82-dbg lsphp82-dev lsphp82-igbinary lsphp82-imagick lsphp82-imap lsphp82-intl lsphp82-ioncube lsphp82-json lsphp82-ldap lsphp82-memcached lsphp82-modules-source lsphp82-msgpack lsphp82-mysql lsphp82-opcache lsphp82-pear lsphp82-pgsql lsphp82-pspell lsphp82-redis lsphp82-snmp lsphp82-sqlite3 lsphp82-sybase lsphp82-tidy
    

    After installing, you need to edit the OpenLiteSpeed config file to switch php version.

    See OpenLiteSpeed

  • OpenLiteSpeed move Swapping Directory

    OpenLiteSpeed move Swapping Directory

    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 nobody:nobody /lswstmp/lshttpd
    

    Now login to OpenLiteSpeed admin interface at

    https://your-server-ip:7080/login.php
    

    If you don’t have user name and password, you can reset it by running command

    /usr/local/lsws/admin/misc/admpass.sh
    

    Once logged in, go to

    Server Configuration > General
    

    OpenLiteSpeed

    Under “Server Process’ section, you need to edit value of “Swapping Directory”. Default value is “/tmp/lshttpd/swap”, change it to “/lswstmp/lshttpd/swap”.

    Restart OpenLiteSpeed. You can do it using web interface or using SSH.

    systemctl restart lsws
    

    See OpenLiteSpeed

  • Monitor OpenLiteSpeed with monit

    OpenLiteSpeed Monit

    To monitor OpenLiteSpeed with monit on Ubuntu Server, create file

    vi /etc/monit/conf-enabled/openlitespeed
    

    Add following content

    check process OpenLiteSpeed with pidfile /tmp/lshttpd/lshttpd.pid
        start program = "/usr/bin/systemctl start lshttpd"
        stop program = "/usr/bin/systemctl stop lshttpd"
    

    Reload monit with

    monit reload
    

    Now monit will monitor OpenLiteSpeed, restart if required. You can check status with

    monit status
    

    monit status openlitespeed

    If you want to monitor if web server is responding to request, you can use

    check process OpenLiteSpeed with pidfile /tmp/lshttpd/lshttpd.pid
        start program = "/usr/bin/systemctl start lshttpd"
        stop program = "/usr/bin/systemctl stop lshttpd"
        if failed host localhost port 80 protocol http then restart
    
  • Install Zend OpCache on OpenLiteSpeed Server

    Install Zend OpCache on OpenLiteSpeed Server

    To install Zend OpCache on OpenLiteSpeed Server, run

    apt install -y lsphp73-opcache
    

    Now restart PHP with command

    killall -9 lsphp
    

    Zend OpCache GUI

    Zend OpCache GUI shows stats for OpCache. This is for monitoring purpose only.

    You can download it from

    https://github.com/amnuts/opcache-gui

    All you need to do is download the files, exact it, upload it to your web site. It will show nice graphs with cache statistics.

    Zend OpCache GUI

  • OpenLiteSpeed restart PHP

    On OpenLiteSpeed, if you edit php.ini or installed a PHP module, restart OpenLiteSpeed won’t show the changes. You will need to restart PHP process.

    You can do this by killing all PHP process with

    killall -9 lsphp
    

    Or you can create a file

    touch /usr/local/lsws/admin/tmp/.lsphp_restart.txt
    

    If you need PHP restarted just for a web site, run

    touch /home/USER1/.lsphp_restart.txt
    
  • OpenLiteSpeed Binary Installation

    OpenLiteSpeed Binary Installation

    You can download latest version of OpenLiteSpeed web server from

    https://openlitespeed.org/downloads/

    There are 2 download links for each version of OpenLiteSpeed, here we use the binary download. To install verison 1.7.1, run

    cd /usr/local/src
    rm -rf openlitespeed*
    wget https://openlitespeed.org/packages/openlitespeed-1.7.16.tgz
    tar -zxvf openlitespeed-*.tgz
    cd openlitespeed
    ./install.sh
    

    To start/stop OpenLiteSpeed, use the following commands

    /usr/local/lsws/bin/lswsctrl start
    /usr/local/lsws/bin/lswsctrl stop
    /usr/local/lsws/bin/lswsctrl status
    

    OpenLiteSpeed control panel available at

    https://SERVER-IP-ADDR:7080/
    User = admin
    PW = 123456
    

    Default password for admin user is 123456.

  • Install OpenLiteSpeed on CentOS

    Install OpenLiteSpeed on CentOS

    To install OpenLiteSpeed web server on CentOS, install repository for your CentOS version

    For CentOS 6

    rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el6.noarch.rpm
    

    For CentOS 7

    rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm
    

    For CentOS 8

    rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm
    

    To install OpenLiteSpeed, run

    yum install openlitespeed
    

    Before you can install PHP, you need epel repository enabled with

    yum install epel-release
    

    Install PHP with

    yum install lsphp73 lsphp73-common lsphp73-mysql lsphp73-gd lsphp73-process lsphp73-mbstring lsphp73-xml lsphp73-mcrypt lsphp73-pdo lsphp73-imap lsphp73-soap lsphp73-bcmath lsphp73-json lsphp73-mysqlnd
    

    Set symlink

    ln -sf /usr/local/lsws/lsphp73/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp5
    

    Start OpenLiteSpeed with

    /usr/local/lsws/bin/lswsctrl start
    

    To stop OpenLiteSpeed, run

    /usr/local/lsws/bin/lswsctrl stop
    

    By default, OpenLiteSpeed will run on port 8088

    http://YOUR_SERVER_IP_HERE:8088
    

    You can login to Admin Interface at

    http://YOUR_SERVER_IP_HERE:7080
    User = admin
    PW = 123456
    

    By default, you see an example application. The configuration file for this is at

    /usr/local/lsws/conf/vhosts/Example/vhconf.conf
    

    Default DocumentRoot is /usr/local/lsws/Example/html. To change, edit file

    vi /usr/local/lsws/conf/vhosts/Example/vhconf.conf
    

    Find

    docRoot $VH_ROOT/html/
    

    Replace $VH_ROOT/html/ with whatever path you need. You need to restart OpenLiteSpeed to make the change go live

    /usr/local/lsws/bin/lswsctrl restart
    
  • OpenLiteSpeed

    OpenLiteSpeed

    OpenLiteSpeed is an open-source version of the popular commercial web server LiteSpeed. OpenLiteSpeed contains all of the essential features found in LiteSpeed Enterprise.

    You can get OpenLiteSpeed from

    https://openlitespeed.org

    Here is a benchmark from the OpenLiteSpeed website that compares OpenLiteSpeed with Nginx.

    OpenLiteSpeed Benchmark

    OpenLiteSpeed configuration file

    /usr/local/lsws/conf/httpd_config.conf

    To start/stop/restart, use

    /usr/local/lsws/bin/lswsctrl start
    /usr/local/lsws/bin/lswsctrl stop
    /usr/local/lsws/bin/lswsctrl restart
    /usr/local/lsws/bin/lswsctrl status

    OpenLiteSpeed web server stores cache in directory /usr/local/lsws/cachedata. This can grow big over time. You can delete this folder to free up space or move it to another partition with free disk space and create a symlink.

    To set/reset the WebAdmin password, run

    /usr/local/lsws/admin/misc/admpass.sh

    Update OpenLiteSpeed

    /usr/local/lsws/admin/misc/lsup.sh -v 1.8.1

    You can login to WebAdmin at

    https://server-ip:7080

    Web Server

  • Install OpenLiteSpeed on Ubuntu/Debian

    Install OpenLiteSpeed on Ubuntu/Debian

    OpenLiteSpeed ia an Open Source version of LiteSpeed Web Server.

    To install OpenLiteSpeed, add repository by running

    wget -O - http://rpms.litespeedtech.com/debian/enable_lst_debain_repo.sh | bash
    

    Now you have openlitespeed packages available on your server. Here is packages available on a Debian 9 server.

    OpenLiteSpeed Web Server

    To install OpenLiteSpeed, run

    apt install -y openlitespeed
    

    OpenLiteSpeed will be installed in folder

    /usr/local/lsws
    

    You can start/stop OpenLiteSpeed using command

    root@ok:~# /usr/local/lsws/bin/lswsctrl
    $Usage: /usr/local/lsws/bin/lswsctrl {start|stop|restart|reload|condrestrt|try-restart|status|help}
    
    start       - start web server
    stop        - stop web server
    restart     - gracefully restart web server with zero down time
    reload      - same as restart
    condrestart - gracefully restart web server if server is running
    try-restart - same as condrestart
    status      - show service status
    help        - this screen
    
    root@ok:~#
    

    Once installed, you will be able to login to WebAdmin at

    https://YOUR_SERVER_IP_ADDR:7080
    User = admin
    Pass = 123456
    

    You can change default admin passord by going to

    Admin > WebAdmin Settings > General > Users

    Click on edit icon right side of user “admin”.

    OpenLiteSpeed Change Admin Password

    You can also change OpenLiteSpeed Admin password by running following command as user root

    /usr/local/lsws/admin/misc/admpass.sh
    
  • Install CyberPanel on CentOS 7

    Install CyberPanel on CentOS 7

    CyberPanel is a hosting control panel. CyberPanel uses OpenLiteSpeed, an open-source version of LiteSpeed Web server.

    CyberPanel with OpenLitespeed is Free to use.

    To install CyberPanel, run

    yum install -y wget
    wget https://cyberpanel.net/install.sh
    bash install.sh

    It asks you the number of MySQL instances. I selected option 1

    LiteSpeed CyberPanel install

    On next screen, it ask you to select MariaDB version. MariaDB is a MySQL drop in replacement, it work exactly like MySQL. Once install completed, installer displays login user name and password.

    You wil be able to login to CyberPanel at

    https://SERVER_IP:8090
    Panel username: admin
    Panel password: 1234567

    See LiteSpeed