### Perl CGI Hello World Script for OpenLiteSpeed Source: https://docs.openlitespeed.org/config/appserver/cgi This script provides a 'Hello World' example using Perl for OpenLiteSpeed's CGI. It prints the 'Content-type' header and basic HTML content. Proper execution permissions are crucial for this script. ```perl #!/usr/bin/perl print "Content-type: text/html\n\n"; print < A Simple Perl CGI

A Simple Perl CGI

Hello World

HTML exit; ``` -------------------------------- ### Manage OpenLiteSpeed Web Server Service Source: https://docs.openlitespeed.org/installation/binary These commands are used to start and check the status of the OpenLiteSpeed web server after installation. They rely on the startup script created during the binary installation. You typically need root or superuser privileges to execute these. ```bash /usr/local/lsws/bin/lswsctrl start ``` ```bash /usr/local/lsws/bin/lswsctrl status ``` -------------------------------- ### Configure Ghost Installation Source: https://docs.openlitespeed.org/apps/ghost Runs the Ghost setup wizard with specific flags to disable Nginx, systemd, and SSL setup, and to prevent automatic startup. The user will be prompted for configuration details. ```bash ghost setup --no-setup-nginx --no-setup-systemd --no-setup-ssl --no-start ``` -------------------------------- ### Install Flask and Create Project Structure (Shell) Source: https://docs.openlitespeed.org/config/appserver/python Installs Flask using pip and sets up the basic directory structure for a Flask project. It creates a 'demo' project directory and an 'app' subdirectory within it. ```shell pip3 install flask ``` ```shell mkdir /var/www/html/demo cd /var/www/html/demo mkdir app ``` -------------------------------- ### Build Example Module with make Source: https://docs.openlitespeed.org/modules Compiles a module's source code using the `make` command. Assumes the source code is in the specified directory. The output is a dynamic library file. ```Shell cd /openlitespeed_download/src/modules/example make ``` -------------------------------- ### Shell CGI Hello World Script for OpenLiteSpeed Source: https://docs.openlitespeed.org/config/appserver/cgi This script demonstrates a basic 'Hello World' CGI program written in shell script. It sets the 'Content-type' header and outputs a simple text message. Ensure the script has execute permissions for the web server user. ```shell #!/bin/sh date=`date -u '+%a,  %d  %b  %Y  %H:%M:%S  %Z'` cat << EOF Content-type: text/plain Expires: $date Hello World EOF ``` -------------------------------- ### Install Django and Create Project (Shell) Source: https://docs.openlitespeed.org/config/appserver/python Installs Django using pip and creates a new Django project. It assumes a virtual environment is already active. The project is created in the specified directory. ```shell pip install django ``` ```shell cd /var/www/html/ django-admin startproject demo ``` -------------------------------- ### Install Django Framework Source: https://docs.openlitespeed.org/config/appserver/python Installs the Django web framework using pip3, the Python package installer. This command is necessary to create and manage Django projects. ```shell pip3 install django ``` -------------------------------- ### Configure Module Parameters with More Options Source: https://docs.openlitespeed.org/modules An extended example of module parameters for OpenLiteSpeed, including additional caching and domain/URL exclusion settings. ```INI checkPublicCache 1 checkPrivateCache 1 maxCacheObjSize 10000000 maxStaleAge 200 qsCache 1 reqCookieCache 1 ignoreReqCacheCtrl 1 ignoreRespCacheCtrl 0 respCookieCache storagepath cachedata noCacheDomain noCacheUrl no-vary 0 addEtag |0 enableCache 0 expirelnSeconds 3600 enablePrivateCache 0 privateExpirelnSeconds 3600 ``` -------------------------------- ### Install OpenLiteSpeed using install.sh Source: https://docs.openlitespeed.org/installation/source This snippet demonstrates how to execute the `install.sh` script to complete the OpenLiteSpeed installation after the build process. A successful installation is indicated by an OK message. ```bash ./install.sh ``` -------------------------------- ### Verify WSGI Script Example Source: https://docs.openlitespeed.org/config/appserver/python A simple Python WSGI application script that demonstrates a basic 'It works!' response. This script is used to test the LSAPI and WSGI setup by returning a plain text message and the Python version. ```python import os import sys sys.path.insert(0, os.path.dirname(__file__)) def application(environ, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) message = 'It works!\n' version = 'Python %s\n' % sys.version.split()[0] response = '\n'.join([message, version]) return [response.encode()] ``` -------------------------------- ### Install OpenLiteSpeed, LSPHP, MariaDB, WordPress, and LiteSpeed Cache Plugin Source: https://docs.openlitespeed.org/installation/script This command installs OpenLiteSpeed, LSPHP, MariaDB, WordPress, and the LiteSpeed Cache plugin using the one-click script. It's a comprehensive setup for a functional WordPress site. ```bash bash <( curl -k https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh ) -w ``` -------------------------------- ### Install Ghost Locally using Ghost-CLI Source: https://docs.openlitespeed.org/apps/ghost Installs the Ghost blogging platform in the current directory using the 'ghost install local' command. This command handles downloading and setting up the core Ghost files. ```bash ghost install local ``` -------------------------------- ### Install OpenLiteSpeed with Default PHP Version Source: https://docs.openlitespeed.org/installation/script This basic command installs OpenLiteSpeed using the default PHP version configured in the script. It's the simplest way to get a web server running. ```bash ./ols1clk.sh ``` -------------------------------- ### Install AWStats on Ubuntu/Debian Source: https://docs.openlitespeed.org/modules/awstats Installs the AWStats package on Ubuntu and Debian-based systems using the apt package manager. This command ensures AWStats is installed with all its dependencies. ```shell apt install awstats -y ``` -------------------------------- ### Compile and Install PHP Source: https://docs.openlitespeed.org/config/php Compiles the configured PHP source code and installs it to the specified location. This process involves running `make` to build the binaries and `make install` to place them in the target directory. ```bash sudo make sudo make install ``` -------------------------------- ### Install OpenLiteSpeed with WordPress and MariaDB Source: https://docs.openlitespeed.org/installation/script This command installs OpenLiteSpeed, WordPress, and MariaDB. It's a common setup for users who want to host WordPress sites with a managed database. ```bash ./ols1clk.sh -W ``` -------------------------------- ### Install Pimcore using Vendor Binary Source: https://docs.openlitespeed.org/apps/pimcore Installs Pimcore within an existing project after navigating to the project directory. This command initiates the Pimcore installation process, prompting the user for necessary configuration details. ```shell cd html ./vendor/bin/pimcore-install ``` -------------------------------- ### Extract and Install OpenLiteSpeed Binary Source: https://docs.openlitespeed.org/installation/binary These commands first extract the downloaded OpenLiteSpeed archive using `tar` and then navigate into the extracted directory to run the installation script. Ensure you have the necessary permissions to extract and execute scripts. ```bash tar -zxvf openlitespeed-*.tgz cd openlitespeed ./install.sh ``` -------------------------------- ### Install AWStats on CentOS Source: https://docs.openlitespeed.org/modules/awstats Installs AWStats on CentOS systems. It first installs the EPEL repository, which provides the AWStats package, and then installs AWStats using dnf. ```shell dnf install epel-release dnf install awstats ``` -------------------------------- ### Install Composer using curl Source: https://docs.openlitespeed.org/apps/pimcore Installs Composer globally on the system using a curl command to download the installer and execute it with sudo privileges. This makes the 'composer' command available system-wide. ```shell curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer ``` -------------------------------- ### Install WSGI LSAPI for Python Source: https://docs.openlitespeed.org/config/appserver/python Downloads, compiles, and installs the WSGI LSAPI module for OpenLiteSpeed. This enables the web server to communicate with Python WSGI applications. Ensure you replace 'VERSION' with the desired LSAPI version. ```shell curl -O http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-VERSION.tgz tar xf wsgi-lsapi-VERSION.tgz cd wsgi-lsapi-VERSION python3 ./configure.py make cp lswsgi /usr/local/lsws/fcgi-bin/ ``` -------------------------------- ### OpenLiteSpeed Web Server Crash Alert Example Source: https://docs.openlitespeed.org/bugreport This is an example of an email alert that OpenLiteSpeed Web Server sends when it crashes unexpectedly. It includes environment details, module versions, OS information, and a core dump call stack for debugging purposes. The alert guides users to forward this information for issue resolution. ```text Web server example.com on example.com automatically restarted ##---------- Forwarded message ----------## At [21/Nov/2019:14:29:56 +0100], web server with pid=11024 received unexpected signal=7, a core file is created. A new instance of web server will be started automatically! Please forward the following debug information to bug@litespeedtech.com. Environment: Server: LiteSpeed/1.5.8 Open module versions: modpagespeed 2.2-1.11.33.4 cache 1.61 modinspector 1.1 uploadprogress LSIAPI_VERSION_STRING mod_security 1.1 OS: Linux Release: 3.10.0-1062.4.1.el7.x86_64 Version: #1 SMP Fri Oct 18 17:15:30 UTC 2019 Machine: x86_64 If the call stack information does not show up here, please compress and forward the core file located in /tmp/lshttpd. [New LWP 11024] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Core was generated by `openlitesp'. Program terminated with signal 7, Bus error. 0 0x00007fb7c94dcfe0 in __memmove_ssse3_back () from /lib64/libc.so.6 0 0x00007fb7c94dcfe0 in __memmove_ssse3_back () from /lib64/libc.so.6 1 0x00000000004c46a0 in ls_loopbuf_iAppend (pThis=0x2592260, pBuf=0x7fb7c9fa3800
, size=1352, pool=0x0) at lsr/ls_loopbuf.c:479 2 0x00000000004c430a in ls_loopbuf_xappend (pThis=0x2592260, pBuf=0x7fb7c9fa3800
, size=1352, pool=0x0) at lsr/ls_loopbuf.c:380 3 0x000000000055ce21 in ls_loopbuf_append (pThis=0x2592260, pBuf=0x7fb7c9fa3800
, size=1352) at ../../include/lsr/ls_loopbuf.h:285 4 0x000000000055d85b in LoopBuf::append (this=0x2592260, pBuf=0x7fb7c9fa3800
, size=1352) at ../../src/util/loopbuf.h:69 5 0x0000000000587ce0 in BufferedOS::cacheWrite (this=0x2592250, pBuf=0x7fb7c9fa3800
, size=1352) at ../../src/edio/bufferedos.h:54 6 0x000000000058c56c in H2Connection::sendDataFrame (this=0x2592240, uiStreamId=3963, flag=0, pBuf=0x7fb7c9fa3800
, len=1352) at h2connection.cpp:1254 7 0x000000000058fff9 in H2Stream::write (this=0x25bc650, buf=0x7fb7c9fa3800
, len=1352) at h2stream.cpp:305 8 0x00000000005491d0 in HttpSession::writeRespBodyDirect (this=0x273f790, pBuf=0x7fb7c9fa3800
, size=1352) at httpsession.cpp:3159 9 0x000000000054da1c in HttpSession::writeRespBodyBlockInternal (this=0x273f790, pData=0x273fe48, pBuf=0x7fb7c9fa3800
, written=1352) at httpsession.cpp:4763 10 0x000000000054e29c in HttpSession::sendStaticFileEx (this=0x273f790, pData=0x273fe48) at httpsession.cpp:4927 11 0x000000000054e618 in HttpSession::sendStaticFile (this=0x273f790, pData=0x273fe48) at httpsession.cpp:4975 12 0x000000000054b782 in HttpSession::flushBody (this=0x273f790) at httpsession.cpp:3968 13 0x000000000054bc66 in HttpSession::flush (this=0x273f790) at httpsession.cpp:4089 14 0x0000000000547ba2 in HttpSession::doWrite (this=0x273f790) at httpsession.cpp:2729 15 0x0000000000547fb5 in HttpSession::onWriteEx (this=0x273f790) at httpsession.cpp:2816 16 0x000000000059011a in H2Stream::onWrite (this=0x25bc650) at h2stream.cpp:326 17 0x000000000058e66a in H2Connection::onWriteEx2 (this=0x2592240) at h2connection.cpp:1817 18 0x000000000058e885 in H2Connection::onWriteEx (this=0x2592240) at h2connection.cpp:1851 19 0x000000000052c5a1 in NtwkIOLink::doWrite (this=0x244e7e0) at ntwkiolink.h:162 20 0x000000000052a218 in NtwkIOLink::onWriteSSL_T (pThis=0x244e7e0) at ntwkiolink.cpp:1455 21 0x0000000000527025 in NtwkIOLink::handleEvents (this=0x244e7e0, evt=4) at ntwkiolink.cpp:405 22 0x00000000005dd659 in epoll::waitAndProcessEvents (this=0x16c2c30, iTimeoutMilliSec=100) at epoll.cpp:229 23 0x0000000000513e74 in EventDispatcher::run (this=0x169dab8) at eventdispatcher.cpp:232 24 0x00000000004dc47c in HttpServerImpl::start (this=0x169da90) at httpserver.cpp:506 25 0x00000000004e7cfa in HttpServer::start (this=0x169da70) at httpserver.cpp:4578 26 0x00000000004d8a3a in LshttpdMain::main (this=0x169d820, argc=1, argv=0x7ffed44421b8) at lshttpdmain.cpp:1073 27 0x00000000004a3639 in main (argc=1, argv=0x7ffed44421b8) at main.cpp:109 ``` -------------------------------- ### Install MySQL Server Source: https://docs.openlitespeed.org/apps/ghost Installs the MySQL server package on Debian-based systems (like Ubuntu). ```bash apt-get install mysql-server ``` -------------------------------- ### Install OpenLiteSpeed (Debian/Ubuntu) Source: https://docs.openlitespeed.org/installation/repo Installs the OpenLiteSpeed web server on Debian or Ubuntu-based systems using the APT package manager after the LiteSpeed repository has been added. ```bash sudo apt-get -y install openlitespeed ``` -------------------------------- ### Install Python3 Development Libraries (Ubuntu) Source: https://docs.openlitespeed.org/config/appserver/python Installs essential build tools and the Python 3 development package on Ubuntu systems, required for compiling Python LSAPI. This ensures Python modules can be built correctly. ```shell apt install build-essential apt-get install python3-dev ``` -------------------------------- ### Search LSPHP Packages (Debian/Ubuntu) Source: https://docs.openlitespeed.org/installation/repo Lists available LSPHP packages and their extensions that can be installed on Debian or Ubuntu systems. ```bash sudo apt-cache search lsphp ``` -------------------------------- ### Install Python3 Development Libraries (CentOS) Source: https://docs.openlitespeed.org/config/appserver/python Installs the necessary Python 3 development package and pip for building Python extensions on CentOS systems. This is a prerequisite for compiling LSAPI. ```shell yum install python3-devel yum install python3-pip You may need to use: yum install python36-devel yum install python36-pip ``` -------------------------------- ### Install Ghost-CLI Globally Source: https://docs.openlitespeed.org/apps/ghost Installs the latest version of the Ghost-CLI command-line tool globally using npm. This tool is used for managing Ghost installations. ```bash npm install -g ghost-cli@latest ``` -------------------------------- ### Install GDB for OpenLiteSpeed Debugging Source: https://docs.openlitespeed.org/bugreport This snippet shows how to install the GDB debugger using yum, a prerequisite for obtaining detailed debug information from OpenLiteSpeed crash logs. After installation, a specific command is used to enable debug builds for OLS. ```bash yum install gdb /usr/local/lsws/admin/misc/lsup.sh -b -s -v ``` -------------------------------- ### Create Virtual Environment for Flask (Shell) Source: https://docs.openlitespeed.org/config/appserver/python Creates and activates a Python virtual environment for a Flask project. Similar to the Django example, it uses `virtualenv` and can specify Python versions. ```shell virtualenv venv ``` ```shell virtualenv -p python3 venv ``` ```shell source venv/bin/activate ``` ```shell which python ``` -------------------------------- ### Install OpenLiteSpeed with WordPress and MySQL Source: https://docs.openlitespeed.org/installation/script This command installs OpenLiteSpeed, WordPress, and MySQL. It provides an alternative database option for WordPress installations. ```bash ./ols1clk.sh -W --with-mysql ``` -------------------------------- ### Install Node.js and npm on Ubuntu Source: https://docs.openlitespeed.org/apps/ghost Installs Node.js and npm package manager on Ubuntu systems using apt-get. This is a prerequisite for installing Ghost-CLI. ```bash apt-get install nodejs npm -y ``` -------------------------------- ### Create Django Project Source: https://docs.openlitespeed.org/config/appserver/python Creates a new Django project named 'demo' in the specified directory. This command initializes the project structure, including necessary configuration files. ```shell mkdir -p /var/www/html/ cd /var/www/html/ django-admin startproject demo ``` -------------------------------- ### Download OpenLiteSpeed Binary using wget Source: https://docs.openlitespeed.org/installation/binary This command downloads the OpenLiteSpeed binary archive from a specified URL. It requires `wget` to be installed on the system. The output is the downloaded archive file. ```bash wget https://openlitespeed.org/packages/openlitespeed-1.8.4.tgz ``` -------------------------------- ### Create Ghost Application Directory Source: https://docs.openlitespeed.org/apps/ghost Creates the directory structure for the Ghost application and changes the current directory to it. This is where Ghost will be installed. ```bash mkdir -p /home/ghost/app/ ``` ```bash cd /home/ghost/app/ ``` -------------------------------- ### CrowdSec Decisions Table Example Source: https://docs.openlitespeed.org/security/crowdsec This is an example of the output format for the `cscli decisions list` command, displaying security decisions made by CrowdSec. It includes columns for ID, Source, Scope, Reason, Action, Country, AS, Events, expiration, and Alert ID. ```text ╭──────────┬───────────┬────────────────────┬────────────────────────────────────────┬────────┬──────────┬───────────────────────────┬─────────┬─────────────────────┬───────────╮ │ ID │ Source │ Scope:Value │ Reason │ Action │ Country │ AS │ Events │ expiration │ Alert ID │ ├──────────┼───────────┼────────────────────┼────────────────────────────────────────┼────────┼──────────┼───────────────────────────┼─────────┼─────────────────────┼───────────┤ │ 1560343 │ crowdsec │ Ip:x.x.x.x │ crowdsecurity/http-sensitive-files │ ban │ US │ 31898 xxxxxx-BMC-31898 │ 5 │ 3h59m58.922003003s │ 447 │ ╰──────────┴───────────┴────────────────────┴────────────────────────────────────────┴────────┴──────────┴───────────────────────────┴─────────┴─────────────────────┴───────────╯ ``` -------------------------------- ### Configure Module Parameters in WebAdmin Console Source: https://docs.openlitespeed.org/modules Example of module parameters that can be configured in the OpenLiteSpeed WebAdmin Console. These settings control the behavior of the module, such as caching policies. ```INI checkPrivateCache 1 checkPublicCache 1 maxCacheObjSize 10000000 maxStaleAge 0 qsCache 1 reqCookieCache 1 respCookieCache 1 ignoreReqCacheCtrl 1 ignoreRespCacheCtrl 0 enableCache 0 expireInSeconds 3600 enablePrivateCache 0 privateExpireInSeconds 3600 ``` -------------------------------- ### Install OpenLiteSpeed PageSpeed Repo and Packages Source: https://docs.openlitespeed.org/modules/pagespeed Commands to enable the LiteSpeed repository and install the PageSpeed module using package managers for Redhat/CentOS and Debian/Ubuntu systems. ```bash sudo wget -O - https://repo.litespeed.sh | sudo bash ``` ```bash yum install ols-pagespeed ``` ```bash apt-get install ols-pagespeed ``` -------------------------------- ### Set up Symlinks for AWStats CGI and Icons Source: https://docs.openlitespeed.org/modules/awstats Creates symbolic links to make the AWStats CGI scripts and icon files accessible from the web server's document root. This is necessary for viewing AWStats reports through a web browser. ```shell ln -sf /usr/lib/cgi-bin /var/www/html/cgi-bin ln -sf /usr/share/awstats/icon/* /var/www/html/awstats-icon ``` -------------------------------- ### Apache vhost Rewrite Rule Source: https://docs.openlitespeed.org/config/rewriterules Example of rewrite rules defined in an Apache vhost configuration. These rules can often be copied directly to OpenLiteSpeed. ```apache ServerName www.example.com RewriteEngine on RewriteCond %{HTTP_HOST} ^www.example.example.com RewriteRule ^/(.*)$ http://example.com/$1 [L,R=301] ``` -------------------------------- ### Build and Install Bubblewrap from Source Source: https://docs.openlitespeed.org/config/advanced/bubblewrap Builds and installs bubblewrap from source on Ubuntu 16.04/18.04 and similar releases. This is necessary if pre-built packages are not available or an older version is present. It includes steps for dependency installation, cloning the repository, checking out a specific version, compiling, and installing, along with creating symbolic links for bwrap. ```bash sudo apt install pkg-config libcap-dev automake git clone https://github.com/containers/bubblewrap.git cd bubblewrap git checkout v0.4.1 ./autogen.sh make sudo make install sudo ln -s /usr/local/bin/bwrap /bin/bwrap sudo mv /usr/bin/bwrap /usr/bin/bwrap.dist sudo ln -s /usr/local/bin/bwrap /usr/bin/bwrap ``` -------------------------------- ### Search LSPHP Packages (CentOS) Source: https://docs.openlitespeed.org/installation/repo Lists available LSPHP packages and their extensions that can be installed on CentOS or RHEL systems. ```bash sudo yum search lsphp ``` -------------------------------- ### Verify AWStats Configuration and Update Statistics Source: https://docs.openlitespeed.org/modules/awstats Builds the initial AWStats statistics by processing the current log files for a specified configuration. This command verifies that the configuration is correct and that AWStats can parse the log data. ```shell /usr/lib/cgi-bin/awstats.pl -config=example.com -update ``` -------------------------------- ### Install Ruby Packages (Ubuntu) Source: https://docs.openlitespeed.org/config/appserver/ruby Installs Ruby version manager (rbenv), ruby-build plugin, and Ruby 2.5.0 on Ubuntu systems. Includes development headers. ```bash git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build apt install rbenv libreadline-dev ruby-dev -y rbenv install 2.5.0 rbenv global 2.5.0 ``` -------------------------------- ### Install OpenLiteSpeed (CentOS) Source: https://docs.openlitespeed.org/installation/repo Installs the OpenLiteSpeed web server on CentOS or RHEL-based systems using the YUM package manager after the LiteSpeed repository has been added. ```bash sudo yum install openlitespeed -y ``` -------------------------------- ### Install Ruby Packages (CentOS) Source: https://docs.openlitespeed.org/config/appserver/ruby Installs Ruby, development headers, and gems package manager on CentOS systems using yum. ```bash yum install ruby ruby-devel rubygems ``` -------------------------------- ### Install OpenLiteSpeed and LSPHP Only Source: https://docs.openlitespeed.org/installation/script This command installs only OpenLiteSpeed and LSPHP, providing a minimal web server environment. It's useful for users who want to configure other components manually. ```bash bash <( curl -k https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh ) ``` -------------------------------- ### Install LSPHP (Debian/Ubuntu) Source: https://docs.openlitespeed.org/installation/repo Installs LSPHP version 8.1 and its MySQL extension on Debian or Ubuntu systems. This provides a high-performance PHP runtime for OpenLiteSpeed. ```bash sudo apt-get install lsphp81 lsphp81-common lsphp81-mysql ``` -------------------------------- ### Install Ruby LSAPI Gems Source: https://docs.openlitespeed.org/config/appserver/ruby Installs the Rack gem (version 1.6.11) and the ruby-lsapi gem, which are necessary for running Ruby applications with LSAPI. ```bash gem install rack -v 1.6.11 gem install ruby-lsapi ``` -------------------------------- ### Install LSPHP 8.3 (Ubuntu/Debian - apt-get) Source: https://docs.openlitespeed.org/config/php Installs LSPHP version 8.3 along with common files and MySQL support on Ubuntu and Debian systems using the apt-get package manager. This command ensures essential components for PHP with LSAPI are installed. ```bash $ sudo apt-get install lsphp83 lsphp83-common lsphp83-mysql ``` -------------------------------- ### Set up Cronjob for AWStats Log Updates Source: https://docs.openlitespeed.org/modules/awstats Configures a cron job to automatically update AWStats statistics at regular intervals (every 30 minutes in this example). This ensures that the statistics are always up-to-date with the latest log entries. ```shell crontab -e # Add the following rule: */30 * * * * root /usr/lib/cgi-bin/awstats.pl -config=example.com -update ``` -------------------------------- ### Install Node.js and npm on CentOS Source: https://docs.openlitespeed.org/apps/ghost Installs Node.js and npm package manager on CentOS systems using yum. This is a prerequisite for installing Ghost-CLI. ```bash yum install nodejs npm -y ``` -------------------------------- ### Install OpenLiteSpeed on DirectAdmin Source: https://docs.openlitespeed.org/panel/directadmin These commands install OpenLiteSpeed and configure PHP for use within the DirectAdmin environment. Ensure you are in the '/usr/local/directadmin/custombuild/' directory before executing. ```bash ./build set webserver openlitespeed ./build set php1_mode lsphp ./build openlitespeed ./build php ./build rewrite_confs ``` ```bash ./build set webserver openlitespeed ./build set php1_mode lsphp ./build set php2_mode lsphp ./build set php3_mode lsphp ./build openlitespeed ./build php ./build rewrite_confs ``` -------------------------------- ### Install LSPHP (CentOS) Source: https://docs.openlitespeed.org/installation/repo Installs LSPHP version 8.1 and its MySQLND extension on CentOS or RHEL systems. This provides a high-performance PHP runtime for OpenLiteSpeed. ```bash sudo yum install lsphp81 lsphp81-common lsphp81-mysqlnd ``` -------------------------------- ### Switch to Ghost User Source: https://docs.openlitespeed.org/apps/ghost Switches the current user to the newly created 'demouser' account. Subsequent commands will be executed as this user. ```bash su - demouser ``` -------------------------------- ### Search LSPHP Packages (Ubuntu/Debian - apt-cache) Source: https://docs.openlitespeed.org/config/php Searches for available LSPHP packages and extensions using the apt-cache command on Ubuntu and Debian systems. This helps identify specific versions and modules for installation. ```bash $ sudo apt-cache search lsphp ``` -------------------------------- ### Configure AWStats Website Settings Source: https://docs.openlitespeed.org/modules/awstats Copies the default AWStats configuration file to a new file specific to a website and then modifies key parameters within that configuration. This includes setting the log file path, the site domain, and host aliases, as well as enabling statistics updates from the browser. ```shell cp /etc/awstats/awstats.conf /etc/awstats/awstats.example.com.conf # Add the following entries to /etc/awstats/awstats.example.com.conf LogFile="/var/www/html/logs/access.log" SiteDomain="example.com" HostAliases="www.example.com localhost 127.0.0.1" AllowToUpdateStatsFromBrowser=1 ``` -------------------------------- ### Download OpenLiteSpeed Source Code using wget Source: https://docs.openlitespeed.org/installation/source This snippet shows how to download the OpenLiteSpeed source archive using the `wget` command from the console. It specifies a direct download URL for a specific version. ```bash wget https://github.com/litespeedtech/openlitespeed/archive/refs/tags/v1.8.4.tar.gz ``` -------------------------------- ### Install CrowdSec Repositories (Shell) Source: https://docs.openlitespeed.org/security/crowdsec Installs the CrowdSec repositories to enable access to the latest Security Engine and Remediation Components packages. This is a prerequisite for installing CrowdSec. ```shell curl -s https://install.crowdsec.net | sudo sh ``` -------------------------------- ### systemctl: General Help Source: https://docs.openlitespeed.org/config/advanced/cgroups Obtain general usage information and available options for the `systemctl` command by running it with the `--help` flag. ```bash systemctl --help ``` -------------------------------- ### CORS Methods Configuration Example Source: https://docs.openlitespeed.org/security/headers This snippet shows how to extend the default CORS supported methods by adding `OPTIONS` and `DELETE` to the `Access-Control-Allow-Methods` header. This allows for more complex HTTP requests to be handled by the server. ```text Access-Control-Allow-Methods GET, POST, OPTIONS, DELETE ``` -------------------------------- ### Install Rails and Node.js Source: https://docs.openlitespeed.org/config/appserver/ruby Installs the Rails gem for Ruby web development and Node.js, which is often a dependency for Rails asset management. ```bash gem install rails apt install node.js ``` -------------------------------- ### Configure PHP with LSAPI Support (PHP 7.3 and below) Source: https://docs.openlitespeed.org/config/php Configures the PHP build for older versions (like 7.3) with LSAPI support, specifying a custom installation path and various common extensions. Note the use of `--with-litespeed` for these versions. ```bash sudo ./configure '--prefix=/usr/local/lsws/lsphp73' '--with-libdir=lib64' '--with-zlib' '--with-gd' '--enable-shmop' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--with-curl' '--with-openssl' '--with-gettext' '--with-mcrypt' '--enable-mbstring=all' '--enable-mbregex' '--with-png-dir=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--enable-ftp' '--with-imap=/usr' '--with-imap-ssl' '--with-mysql=/usr' '--with-mysqli=/usr/bin/mysql_config' '--enable-pcntl' '--with-freetype-dir=/usr' '--with-pdo-mysql=/usr' '--with-litespeed' ``` -------------------------------- ### Restart OpenLiteSpeed Service Source: https://docs.openlitespeed.org/apps/ghost Restarts the OpenLiteSpeed web server service using systemctl. This is necessary for the server to recognize the new virtual host configuration and the running Node.js application. ```bash systemctl restart lsws ``` -------------------------------- ### OpenLiteSpeed cgroups Setup Script Source: https://docs.openlitespeed.org/config/advanced/cgroups This command executes the `lssetup` script provided by OpenLiteSpeed, which automates the system configuration for cgroups v2 and LiteSpeed. It sets up necessary cgroups features and modifies LiteSpeed configuration to enable cgroups and namespaces at the virtual host level. This is the recommended method for most users. ```bash sudo /usr/local/lsws/lsns/bin/lssetup ``` -------------------------------- ### Install LSPHP 8.3 (CentOS 9/8 - dnf) Source: https://docs.openlitespeed.org/config/php Installs LSPHP version 8.3 with common files and MySQLnd support on CentOS 8 and 9 systems using the dnf package manager. This command installs the core PHP package and necessary extensions. ```bash $ sudo dnf install lsphp83 lsphp83-common lsphp83-mysqlnd ``` -------------------------------- ### Install PHP Build Dependencies on Ubuntu/Debian Source: https://docs.openlitespeed.org/config/php Installs essential development packages required for compiling PHP with a feature-rich set of extensions on Ubuntu and Debian-based systems. This command ensures all necessary libraries and tools are present before the compilation process. ```bash sudo apt-get install build-essential pkg-config openssl libssl-dev bison autoconf automake libtool re2c flex libxml2-dev libssl-dev libbz2-dev libcurl4-openssl-dev libdb++-dev libjpeg-dev libpng-dev libxpm-dev libfreetype-dev libgmp3-dev libc-client2007e-dev libldap2-dev libmcrypt-dev libmhash-dev freetds-dev zlib1g-dev libmysqlclient-dev libncurses-dev libpcre3-dev unixodbc-dev libsqlite3-dev libaspell-dev libreadline-dev librecode-dev libsnmp-dev libtidy-dev libxslt1-dev libkrb5-dev libc6-dev libonig-dev libzip-dev -y ``` -------------------------------- ### OpenLiteSpeed Include File Directive Example Source: https://docs.openlitespeed.org/config/advanced/includes This example demonstrates the syntax for including configuration files in OpenLiteSpeed using wildcards. The directive searches for files with a .conf extension in specified subdirectories. It is important to note that this feature requires manual editing of configuration files as it's not supported by the WebAdmin Console. ```apache include $SERVER_ROOT/conf/l1/*/*.conf ``` -------------------------------- ### Add LiteSpeed Repository Source: https://docs.openlitespeed.org/installation/repo This command adds the LiteSpeed repository to your system, enabling package management for OpenLiteSpeed and LSPHP. It requires administrative privileges. ```bash sudo wget -O - https://repo.litespeed.sh | sudo bash ``` -------------------------------- ### Enable OWASP Feature for OpenLiteSpeed Source: https://docs.openlitespeed.org/installation/script This command enables the OWASP (Open Web Application Security Project) feature for OpenLiteSpeed, enhancing security by enabling mod_security with OWASP rules. This can be run even if the web server is already installed. ```bash ./ols1clk.sh --owasp-enable ``` -------------------------------- ### Flask Application Code (__init__.py) (Python) Source: https://docs.openlitespeed.org/config/appserver/python A minimal Flask application defining a single route that returns 'Hello Flask!'. This code is intended to be placed in the `app/__init__.py` file. ```python from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello Flask!" ``` -------------------------------- ### Install Node.js on Ubuntu Source: https://docs.openlitespeed.org/config/appserver/nodejs Command to install Node.js on Ubuntu systems using apt-get package manager. This is a prerequisite for running Node.js applications proxied by OpenLiteSpeed. ```bash apt-get install nodejs ``` -------------------------------- ### Configure OpenLiteSpeed Virtual Host for Ghost Source: https://docs.openlitespeed.org/apps/ghost Configuration steps for creating a virtual host in OpenLiteSpeed to serve a Ghost application. This involves setting virtual host details, document root, and app server context. ```text Virtual Host Name : Ghost Virtual Host Root : /home/ghost/app/ Config File : $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf Follow Symbolic Link : Yes Enable Scripts/ExtApps : Yes Restrained : Yes suEXEC User : demouser suEXEC Group : demouser ``` ```text Document Root: /home/ghost/app/ ``` ```text Type: App Server URI : / Location : /home/ghost/app/ Binary Path : /usr/bin/node Application Type : Node Startup File : current/index.js Run-time Mode : Production ``` ```text Virtual Host : Ghost Domains : ghost-ols.local ``` -------------------------------- ### Configure PHP with LSAPI Support (PHP 8.3+) Source: https://docs.openlitespeed.org/config/php Configures the PHP build with LSAPI support and various recommended extensions, setting a custom installation prefix. This command is for PHP versions 8.3 and newer and enables integration with OpenLiteSpeed. ```bash sudo ./configure --prefix=/usr/local/lsws/lsphp83 --enable-litespeed --with-mysqli --with-zlib --enable-gd --enable-shmop --enable-sockets --enable-sysvsem --enable-sysvshm --enable-mbstring --with-iconv --with-pdo-mysql --enable-ftp --with-zip --with-curl --enable-soap --enable-xml --with-openssl --enable-bcmath ``` -------------------------------- ### Copy Compiled Module to OpenLiteSpeed Source: https://docs.openlitespeed.org/modules Copies the compiled dynamic library file (e.g., `example.so`) to the OpenLiteSpeed modules directory. This makes the module available to the server. ```Shell cp example.so /usr/local/lsws/modules ``` -------------------------------- ### OpenLiteSpeed Common Log Format Examples Source: https://docs.openlitespeed.org/config/logs Provides examples of common log formats compatible with Apache 2.0's custom log format syntax. These formats define the structure of log entries for analysis. ```text %h %l %u %t "%r" %>s %b ``` ```text %v %h %l %u %t "%r" %>s %b ``` ```text %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i" ``` ```text %{Foobar}C ``` -------------------------------- ### Basic Ruby Application config.ru Source: https://docs.openlitespeed.org/config/appserver/ruby A simple Rack configuration file for a basic Ruby application. It defines a proc that returns 'It works!' and the Ruby version. This is used for verifying LSAPI setup. ```ruby app = proc do |env| message = "It works!\n" version = "Ruby %s\n" % RUBY_VERSION response = [message, version].join("\n") [200, {"Content-Type" => "text/plain"}, [response]] end run app ``` -------------------------------- ### Install PHP Build Dependencies on CentOS 9/8 Source: https://docs.openlitespeed.org/config/php Installs development packages necessary for compiling PHP on CentOS 8 and 9 systems. This command includes essential tools like gcc, make, and various development libraries for common PHP extensions. ```bash sudo dnf install patch gcc glibc libstdc++ binutils libtool autoconf make bison pam-devel libcap-devel openssl-devel tcp_wrappers-devel bzip2-devel curl-devel db4-devel gmp-devel httpd-devel libstdc++-devel sqlite-devel sqlite2-devel liyuybedit-devel pcre-devel libtool gcc-c++ libtool-ltdl-devel libevent-devel libc-client-devel cyrus-sasl-devel openldap-devel mysql-devel postgresql-devel unixODBC-devel libxml2-devel net-snmp-devel libxslt-devel libxml2-devel libjpeg-devel libpng-devel freetype-devel libXpm-devel t1lib-devel libmcrypt-devel libtidy-devel freetds-devel aspell-devel recode-devel enchant-devel firebird-devel gdbm-devel tokyocabinet-devel ``` -------------------------------- ### Install Bubblewrap on Ubuntu Source: https://docs.openlitespeed.org/config/advanced/bubblewrap Installs the bubblewrap package on Ubuntu systems using the apt package manager. This is a prerequisite for using bubblewrap with OpenLiteSpeed. ```bash sudo apt install bubblewrap ``` -------------------------------- ### Collect Static Files and Migrate (Shell) Source: https://docs.openlitespeed.org/config/appserver/python Collects static files into the designated `STATIC_ROOT` and applies database migrations. It also includes creating an admin superuser for Django. ```shell mkdir -p public/static ``` ```shell python manage.py collectstatic ``` ```shell python manage.py migrate ``` ```shell python manage.py createsuperuser ``` -------------------------------- ### Create Ghost User and Add to Sudoers Source: https://docs.openlitespeed.org/apps/ghost Creates a new user account named 'demouser' and adds it to the sudoers group, allowing it to run commands with administrative privileges. This user is required by Ghost-CLI. ```bash adduser demouser ``` ```bash usermod -aG sudo demouser ``` -------------------------------- ### 7G Firewall Log Entry Example Source: https://docs.openlitespeed.org/apps/7gfirewall An example of a log entry generated by the 7G Firewall when a request is blocked and logged. It includes IP address, timestamp, request method, protocol, requested URI, query string, and user agent. ```text 1.2.3.4 - 2021/10/08 01:06:38 - GET - HTTP/1.1 - / - fullclick - - - Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 ``` -------------------------------- ### Install Specific OpenLiteSpeed Version Source: https://docs.openlitespeed.org/panel/directadmin Instructions for downgrading or upgrading OpenLiteSpeed to a specific version by creating a 'custom_versions.txt' file. This allows for precise version control of OLS. ```bash cd /usr/local/directadmin/custombuild echo "openlitespeed:1.7.19:" > custom_versions.txt ./build openlitespeed ``` -------------------------------- ### Build OpenLiteSpeed from Source using build.sh Source: https://docs.openlitespeed.org/installation/source This snippet outlines the steps to build OpenLiteSpeed from its source code. It involves extracting the archive, navigating into the source directory, and executing the `build.sh` script which handles dependencies, configuration, and compilation. ```bash tar -zxvf v*.tar.gz cd openlitespeed* ./build.sh ``` -------------------------------- ### Apply Django Migrations and Create Superuser Source: https://docs.openlitespeed.org/config/appserver/python Applies database migrations to set up the necessary tables for your Django project and creates an administrative superuser account for accessing the Django admin interface. ```shell python3 manage.py migrate python3 manage.py createsuperuser ``` -------------------------------- ### Add LiteSpeed Repository (Bash) Source: https://docs.openlitespeed.org/config/php This command adds the LiteSpeed repository to your system, making it easier to install LSPHP packages. It requires root privileges and uses wget to download and execute a bash script. ```bash $ sudo wget -O - https://repo.litespeed.sh | sudo bash ``` -------------------------------- ### Scan Website with Nikto Source: https://docs.openlitespeed.org/security/crowdsec This command initiates a vulnerability scan on a specified website using the Nikto tool. Ensure Nikto is installed and accessible in your environment. The output will detail potential security issues found on the target. ```bash nikto -h https://example.com ``` -------------------------------- ### Example Lua Script (hello.lua) Source: https://docs.openlitespeed.org/modules/lua A simple Lua script that demonstrates basic output using OpenLiteSpeed's Lua API. It logs the current time, a string message, and the Lua version. ```lua ls.say(ls.logtime(), "LiteSpeed: Hello", _VERSION) ```