Giter Site home page Giter Site logo

ols1clk's Introduction

ols1clk

Build Status

Description

ols1clk is a one-click installation script for OpenLiteSpeed. Using this script, you can quickly and easily install OpenLiteSpeed with it’s default settings. We also provide a -W parameter that will install WordPress at the same time but it must still be configured through the wp-config.php page. By default, a MariaDB database will be set up using this script, you can also specify other DB if needed. If you already have a WordPress installation running on another server, it can be imported into OpenLiteSpeed with no hassle using the --wordpresspath parameter. To completely install WordPress with your OpenLiteSpeed installation, skipping the need for the wp-config.php page, use the --wordpressplus flag. This can be used with --wpuser, --wppassword, --wplang, and --sitetitle to configure each of the settings normally set by wp-config.php.

Installation

Our One-Click script comes with several options. Here are two commmon usages.

Install OpenLiteSpeed, LSPHP, MariaDB, WordPress, and LiteSpeed Cache plugin:

bash <( curl -k https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh ) -w

Install OpenLiteSpeed and LSPHP only:

bash <( curl -k https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh )

See below for additional options and usage examples.

Options:

./ols1clk.sh [option] [option] …
Opt Options Description
--adminuser [USERNAME] To set the WebAdmin username for OpenLiteSpeed instead of admin.
-A --adminpassword [PASSWORD] To set the WebAdmin password for OpenLiteSpeed instead of using a random one.
--adminport [PORTNUMBER] To set the WebAdmin console port number instead of 7080.
-E --email [EMAIL] To set the administrator email.
--lsphp [VERSION] To set the LSPHP version, such as 82. We currently support versions '71 72 73 74 80 81 82'.
--mariadbver [VERSION] To set MariaDB version, such as 10.9. We currently support versions '10.2 10.3 ...10.11'.
-W --wordpress To install WordPress. You will still need to complete the WordPress setup by browser
--wordpressplus [SITEDOMAIN] To install, set up, and configure WordPress, also LSCache will be enabled
--wordpresspath [WP_PATH] To specify a location for the new WordPress installation or use for an existing WordPress.
-R --dbrootpassword [PASSWORD] To set the database root password instead of using a random one.
--dbname [DATABASENAME] To set the database name to be used by WordPress.
--dbuser [DBUSERNAME] To set the WordPress username in the database.
--dbpassword [PASSWORD] To set the WordPress table password in MySQL instead of using a random one.
--prefix [PREFIXNAME] To set the WordPress table prefix.
--listenport [PORT] To set the HTTP server listener port, default is 80.
--ssllistenport [PORT] To set the HTTPS server listener port, default is 443.
--wpuser [WP_USER] To set the WordPress admin user for WordPress dashboard login. Default value is wpuser.
--wppassword [PASSWORD] To set the WordPress admin user password for WordPress dashboard login.
--wplang [WP_LANGUAGE] To set the WordPress language. Default value is "en_US" for English.
--sitetitle [WP_TITLE] To set the WordPress site title. Default value is mySite.
--pure-mariadb To install OpenLiteSpeed and MariaDB.
--pure-mysql To install OpenLiteSpeed and MySQL.
--pure-percona To install OpenLiteSpeed and Percona.
--with-mysql To install OpenLiteSpeed/App with MySQL.
--with-percona To install OpenLiteSpeed/App with Percona.
--owasp-enable To enable mod_security with OWASP rules. If OLS is installed, then enable the owasp directly
--owasp-disable To disable mod_security with OWASP rules.
--proxy-r To set a proxy with rewrite type.
--proxy-c To set a proxy with config type.
-U --uninstall To uninstall OpenLiteSpeed and remove installation directory.
-P --purgeall To uninstall OpenLiteSpeed, remove installation directory, and purge all data in MySQL.
-Q --quiet To use quiet mode, won't prompt to input anything.
-V --version To display the script version information.
-v --verbose To display more messages during the installation.
--update To update ols1clk from github.
-H --help To display help messages.

Examples

Examples Description
./ols1clk.sh To install OpenLiteSpeed with a random WebAdmin password.
./ols1clk.sh --lsphp 81 To install OpenLiteSpeed with lsphp80.
./ols1clk.sh -A 123456 -e [email protected] To install OpenLiteSpeed with WebAdmin password "123456" and email [email protected].
./ols1clk.sh -R 123456 -W To install OpenLiteSpeed with WordPress and MySQL root password "123456".
./ols1clk.sh --wordpressplus a.com To install OpenLiteSpeed with a fully configured WordPress installation at "a.com".

FAQ

How do I create additional Virtual Hosts from the console?

Run the following command to create an additional virtual host in a few seconds. The example document root will be /var/www/www.example.com. Be sure to substitute your own domain.

/bin/bash <( curl -sk https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Setup/vhsetup.sh ) -d www.example.com

How do I create additional Virtual Hosts with WordPress from the console?

The first time you create an additional Virtual Host, the script will need to get your database root password from /usr/local/lsws/password. If you have custom value, please update /usr/local/lsws/password or echo the password to the specified location: /root/.db_password.

echo 'root_mysql_pass="DB_ROOT_PASSWORD"' > /root/.db_password

Then run the following command to create an additional virtual host with the WordPress.

/bin/bash <( curl -sk https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Setup/vhsetup.sh ) -d www.example.com -w

How to I create additional Virtual Hosts and LE certificates from the console?

Please be sure that your domain is already pointing to the server.

Then run the following command to create an additional virtual host with a Let's Encrypt certificate applied. Be sure to substitute your own domain and your email address.

/bin/bash <( curl -sk https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Setup/vhsetup.sh ) -d www.example.com -le [email protected] -f

Note: The -f option is to force https redirection

Support & Feedback

If you still have a question after reading these instructions, you have a few options:

ols1clk's People

Contributors

adrianpop avatar code-egg avatar davidlst avatar ducun avatar ivmm avatar kevin-fwu avatar litespeedtech avatar lslisa avatar lsmike avatar timbocode avatar zixia1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ols1clk's Issues

Allow different "admin" user

Hi,

Not sure if this is possible, but since we already have a --adminpassword flag, can we also please have a --adminuser as well?
The goal if possible, is not to create the "admin" username at all, and instead use our own admin username.

Thank you

Support Debian 11

#!/bin/bash
##############################################################################
#    Open LiteSpeed is an open source HTTP server.                           #
#    Copyright (C) 2013 - 2021 LiteSpeed Technologies, Inc.                  #
#                                                                            #
#    This program is free software: you can redistribute it and/or modify    #
#    it under the terms of the GNU General Public License as published by    #
#    the Free Software Foundation, either version 3 of the License, or       #
#    (at your option) any later version.                                     #
#                                                                            #
#    This program is distributed in the hope that it will be useful,         #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of          #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            #
#    GNU General Public License for more details.                            #
#                                                                            #
#    You should have received a copy of the GNU General Public License       #
#    along with this program. If not, see http://www.gnu.org/licenses/.      #
##############################################################################
###    Author: [email protected] (David Shue)


TEMPRANDSTR=
OSNAMEVER=UNKNOWN
OSNAME=
OSVER=
OSTYPE=$(uname -m)
MARIADBCPUARCH=
SERVER_ROOT=/usr/local/lsws
WEBCF="$SERVER_ROOT/conf/httpd_config.conf"
OLSINSTALLED=
MYSQLINSTALLED=
TESTGETERROR=no
DATABASENAME=olsdbname
USERNAME=olsdbuser
VERBOSE=0
PURE_DB=0
WORDPRESSPATH=$SERVER_ROOT/wordpress
WPPORT=80
SSLWPPORT=443
WORDPRESSINSTALLED=
INSTALLWORDPRESS=0
INSTALLWORDPRESSPLUS=0
FORCEYES=0
WPLANGUAGE=en_US
WPUSER=wpuser
WPTITLE=MySite
SITEDOMAIN=*
EMAIL=
ADMINPASSWORD=
ROOTPASSWORD=
USERPASSWORD=
WPPASSWORD=
LSPHPVERLIST=(56 70 71 72 73 74 80)
MARIADBVERLIST=(10.2 10.3 10.4 10.5 10.6)
LSPHPVER=80
MARIADBVER=10.6
WEBADMIN_LSPHPVER=80
ALLERRORS=0
TEMPPASSWORD=
ACTION=INSTALL
FOLLOWPARAM=
CONFFILE=myssl.conf
CSR=example.csr
KEY=example.key
CERT=example.crt
EPACE='        '
FPACE='    '
APT='apt-get -qq'
YUM='yum -q'
MYGITHUBURL=https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh

function echoY
{
    FLAG=$1
    shift
    echo -e "\033[38;5;148m$FLAG\033[39m$@"
}

function echoG
{
    FLAG=$1
    shift
    echo -e "\033[38;5;71m$FLAG\033[39m$@"
}

function echoB
{
    FLAG=$1
    shift
    echo -e "\033[38;1;34m$FLAG\033[39m$@"
}

function echoR
{
    FLAG=$1
    shift
    echo -e "\033[38;5;203m$FLAG\033[39m$@"
}

function echoW
{
    FLAG=${1}
    shift
    echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}

function echoNW
{
    FLAG=${1}
    shift
    echo -e "\033[1m${FLAG}\033[0m${@}"
}

function echoCYAN
{
    FLAG=$1
    shift
    echo -e "\033[1;36m$FLAG\033[0m$@"
}

function silent
{
    if [ "${VERBOSE}" = '1' ] ; then
        "$@"
    else
        "$@" >/dev/null 2>&1
    fi
}

function change_owner
{
    chown -R ${USER}:${GROUP} ${1}
}

function check_root
{
    local INST_USER=`id -u`
    if [ $INST_USER != 0 ] ; then
        echoR "Sorry, only the root user can install."
        echo
        exit 1
    fi
}

function update_system(){
    echoG 'System update'
    if [ "$OSNAME" = "centos" ] ; then
        silent ${YUM} update -y >/dev/null 2>&1
    else
        silent ${APT} update && ${APT} upgrade -y >/dev/null 2>&1
    fi
}

function check_wget
{
    which wget  >/dev/null 2>&1
    if [ $? != 0 ] ; then
        if [ "$OSNAME" = "centos" ] ; then
            silent ${YUM} -y install wget
        else
            ${APT} -y install wget
        fi
        which wget  >/dev/null 2>&1
        if [ $? != 0 ] ; then
            echoR "An error occured during wget installation."
            ALLERRORS=1
        fi
    fi
}

function check_curl
{
    which curl  >/dev/null 2>&1
    if [ $? != 0 ] ; then
        if [ "$OSNAME" = "centos" ] ; then
            silent ${YUM} -y install curl
        else
            ${APT} -y install curl
        fi
        which curl  >/dev/null 2>&1
        if [ $? != 0 ] ; then
            echoR "An error occured during curl installation."
            ALLERRORS=1
        fi
    fi
}

function update_email
{
    if [ "$EMAIL" = '' ] ; then
        if [ "$SITEDOMAIN" = "*" ] ; then
            EMAIL=root@localhost
        else
            EMAIL=root@$SITEDOMAIN
        fi
    fi
}

function restart_lsws
{
    systemctl stop lsws >/dev/null 2>&1
    systemctl start lsws
}

function usage
{
    echo -e "\033[1mOPTIONS\033[0m"
    echoNW "  -A,    --adminpassword [PASSWORD]" "${EPACE}To set the WebAdmin password for OpenLiteSpeed instead of using a random one."
    echoNW "  -E,    --email [EMAIL]          " "${EPACE} To set the administrator email."
    echoW " --lsphp [VERSION]                 " "To set the LSPHP version, such as 80. We currently support versions '${LSPHPVERLIST[@]}'."
    echoW " --mariadbver [VERSION]            " "To set MariaDB version, such as 10.5. We currently support versions '${MARIADBVERLIST[@]}'."
    echoNW "  -W,    --wordpress              " "${EPACE} To install WordPress. You will still need to complete the WordPress setup by browser"
    echoW " --wordpressplus [SITEDOMAIN]      " "To install, setup, and configure WordPress, also LSCache will be enabled"
    echoW " --wordpresspath [WP_PATH]         " "To specify a location for the new WordPress installation or an existing WordPress."
    echoNW "  -R,    --dbrootpassword [PASSWORD]  " "     To set the database root password instead of using a random one."
    echoW " --dbname [DATABASENAME]           " "To set the database name to be used by WordPress."
    echoW " --dbuser [DBUSERNAME]             " "To set the WordPress username in the database."
    echoW " --dbpassword [PASSWORD]           " "To set the WordPress table password in MySQL instead of using a random one."
    echoW " --listenport [PORT]               " "To set the HTTP server listener port, default is 80."
    echoW " --ssllistenport [PORT]            " "To set the HTTPS server listener port, default is 443."
    echoW " --wpuser [WORDPRESSUSER]          " "To set the WordPress admin user for WordPress dashboard login. Default value is wpuser."
    echoW " --wppassword [PASSWORD]           " "To set the WordPress admin user password for WordPress dashboard login."
    echoW " --wplang [WP_LANGUAGE]            " "To set the WordPress language. Default value is \"en_US\" for English."
    echoW " --sitetitle [WP_TITLE]            " "To set the WordPress site title. Default value is mySite."
    echoNW "  -U,    --uninstall              " "${EPACE} To uninstall OpenLiteSpeed and remove installation directory."
    echoNW "  -P,    --purgeall               " "${EPACE} To uninstall OpenLiteSpeed, remove installation directory, and purge all data in MySQL."
    echoNW "  -Q,    --quiet                  " "${EPACE} To use quiet mode, won't prompt to input anything."
    echoNW "  -V,    --version                " "${EPACE} To display the script version information."
    echoNW "  -v,    --verbose                " "${EPACE} To display more messages during the installation."
    echoW " --update                          " "To update ols1clk from github."
    echoNW "  -H,    --help                   " "${EPACE} To display help messages."
    echo 
    echo -e "\033[1mEXAMPLES\033[0m"
    echoW "./ols1clk.sh                       " "To install OpenLiteSpeed with a random WebAdmin password."
    echoW "./ols1clk.sh --lsphp 80            " "To install OpenLiteSpeed with lsphp80."
    echoW "./ols1clk.sh -A 123456 -e [email protected] " "To install OpenLiteSpeed with WebAdmin password  \"123456\" and email [email protected]."
    echoW "./ols1clk.sh -R 123456 -W          " "To install OpenLiteSpeed with WordPress and MySQL root password \"123456\"."
    echoW "./ols1clk.sh --wordpressplus a.com " "To install OpenLiteSpeed with a fully configured WordPress installation at \"a.com\"."
    echo
    exit 0
}

function display_license
{
    echoY '**********************************************************************************************'
    echoY '*                    Open LiteSpeed One click installation, Version 3.0                      *'
    echoY '*                    Copyright (C) 2016 - 2021 LiteSpeed Technologies, Inc.                  *'
    echoY '**********************************************************************************************'
}

function check_os
{
    if [ -f /etc/redhat-release ] ; then
        OSNAME=centos
        USER='nobody'
        GROUP='nobody'
        case $(cat /etc/centos-release | tr -dc '0-9.'|cut -d \. -f1) in 
        6)
            OSNAMEVER=CENTOS6
            OSVER=6
            ;;
        7)
            OSNAMEVER=CENTOS7
            OSVER=7
            ;;
        8)
            OSNAMEVER=CENTOS8
            OSVER=8
            ;;
        esac    
    elif [ -f /etc/lsb-release ] ; then
        OSNAME=ubuntu
        USER='nobody'
        GROUP='nogroup'
        case $(cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2) in
        trusty)
            OSNAMEVER=UBUNTU14
            OSVER=trusty
            MARIADBCPUARCH="arch=amd64,i386,ppc64el"
            ;;
        xenial)
            OSNAMEVER=UBUNTU16
            OSVER=xenial
            MARIADBCPUARCH="arch=amd64,i386,ppc64el"
            ;;
        bionic)
            OSNAMEVER=UBUNTU18
            OSVER=bionic
            MARIADBCPUARCH="arch=amd64"
            ;;
        focal)            
            OSNAMEVER=UBUNTU20
            OSVER=focal
            MARIADBCPUARCH="arch=amd64"
            ;;
        esac
    elif [ -f /etc/debian_version ] ; then
        OSNAME=debian
        case $(cat /etc/os-release | grep VERSION_CODENAME | cut -d = -f 2) in
        wheezy)
            OSNAMEVER=DEBIAN7
            OSVER=wheezy
            MARIADBCPUARCH="arch=amd64,i386"
            ;;
        jessie)
            OSNAMEVER=DEBIAN8
            OSVER=jessie
            MARIADBCPUARCH="arch=amd64,i386"
            ;;
        stretch) 
            OSNAMEVER=DEBIAN9
            OSVER=stretch
            MARIADBCPUARCH="arch=amd64,i386"
            ;;
        buster)
            OSNAMEVER=DEBIAN10
            OSVER=buster
            MARIADBCPUARCH="arch=amd64,i386"
            ;;
        bullseye)
            OSNAMEVER=DEBIAN11
            OSVER=bullseye
            MARIADBCPUARCH="arch=amd64,i386"
            ;;
        esac    
    fi
    if [ "$OSNAMEVER" = '' ] ; then
        echoR "Sorry, currently one click installation only supports Centos(6-8), Debian(7-10) and Ubuntu(14,16,18,20)."
        echoR "You can download the source code and build from it."
        echoR "The url of the source code is https://github.com/litespeedtech/openlitespeed/releases."
        exit 1
    else
        if [ "$OSNAME" = "centos" ] ; then
            echoG "Current platform is "  "$OSNAME $OSVER."
        else
            export DEBIAN_FRONTEND=noninteractive
            echoG "Current platform is "  "$OSNAMEVER $OSNAME $OSVER."
        fi
    fi
}

function update_centos_hashlib
{
    if [ "$OSNAME" = 'centos' ] ; then
        silent ${YUM} -y install python-hashlib
    fi
}

function install_ols_centos
{
    local action=install
    if [ "$1" = "Update" ] ; then
        action=update
    elif [ "$1" = "Reinstall" ] ; then
        action=reinstall
    fi

    local JSON=
    if [ "x$LSPHPVER" = "x70" ] || [ "x$LSPHPVER" = "x71" ] || [ "x$LSPHPVER" = "x72" ] || [ "x$LSPHPVER" = "x73" ] || [ "x$LSPHPVER" = "x74" ]; then
        JSON=lsphp$LSPHPVER-json
    fi
    echoB "${FPACE} - add epel repo"
    silent ${YUM} -y $action epel-release
    echoB "${FPACE} - add litespeedtech repo"
    rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el$OSVER.noarch.rpm >/dev/null 2>&1
    echoB "${FPACE} - $1 OpenLiteSpeed"
    silent ${YUM} -y $action openlitespeed
    if [ ! -e $SERVER_ROOT/lsphp$LSPHPVER/bin/lsphp ] ; then
        action=install
    fi
    echoB "${FPACE} - $1 lsphp$LSPHPVER"
    if [ "$action" = "reinstall" ] ; then
        silent ${YUM} -y remove lsphp$LSPHPVER-mysqlnd
    fi
    silent ${YUM} -y install lsphp$LSPHPVER-mysqlnd
    if [ "$LSPHPVER" = "80" ]; then 
        silent ${YUM} -y $action lsphp$LSPHPVER lsphp$LSPHPVER-common lsphp$LSPHPVER-gd lsphp$LSPHPVER-process lsphp$LSPHPVER-mbstring \
        lsphp$LSPHPVER-xml lsphp$LSPHPVER-pdo lsphp$LSPHPVER-imap
    else
        silent ${YUM} -y $action lsphp$LSPHPVER lsphp$LSPHPVER-common lsphp$LSPHPVER-gd lsphp$LSPHPVER-process lsphp$LSPHPVER-mbstring \
        lsphp$LSPHPVER-xml lsphp$LSPHPVER-mcrypt lsphp$LSPHPVER-pdo lsphp$LSPHPVER-imap $JSON
    fi
    echoB "${FPACE} - Setup lsphp symlink"
    if [ $? != 0 ] ; then
        echoR "An error occured during OpenLiteSpeed installation."
        ALLERRORS=1
    else
        ln -sf $SERVER_ROOT/lsphp$LSPHPVER/bin/lsphp $SERVER_ROOT/fcgi-bin/lsphpnew
        sed -i -e "s/fcgi-bin\/lsphp/fcgi-bin\/lsphpnew/g" "${WEBCF}"
        sed -i -e "s/lsphp${WEBADMIN_LSPHPVER}\/bin\/lsphp/lsphp$LSPHPVER\/bin\/lsphp/g" "${WEBCF}"
    fi
}

function uninstall_ols_centos
{
    echoB "${FPACE} - Remove OpenLiteSpeed"
    silent ${YUM} -y remove openlitespeed
    if [ $? != 0 ] ; then
        echoR "An error occured while uninstalling OpenLiteSpeed."
        ALLERRORS=1
    fi
    rm -rf $SERVER_ROOT/
}

function uninstall_php_centos
{
    ls "${SERVER_ROOT}" | grep lsphp >/dev/null
    if [ $? = 0 ] ; then
        local LSPHPSTR="$(ls ${SERVER_ROOT} | grep -i lsphp | tr '\n' ' ')"
        for LSPHPVER in ${LSPHPSTR}; do 
            echoB "${FPACE} - Detect LSPHP version $LSPHPVER"
            if [ "$LSPHPVER" = "lsphp80" ]; then
                silent ${YUM} -y remove lsphp$LSPHPVER lsphp$LSPHPVER-common lsphp$LSPHPVER-gd lsphp$LSPHPVER-process lsphp$LSPHPVER-mbstring \
                lsphp$LSPHPVER-mysqlnd lsphp$LSPHPVER-xml  lsphp$LSPHPVER-pdo lsphp$LSPHPVER-imap lsphp*
            else
                silent ${YUM} -y remove lsphp$LSPHPVER lsphp$LSPHPVER-common lsphp$LSPHPVER-gd lsphp$LSPHPVER-process lsphp$LSPHPVER-mbstring \
                lsphp$LSPHPVER-mysqlnd lsphp$LSPHPVER-xml lsphp$LSPHPVER-mcrypt lsphp$LSPHPVER-pdo lsphp$LSPHPVER-imap $JSON lsphp*
            fi                
            if [ $? != 0 ] ; then
                echoR "An error occured while uninstalling lsphp$LSPHPVER"
                ALLERRORS=1
            fi
        done 
    else
        echoB "${FPACE} - Uinstall LSPHP"
        ${YUM} -y remove lsphp*
        echoR "Uninstallation cannot get the currently installed LSPHP version."
        echoY "May not uninstall LSPHP correctly."
        LSPHPVER=
    fi
}

function install_ols_debian
{
    local action=
    local INSTALL_STATUS=0
    if [ "$1" = "Update" ] ; then
        action="--only-upgrade"
    elif [ "$1" = "Reinstall" ] ; then
        action="--reinstall"
    fi
    echoB "${FPACE} - add litespeedtech repo"
    grep -Fq  "http://rpms.litespeedtech.com/debian/" /etc/apt/sources.list.d/lst_debian_repo.list 2>/dev/null
    if [ $? != 0 ] ; then
        echo "deb http://rpms.litespeedtech.com/debian/ $OSVER main"  > /etc/apt/sources.list.d/lst_debian_repo.list
    fi
    wget -qO /etc/apt/trusted.gpg.d/lst_debian_repo.gpg http://rpms.litespeedtech.com/debian/lst_debian_repo.gpg
    wget -qO /etc/apt/trusted.gpg.d/lst_repo.gpg http://rpms.litespeedtech.com/debian/lst_repo.gpg
    echoB "${FPACE} - update list"
    ${APT} -y update
    echoB "${FPACE} - $1 OpenLiteSpeed"
    silent ${APT} -y install $action openlitespeed

    if [ ${?} != 0 ] ; then
        echoR "An error occured during OpenLiteSpeed installation."
        ALLERRORS=1
        INSTALL_STATUS=1
    fi
    if [ ! -e $SERVER_ROOT/lsphp$LSPHPVER/bin/lsphp ] ; then
        action=
    fi
    echoB "${FPACE} - $1 lsphp$LSPHPVER"
    silent ${APT} -y install $action lsphp$LSPHPVER lsphp$LSPHPVER-mysql lsphp$LSPHPVER-imap lsphp$LSPHPVER-curl
    if [ "$LSPHPVER" = "56" ]; then
        silent ${APT} -y install $action lsphp$LSPHPVER-gd lsphp$LSPHPVER-mcrypt
    elif [ "$LSPHPVER" = "80" ]; then
        silent ${APT} -y install $action lsphp$LSPHPVER-common
    else
        silent ${APT} -y install $action lsphp$LSPHPVER-common lsphp$LSPHPVER-json
    fi
    if [ $? != 0 ] ; then
        echoR "An error occured during lsphp$LSPHPVER installation."
        ALLERRORS=1
    fi
    echoB "${FPACE} - Setup lsphp symlink"
    #if [ ${INSTALL_STATUS} = 0 ]; then 
    if [ -e $SERVER_ROOT/bin/openlitespeed ]; then 
        ln -sf $SERVER_ROOT/lsphp$LSPHPVER/bin/lsphp $SERVER_ROOT/fcgi-bin/lsphpnew
        sed -i -e "s/fcgi-bin\/lsphp/fcgi-bin\/lsphpnew/g" "${WEBCF}"    
        sed -i -e "s/lsphp${WEBADMIN_LSPHPVER}\/bin\/lsphp/lsphp$LSPHPVER\/bin\/lsphp/g" "${WEBCF}"
    fi
}


function uninstall_ols_debian
{
    echoB "${FPACE} - Uninstall OpenLiteSpeed"
    silent ${APT} -y purge openlitespeed
    silent ${APT} -y remove openlitespeed
    ${APT} clean
    #rm -rf $SERVER_ROOT/
}

function uninstall_php_debian
{
    echoB "${FPACE} - Uninstall LSPHP"
    silent ${APT} -y --purge remove lsphp*
    if [ -e /usr/bin/php ] && [ -L /usr/bin/php ]; then 
        rm -f /usr/bin/php
    fi
}

function action_uninstall
{
    if [ "$ACTION" = "UNINSTALL" ] ; then
        uninstall_warn
        uninstall
        uninstall_result
        exit 0
    fi    
} 

function action_purgeall
{    
    if [ "$ACTION" = "PURGEALL" ] ; then
        uninstall_warn
        if [ "$ROOTPASSWORD" = '' ] ; then
            passwd=
            echoY "Please input the MySQL root password: "
            read passwd
            ROOTPASSWORD=$passwd
        fi
        uninstall
        purgedatabase
        uninstall_result
        exit 0
    fi
}

function download_wordpress
{
    echoG 'Start Download WordPress file'
    if [ ! -e "$WORDPRESSPATH" ] ; then
        local WPDIRNAME=$(dirname $WORDPRESSPATH)
        local WPBASENAME=$(basename $WORDPRESSPATH)
        mkdir -p "$WORDPRESSPATH"; 
        cd "$WORDPRESSPATH"
    else
        echoG "$WORDPRESSPATH exists, will use it."
    fi
    if [ "${WORDPRESSINSTALLED}" = '0' ];then 
        wp core download \
            --locale=$WPLANGUAGE \
            --path=$WORDPRESSPATH \
            --allow-root \
            --quiet
    fi        
    echoG 'End Download WordPress file'
}
function create_wordpress_cf
{
    echoG 'Start Create Wordpress config'
    cd "$WORDPRESSPATH"
    wp config create \
        --dbname=$DATABASENAME \
        --dbuser=$USERNAME \
        --dbpass=$USERPASSWORD \
        --locale=ro_RO \
        --allow-root \
        --quiet
    echoG 'Done Create Wordpress config'
}

function install_wordpress_core
{
    echoG 'Start Setting Core Wordpress'
    cd "$WORDPRESSPATH"
    wp core install \
        --url=$SITEDOMAIN \
        --title=$WPTITLE \
        --admin_user=$WPUSER \
        --admin_password=$WPPASSWORD \
        --admin_email=$EMAIL \
        --skip-email \
        --allow-root
    echoG 'Install wordpress Cache plugin'    
    wp plugin install litespeed-cache \
        --allow-root \
        --activate \
        --quiet
    echoG 'End Setting Core Wordpress'
}

function random_password
{
    if [ ! -z ${1} ]; then 
        TEMPPASSWORD="${1}"
    else    
        TEMPPASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 ; echo '')
    fi
}

function main_gen_password
{
    random_password "${ADMINPASSWORD}"
    ADMINPASSWORD="${TEMPPASSWORD}"
    random_password "${ROOTPASSWORD}"
    ROOTPASSWORD="${TEMPPASSWORD}"
    random_password "${USERPASSWORD}"
    USERPASSWORD="${TEMPPASSWORD}"
    random_password "${WPPASSWORD}"
    WPPASSWORD="${TEMPPASSWORD}"
    read_password "$ADMINPASSWORD" "webAdmin password"
    ADMINPASSWORD=$TEMPPASSWORD
    
    if [ "$INSTALLWORDPRESS" = "1" ] ; then
        read_password "$ROOTPASSWORD" "MySQL root password"
        ROOTPASSWORD=$TEMPPASSWORD
        read_password "$USERPASSWORD" "MySQL user password"
        USERPASSWORD=$TEMPPASSWORD
    fi

    if [ "$INSTALLWORDPRESSPLUS" = "1" ] ; then
        read_password "$WPPASSWORD" "WordPress admin password"
        WPPASSWORD=$TEMPPASSWORD
    fi    
}

function main_set_password
{
    echo "WebAdmin username is [admin], password is [$ADMINPASSWORD]." > $SERVER_ROOT/password
    set_ols_password
}

function test_mysql_password
{
    CURROOTPASSWORD=$ROOTPASSWORD
    TESTPASSWORDERROR=0

    mysqladmin -uroot -p$CURROOTPASSWORD password $CURROOTPASSWORD
    if [ $? != 0 ] ; then
        #Sometimes, mysql will treat the password error and restart will fix it.
        service mysql restart
        if [ $? != 0 ] && [ "$OSNAME" = "centos" ] ; then
            service mysqld restart
        fi

        mysqladmin -uroot -p$CURROOTPASSWORD password $CURROOTPASSWORD
        if [ $? != 0 ] ; then
            printf '\033[31mPlease input the current root password:\033[0m'
            read answer
            mysqladmin -uroot -p$answer password $answer
            if [ $? = 0 ] ; then
                CURROOTPASSWORD=$answer
            else
                echoR "root password is incorrect. 2 attempts remaining."
                printf '\033[31mPlease input the current root password:\033[0m'
                read answer
                mysqladmin -uroot -p$answer password $answer
                if [ $? = 0 ] ; then
                    CURROOTPASSWORD=$answer
                else
                    echoR "root password is incorrect. 1 attempt remaining."
                    printf '\033[31mPlease input the current root password:\033[0m'
                    read answer
                    mysqladmin -uroot -p$answer password $answer
                    if [ $? = 0 ] ; then
                        CURROOTPASSWORD=$answer
                    else
                        echoR "root password is incorrect. 0 attempts remaining."
                        echo
                        TESTPASSWORDERROR=1
                    fi
                fi
            fi
        fi
    fi

    export TESTPASSWORDERROR=$TESTPASSWORDERROR
    if [ "x$TESTPASSWORDERROR" = "x1" ] ; then
        export CURROOTPASSWORD=
    else
        export CURROOTPASSWORD=$CURROOTPASSWORD
    fi
}

function centos_install_mysql
{
    echoB "${FPACE} - Add MariaDB repo"
    local REPOFILE=/etc/yum.repos.d/MariaDB.repo
    if [ ! -f $REPOFILE ] ; then
        local CENTOSVER=
        if [ "$OSTYPE" != "x86_64" ] ; then
            CENTOSVER=centos$OSVER-x86
        else
            CENTOSVER=centos$OSVER-amd64
        fi
        if [ "$OSNAMEVER" = "CENTOS8" ] ; then
            rpm --quiet --import https://downloads.mariadb.com/MariaDB/MariaDB-Server-GPG-KEY
            cat >> $REPOFILE <<END
[mariadb]
name = MariaDB
baseurl = https://downloads.mariadb.com/MariaDB/mariadb-$MARIADBVER/yum/rhel/\$releasever/\$basearch
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY
gpgcheck=1
enabled = 1
module_hotfixes = 1
END
        else
            cat >> $REPOFILE <<END
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/$MARIADBVER/$CENTOSVER
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

END
        fi 
    fi
    echoB "${FPACE} - Install MariaDB"
    if [ "$OSNAMEVER" = "CENTOS8" ] ; then
        silent ${YUM} install -y boost-program-options
        silent ${YUM} --disablerepo=AppStream install -y MariaDB-server MariaDB-client
    else
        silent ${YUM} -y install MariaDB-server MariaDB-client
    fi
    if [ $? != 0 ] ; then
        echoR "An error occured during installation of MariaDB. Please fix this error and try again."
        echoR "You may want to manually run the command '${YUM} -y install MariaDB-server MariaDB-client' to check. Aborting installation!"
        exit 1
    fi
    echoB "${FPACE} - Start MariaDB"
    if [ "$OSNAMEVER" = "CENTOS8" ] || [ "$OSNAMEVER" = "CENTOS7" ] ; then
        silent systemctl enable mariadb
        silent systemctl start  mariadb
    else
        service mysql start
    fi    
}

function debian_install_mysql
{
    echoB "${FPACE} - Install software properties"
    if [ "$OSNAMEVER" = "DEBIAN7" ] ; then
        silent ${APT} -y -f install python-software-properties
        silent apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
    elif [ "$OSNAMEVER" = "DEBIAN8" ] ; then
        silent ${APT} -y -f install software-properties-common
        silent apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
    elif [ "$OSNAMEVER" = "DEBIAN9" ] ; then
        silent ${APT} -y -f install software-properties-common gnupg
        silent apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
    elif [ "$OSNAMEVER" = "DEBIAN10" ] ; then
        silent ${APT} -y -f install software-properties-common gnupg
        silent apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
    elif [ "$OSNAMEVER" = "DEBIAN11" ] ; then
        silent ${APT} -y -f install software-properties-common gnupg
        silent apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
    elif [ "$OSNAMEVER" = "UBUNTU14" ] ; then
        silent ${APT} -y -f install software-properties-common
        silent apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
    elif [ "$OSNAMEVER" = "UBUNTU16" ] ; then
        silent ${APT} -y -f install software-properties-common
        silent apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
    elif [ "$OSNAMEVER" = "UBUNTU18" ] ; then
        silent ${APT} -y -f install software-properties-common
        silent apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
    elif [ "$OSNAMEVER" = "UBUNTU20" ] ; then
        silent ${APT} -y -f install software-properties-common
        silent apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8    
    fi
    echoB "${FPACE} - Add MariaDB repo"
    if [ -e /etc/apt/sources.list.d/mariadb_repo.list ]; then  
        grep -Fq  "http://mirror.jaleco.com/mariadb/repo/" /etc/apt/sources.list.d/mariadb_repo.list >/dev/null 2>&1
        if [ $? != 0 ] ; then
            echo "deb [$MARIADBCPUARCH] http://mirror.jaleco.com/mariadb/repo/$MARIADBVER/$OSNAME $OSVER main"  > /etc/apt/sources.list.d/mariadb_repo.list
        fi
    else 
        echo "deb [$MARIADBCPUARCH] http://mirror.jaleco.com/mariadb/repo/$MARIADBVER/$OSNAME $OSVER main"  > /etc/apt/sources.list.d/mariadb_repo.list    
    fi
    echoB "${FPACE} - Update packages"
    ${APT} update
    echoB "${FPACE} - Install MariaDB"
    silent ${APT} -y -f install mariadb-server
    if [ $? != 0 ] ; then
        echoR "An error occured during installation of MariaDB. Please fix this error and try again."
        echoR "You may want to manually run the command 'apt-get -y -f --allow-unauthenticated install mariadb-server' to check. Aborting installation!"
        exit 1
    fi
    echoB "${FPACE} - Start MariaDB"
    service mysql start
}

function install_mysql
{
    echoG "Start Install MariaDB"
    if [ "$OSNAME" = 'centos' ] ; then
        centos_install_mysql
    else
        debian_install_mysql
    fi
    if [ $? != 0 ] ; then
        echoR "An error occured when starting the MariaDB service. "
        echoR "Please fix this error and try again. Aborting installation!"
        exit 1
    fi

    echoB "${FPACE} - Set MariaDB root"
    mysql -uroot -e "flush privileges;"
    mysqladmin -uroot password $ROOTPASSWORD
    if [ $? = 0 ] ; then
        CURROOTPASSWORD=$ROOTPASSWORD
    else
        #test it is the current password
        mysqladmin -uroot -p$ROOTPASSWORD password $ROOTPASSWORD
        if [ $? = 0 ] ; then
            #echoG "MySQL root password is $ROOTPASSWORD"
            CURROOTPASSWORD=$ROOTPASSWORD
        else
            echoR "Failed to set MySQL root password to $ROOTPASSWORD, it may already have a root password."
            printf '\033[31mInstallation must know the password for the next step.\033[0m'
            test_mysql_password

            if [ "$TESTPASSWORDERROR" = "1" ] ; then
                echoY "If you forget your password you may stop the mysqld service and run the following command to reset it,"
                echoY "mysqld_safe --skip-grant-tables &"
                echoY "mysql --user=root mysql"
                echoY "update user set Password=PASSWORD('new-password') where user='root'; flush privileges; exit; "
                echoR "Aborting installation."
                echo
                exit 1
            fi

            if [ "$CURROOTPASSWORD" != "$ROOTPASSWORD" ] ; then
                echoY "Current MySQL root password is $CURROOTPASSWORD, it will be changed to $ROOTPASSWORD."
                printf '\033[31mDo you still want to change it?[y/N]\033[0m '
                read answer
                echo

                if [ "$answer" != "Y" ] && [ "$answer" != "y" ] ; then
                    echoG "OK, MySQL root password not changed."
                    ROOTPASSWORD=$CURROOTPASSWORD
                else
                    mysqladmin -uroot -p$CURROOTPASSWORD password $ROOTPASSWORD
                    if [ $? = 0 ] ; then
                        echoG "OK, MySQL root password changed to $ROOTPASSWORD."
                    else
                        echoR "Failed to change MySQL root password, it is still $CURROOTPASSWORD."
                        ROOTPASSWORD=$CURROOTPASSWORD
                    fi
                fi
            fi
        fi
    fi
    echoG "End Install MariaDB"
}

function setup_mysql
{
    echoG "Start setup mysql"
    local ERROR=
    #delete user if exists
    mysql -uroot -p$ROOTPASSWORD  -e "DELETE FROM mysql.user WHERE User = '$USERNAME@localhost';"

    echo `mysql -uroot -p$ROOTPASSWORD -e "SELECT user FROM mysql.user"` | grep "$USERNAME" >/dev/null
    if [ $? = 0 ] ; then
        echoG "user $USERNAME exists in mysql.user"
    else
        mysql -uroot -p$ROOTPASSWORD  -e "CREATE USER $USERNAME@localhost IDENTIFIED BY '$USERPASSWORD';"
        if [ $? = 0 ] ; then
            mysql -uroot -p$ROOTPASSWORD  -e "GRANT ALL PRIVILEGES ON *.* TO '$USERNAME'@localhost IDENTIFIED BY '$USERPASSWORD';"
        else
            echoR "Failed to create MySQL user $USERNAME. This user may already exist. If it does not, another problem occured."
            echoR "Please check this and update the wp-config.php file."
            ERROR="Create user error"
        fi
    fi

    mysql -uroot -p$ROOTPASSWORD  -e "CREATE DATABASE IF NOT EXISTS $DATABASENAME;"
    if [ $? = 0 ] ; then
        mysql -uroot -p$ROOTPASSWORD  -e "GRANT ALL PRIVILEGES ON $DATABASENAME.* TO '$USERNAME'@localhost IDENTIFIED BY '$USERPASSWORD';"
    else
        echoR "Failed to create database $DATABASENAME. It may already exist. If it does not, another problem occured."
        echoR "Please check this and update the wp-config.php file."
        if [ "x$ERROR" = "x" ] ; then
            ERROR="Create database error"
        else
            ERROR="$ERROR and create database error"
        fi
    fi
    mysql -uroot -p$ROOTPASSWORD  -e "flush privileges;"

    if [ "x$ERROR" = "x" ] ; then
        echoG "Finished MySQL setup without error."
    else
        echoR "Finished MySQL setup - some error(s) occured."
    fi
    echoG "End setup mysql"
}

function resetmysqlroot
{
    if [ "x$OSNAMEVER" = "xCENTOS8" ]; then
        MYSQLNAME='mariadb'
    else
        MYSQLNAME=mysql
    fi
    service $MYSQLNAME stop
    if [ $? != 0 ] && [ "x$OSNAME" = "xcentos" ] ; then
        service $MYSQLNAME stop
    fi

    DEFAULTPASSWD=$1

    echo "update user set Password=PASSWORD('$DEFAULTPASSWD') where user='root'; flush privileges; exit; " > /tmp/resetmysqlroot.sql
    mysqld_safe --skip-grant-tables &
    #mysql --user=root mysql < /tmp/resetmysqlroot.sql
    mysql --user=root mysql -e "update user set Password=PASSWORD('$DEFAULTPASSWD') where user='root'; flush privileges; exit; "
    sleep 1
    service $MYSQLNAME restart
}

function purgedatabase
{
    if [ "$MYSQLINSTALLED" != "1" ] ; then
        echoY "MySQL-server not installed."
    else
        local ERROR=0
        test_mysql_password

        if [ "$TESTPASSWORDERROR" = "1" ] ; then
            echoR "Failed to purge database."
            echo
            ERROR=1
            ALLERRORS=1
        else
            ROOTPASSWORD=$CURROOTPASSWORD
        fi

        if [ "$ERROR" = "0" ] ; then
            mysql -uroot -p$ROOTPASSWORD  -e "DELETE FROM mysql.user WHERE User = '$USERNAME@localhost';"
            mysql -uroot -p$ROOTPASSWORD  -e "DROP DATABASE IF EXISTS $DATABASENAME;"
            echoY "Database purged."
        fi
    fi
}

function pure_mariadb
{
    if [ "$MYSQLINSTALLED" = "0" ] ; then
        install_mysql
        ROOTPASSWORD=$CURROOTPASSWORD
        setup_mysql        
    else
        echoG 'MariaDB already exist, skip!'
    fi
}

function uninstall_result
{
    if [ "$ALLERRORS" != "0" ] ; then
        echoY "Some error(s) occured. Please check these as you may need to manually fix them."
    fi
    echoCYAN 'End OpenLiteSpeed one click Uninstallation << << << << << << <<'
}


function install_openlitespeed
{
    echoG "Start setup OpenLiteSpeed"
    local STATUS=Install
    if [ "$OLSINSTALLED" = "1" ] ; then
        OLS_VERSION=$(cat "$SERVER_ROOT"/VERSION)
        wget -qO "$SERVER_ROOT"/release.tmp  http://open.litespeedtech.com/packages/release?ver=$OLS_VERSION
        LATEST_VERSION=$(cat "$SERVER_ROOT"/release.tmp)
        rm "$SERVER_ROOT"/release.tmp
        if [ "$OLS_VERSION" = "$LATEST_VERSION" ] ; then
            STATUS=Reinstall
            echoY "OpenLiteSpeed is already installed with the latest version, will attempt to reinstall it."
        else
            STATUS=Update
            echoY "OpenLiteSpeed is already installed and newer version is available, will attempt to update it."
        fi
    fi

    if [ "$OSNAME" = "centos" ] ; then
        install_ols_centos $STATUS
    else
        install_ols_debian $STATUS
    fi
    silent killall -9 lsphp
    echoG "End setup OpenLiteSpeed"
}


function gen_selfsigned_cert
{
    if [ -e $CONFFILE ] ; then
        source $CONFFILE 2>/dev/null
        if [ $? != 0 ]; then
            . $CONFFILE
        fi
    fi

    SSL_COUNTRY="${SSL_COUNTRY:-US}"
    SSL_STATE="${SSL_STATE:-New Jersey}"
    SSL_LOCALITY="${SSL_LOCALITY:-Virtual}"
    SSL_ORG="${SSL_ORG:-LiteSpeedCommunity}"
    SSL_ORGUNIT="${SSL_ORGUNIT:-Testing}"
    SSL_HOSTNAME="${SSL_HOSTNAME:-webadmin}"
    SSL_EMAIL="${SSL_EMAIL:-.}"
    COMMNAME=$(hostname)
    
    cat << EOF > $CSR
[req]
prompt=no
distinguished_name=openlitespeed
[openlitespeed]
commonName = ${COMMNAME}
countryName = ${SSL_COUNTRY}
localityName = ${SSL_LOCALITY}
organizationName = ${SSL_ORG}
organizationalUnitName = ${SSL_ORGUNIT}
stateOrProvinceName = ${SSL_STATE}
emailAddress = ${SSL_EMAIL}
name = openlitespeed
initials = CP
dnQualifier = openlitespeed
[server_exts]
extendedKeyUsage=1.3.6.1.5.5.7.3.1
EOF
    openssl req -x509 -config $CSR -extensions 'server_exts' -nodes -days 820 -newkey rsa:2048 -keyout ${KEY} -out ${CERT} >/dev/null 2>&1
    rm -f $CSR
    
    mv ${KEY}   $SERVER_ROOT/conf/$KEY
    mv ${CERT}  $SERVER_ROOT/conf/$CERT
    chmod 0600 $SERVER_ROOT/conf/$KEY
    chmod 0600 $SERVER_ROOT/conf/$CERT
}


function set_ols_password
{
    ENCRYPT_PASS=`"$SERVER_ROOT/admin/fcgi-bin/admin_php" -q "$SERVER_ROOT/admin/misc/htpasswd.php" $ADMINPASSWORD`
    if [ $? = 0 ] ; then
        echo "admin:$ENCRYPT_PASS" > "$SERVER_ROOT/admin/conf/htpasswd"
        if [ $? = 0 ] ; then
            echoG "Set OpenLiteSpeed Web Admin access."
        else
            echoG "OpenLiteSpeed WebAdmin password not changed."
        fi
    fi
}

function config_server
{
    if [ "$INSTALLWORDPRESS" != "1" ]; then 
        if [ -e "${WEBCF}" ] ; then
            sed -i -e "s/adminEmails/adminEmails $EMAIL\n#adminEmails/" "${WEBCF}"
            sed -i -e "s/8088/$WPPORT/" "${WEBCF}"
            sed -i -e "s/ls_enabled/ls_enabled   1\n#/" "${WEBCF}"

            cat >> ${WEBCF} <<END

listener Defaultssl {
address                 *:$SSLWPPORT
secure                  1
map                     Example *
keyFile                 $SERVER_ROOT/conf/$KEY
certFile                $SERVER_ROOT/conf/$CERT
}

END
            chown -R lsadm:lsadm $SERVER_ROOT/conf/
        else
            echoR "${WEBCF} is missing. It appears that something went wrong during OpenLiteSpeed installation."
            ALLERRORS=1
        fi
        echo ols1clk > "$SERVER_ROOT/PLAT"
    fi
}

function config_vh_wp
{
    echoG 'Start setup virtual host config'
    if [ -e "${WEBCF}" ] ; then
        cat ${WEBCF} | grep "virtualhost wordpress" >/dev/null
        if [ $? != 0 ] ; then
            sed -i -e "s/adminEmails/adminEmails $EMAIL\n#adminEmails/" "${WEBCF}"
            sed -i -e "s/ls_enabled/ls_enabled   1\n#/" "${WEBCF}"

            VHOSTCONF=$SERVER_ROOT/conf/vhosts/wordpress/vhconf.conf
            echoB "${FPACE} - Check existing port"
            grep "address.*:${WPPORT}$\|${SSLWPPORT}$"  ${WEBCF} >/dev/null 2>&1
            if [ ${?} = 0 ]; then
                echoY "Detect port ${WPPORT} || ${SSLWPPORT}, will skip domain setup!"
            else   
                echoB "${FPACE} - Create wordpress listener"  
                cat >> ${WEBCF} <<END

listener wordpress {
address                 *:$WPPORT
secure                  0
map                     wordpress $SITEDOMAIN
}


listener wordpressssl {
address                 *:$SSLWPPORT
secure                  1
map                     wordpress $SITEDOMAIN
keyFile                 $SERVER_ROOT/conf/$KEY
certFile                $SERVER_ROOT/conf/$CERT
}

END
            fi
            echoB "${FPACE} - Insert wordpress virtual host"  
            cat >> ${WEBCF} <<END

virtualhost wordpress {
vhRoot                  $WORDPRESSPATH
configFile              $VHOSTCONF
allowSymbolLink         1
enableScript            1
restrained              0
setUIDMode              2
}
END
            echoB "${FPACE} - Create wordpress virtual host conf"
            mkdir -p $SERVER_ROOT/conf/vhosts/wordpress/
            cat > $VHOSTCONF <<END
docRoot                   \$VH_ROOT/
index  {
  useServer               0
  indexFiles              index.php
}

context / {
  location                \$VH_ROOT
  allowBrowse             1
  indexFiles              index.php

  rewrite  {
    enable                1
    inherit               1
    rewriteFile           $WORDPRESSPATH/.htaccess
  }
}

rewrite  {
  enable                  1
  autoLoadHtaccess        1
}

END
            chown -R lsadm:lsadm $SERVER_ROOT/conf/
        else 
            echoY "${FPACE} - Detect wordpress exist, will skip virtual host conf setup!"
        fi
    else
        echoR "${WEBCF} is missing. It appears that something went wrong during OpenLiteSpeed installation."
        ALLERRORS=1
    fi
    echo ols1clk > "$SERVER_ROOT/PLAT"
    echoG 'End setup virtual host config'
}


function activate_cache
{
    cat > $WORDPRESSPATH/activate_cache.php <<END
<?php
include '$WORDPRESSPATH/wp-load.php';
include_once '$WORDPRESSPATH/wp-admin/includes/plugin.php';
include_once '$WORDPRESSPATH/wp-admin/includes/file.php';
define('WP_ADMIN', true);
activate_plugin('litespeed-cache/litespeed-cache.php', '', false, false);

END
    $SERVER_ROOT/fcgi-bin/lsphpnew $WORDPRESSPATH/activate_cache.php
    rm $WORDPRESSPATH/activate_cache.php
}


function check_cur_status
{
    if [ -e $SERVER_ROOT/bin/openlitespeed ] ; then
        OLSINSTALLED=1
    else
        OLSINSTALLED=0
    fi

    which mysqladmin  >/dev/null 2>&1
    if [ $? = 0 ] ; then
        MYSQLINSTALLED=1
    else
        MYSQLINSTALLED=0
    fi
}

function changeOlsPassword
{
    LSWS_HOME=$SERVER_ROOT
    ENCRYPT_PASS=`"$LSWS_HOME/admin/fcgi-bin/admin_php" -q "$LSWS_HOME/admin/misc/htpasswd.php" $ADMINPASSWORD`
    echo "$ADMIN_USER:$ENCRYPT_PASS" > "$LSWS_HOME/admin/conf/htpasswd"
    echoY "Finished setting OpenLiteSpeed WebAdmin password to $ADMINPASSWORD."
}


function uninstall
{
    if [ "$OLSINSTALLED" = "1" ] ; then
        echoB "${FPACE} - Stop OpenLiteSpeed"
        silent $SERVER_ROOT/bin/lswsctrl stop
        echoB "${FPACE} - Stop LSPHP"
        silent killall -9 lsphp
        if [ "$OSNAME" = "centos" ] ; then
            uninstall_php_centos
            uninstall_ols_centos
        else
            uninstall_php_debian
            uninstall_ols_debian 
        fi
        echoG Uninstalled.
    else
        echoY "OpenLiteSpeed not installed."
    fi
}

function read_password
{
    if [ "$1" != "" ] ; then
        TEMPPASSWORD=$1
    else
        passwd=
        echoY "Please input password for $2(press enter to get a random one):"
        read passwd
        if [ "$passwd" = "" ] ; then
            TEMPPASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 ; echo '')
        else
            TEMPPASSWORD=$passwd
        fi
    fi
}

function check_php_param
{
    if [ "$OSNAMEVER" = "UBUNTU20" ] || [ "$OSNAMEVER" = "UBUNTU18" ] || [ "$OSNAMEVER" = "DEBIAN9" ] || [ "$OSNAMEVER" = "DEBIAN10" ] || [ "$OSNAMEVER" = "DEBIAN11" ]; then
        if [ "$LSPHPVER" = "56" ]; then
            echoY "We do not support lsphp$LSPHPVER on $OSNAMEVER, lsphp73 will be used instead."
            LSPHPVER=80
        fi
    fi
}

function check_value_follow
{
    FOLLOWPARAM=$1
    local PARAM=$1
    local KEYWORD=$2

    if [ "$1" = "-n" ] || [ "$1" = "-e" ] || [ "$1" = "-E" ] ; then
        FOLLOWPARAM=
    else
        local PARAMCHAR=$(echo $1 | awk '{print substr($0,1,1)}')
        if [ "$PARAMCHAR" = "-" ] ; then
            FOLLOWPARAM=
        fi
    fi

    if [ -z "$FOLLOWPARAM" ] ; then
        if [ ! -z "$KEYWORD" ] ; then
            echoR "Error: '$PARAM' is not a valid '$KEYWORD', please check and try again."
            usage
        fi
    fi
}


function fixLangTypo
{
    WP_LOCALE="af ak sq am ar hy rup_MK as az az_TR ba eu bel bn_BD bs_BA bg_BG my_MM ca bal zh_CN \
      zh_HK zh_TW co hr cs_CZ da_DK dv nl_NL nl_BE en_US en_AU 	en_CA en_GB eo et fo fi fr_BE fr_FR \
      fy fuc gl_ES ka_GE de_DE de_CH el gn gu_IN haw_US haz he_IL hi_IN hu_HU is_IS ido id_ID ga it_IT \
      ja jv_ID kn kk km kin ky_KY ko_KR ckb lo lv li lin lt_LT lb_LU mk_MK mg_MG ms_MY ml_IN mr xmf mn \
      me_ME ne_NP nb_NO nn_NO ory os ps fa_IR fa_AF pl_PL pt_BR pt_PT pa_IN rhg ro_RO ru_RU ru_UA rue \
      sah sa_IN srd gd sr_RS sd_PK si_LK sk_SK sl_SI so_SO azb es_AR es_CL es_CO es_MX es_PE es_PR es_ES \
      es_VE su_ID sw sv_SE gsw tl tg tzm ta_IN ta_LK tt_RU te th bo tir tr_TR tuk ug_CN uk ur uz_UZ vi \
      wa cy yor"
    LANGSTR=$(echo "$WPLANGUAGE" | awk '{print tolower($0)}')
    if [ "$LANGSTR" = "zh_cn" ] || [ "$LANGSTR" = "zh-cn" ] || [ "$LANGSTR" = "cn" ] ; then
        WPLANGUAGE=zh_CN
    fi

    if [ "$LANGSTR" = "zh_tw" ] || [ "$LANGSTR" = "zh-tw" ] || [ "$LANGSTR" = "tw" ] ; then
        WPLANGUAGE=zh_TW
    fi
    echo ${WP_LOCALE} | grep -w "${WPLANGUAGE}" -q
    if [ ${?} != 0 ]; then 
        echoR "${WPLANGUAGE} language not found." 
        echo "Please check $WP_LOCALE"
        exit 1
    fi
}

function updatemyself
{
    local CURMD=$(md5sum "$0" | cut -d' ' -f1)
    local SERVERMD=$(md5sum  <(wget $MYGITHUBURL -O- 2>/dev/null)  | cut -d' ' -f1)
    if [ "$CURMD" = "$SERVERMD" ] ; then
        echoG "You already have the latest version installed."
    else
        wget -O "$0" $MYGITHUBURL
        CURMD=$(md5sum "$0" | cut -d' ' -f1)
        if [ "$CURMD" = "$SERVERMD" ] ; then
            echoG "Updated."
        else
            echoG "Tried to update but seems to be failed."
        fi
    fi
    exit 0
}

function uninstall_warn
{
    if [ "$FORCEYES" != "1" ] ; then
        echo
        printf "\033[31mAre you sure you want to uninstall? Type 'Y' to continue, otherwise will quit.[y/N]\033[0m "
        read answer
        echo

        if [ "$answer" != "Y" ] && [ "$answer" != "y" ] ; then
            echoG "Uninstallation aborted!"
            exit 0
        fi
        echo 
    fi
    echoCYAN 'Start OpenLiteSpeed one click Uninstallation >> >> >> >> >> >> >>'
}

function befor_install_display
{
    echo
    echoCYAN "Starting to install OpenLiteSpeed to $SERVER_ROOT/ with the parameters below,"
    echoY "WebAdmin password:        " "$ADMINPASSWORD"
    echoY "WebAdmin email:           " "$EMAIL"
    echoY "LSPHP version:            " "$LSPHPVER"
    echoY "MariaDB version:          " "$MARIADBVER"

    if [ "$INSTALLWORDPRESS" = "1" ] ; then
        echoY "Install WordPress:        " Yes
        echoY "WordPress HTTP port:      " "$WPPORT"
        echoY "WordPress HTTPS port:     " "$SSLWPPORT"
        echoY "WordPress language:       " "$WPLANGUAGE"        
        echoY "Web site domain:          " "$SITEDOMAIN"
        echoY "MySQL root Password:      " "$ROOTPASSWORD"
        echoY "Database name:            " "$DATABASENAME"
        echoY "Database username:        " "$USERNAME"
        echoY "Database password:        " "$USERPASSWORD"

        if [ "$INSTALLWORDPRESSPLUS" = "1" ] ; then
            echoY "WordPress plus:           " Yes
            echoY "WordPress site title:     " "$WPTITLE"
            echoY "WordPress username:       " "$WPUSER"
            echoY "WordPress password:       " "$WPPASSWORD"
        else
            echoY "WordPress plus:           " No
        fi


        if [ -e "$WORDPRESSPATH/wp-config.php" ] ; then
            echoY "WordPress location:       " "$WORDPRESSPATH (Exsiting)"
            WORDPRESSINSTALLED=1
        else
            echoY "WordPress location:       " "$WORDPRESSPATH (New install)"
            WORDPRESSINSTALLED=0
        fi
    else
        echoY "Server HTTP port:         " "$WPPORT"
        echoY "Server HTTPS port:        " "$SSLWPPORT"
    fi
    echoNW "Your password will be written to file:  $SERVER_ROOT/password"
    echo 
    if [ "$FORCEYES" != "1" ] ; then
        printf 'Are these settings correct? Type n to quit, otherwise will continue. [Y/n]'
        read answer
        if [ "$answer" = "N" ] || [ "$answer" = "n" ] ; then
            echoG "Aborting installation!"
            exit 0
        fi
    fi  
    echoCYAN 'Start OpenLiteSpeed one click installation >> >> >> >> >> >> >>'
}

function install_wp_cli
{
    if [ -e /usr/local/bin/wp ] || [ -e /usr/bin/wp ]; then 
        echoG 'WP CLI already exist'
    else    
        echoG "Install wp_cli"
        curl -sO https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
        chmod +x wp-cli.phar
        echo $PATH | grep '/usr/local/bin' >/dev/null 2>&1
        if [ ${?} = 0 ]; then
            mv wp-cli.phar /usr/local/bin/wp
        else
            mv wp-cli.phar /usr/bin/wp
        fi    
    fi
    if [ ! -e /usr/bin/php ] && [ ! -L /usr/bin/php ]; then
        ln -s ${SERVER_ROOT}/lsphp${LSPHPVER}/bin/php /usr/bin/php
    elif [ ! -e /usr/bin/php ]; then 
        rm -f /usr/bin/php
        ln -s ${SERVER_ROOT}/lsphp${LSPHPVER}/bin/php /usr/bin/php    
    else 
        echoG '/usr/bin/php symlink exist, skip symlink.'    
    fi
}

function main_install_wordpress
{
    if [ "${PURE_DB}" = '1' ]; then 
        echoG 'Install MariaDB only'
        pure_mariadb
    else
        if [ "$WORDPRESSINSTALLED" = '1' ] ; then
            echoY 'Skip WordPress installation!'
        else
            if [ "$INSTALLWORDPRESS" = "1" ] ; then
                install_wp_cli
                config_vh_wp
                check_port_usage
                if [ "$MYSQLINSTALLED" != "1" ] ; then
                    install_mysql
                else
                    test_mysql_password
                fi
                if [ "$TESTPASSWORDERROR" = "1" ] ; then
                    echoY "MySQL setup bypassed, can not get root password."
                else
                    ROOTPASSWORD=$CURROOTPASSWORD
                    setup_mysql
                fi
                download_wordpress
                create_wordpress_cf
                if [ "$INSTALLWORDPRESSPLUS" = "1" ] ; then            
                    install_wordpress_core
                    echo "WordPress administrator username is [$WPUSER], password is [$WPPASSWORD]." >> $SERVER_ROOT/password  
                fi
                change_owner ${WORDPRESSPATH}
                echo "mysql WordPress DataBase name is [$DATABASENAME], username is [$USERNAME], password is [$USERPASSWORD]." >> $SERVER_ROOT/password    
                echo "mysql root password is [$ROOTPASSWORD]." >> $SERVER_ROOT/password        
            fi
        fi 
    fi    
}

function check_port_usage
{
    if [ "$WPPORT" = "80" ] || [ "$SSLWPPORT" = "443" ]; then
        echoG "Avoid port 80/443 conflict."
        killall -9 apache  >/dev/null 2>&1
        killall -9 apache2  >/dev/null 2>&1
        killall -9 httpd    >/dev/null 2>&1
        killall -9 nginx    >/dev/null 2>&1
    fi
}

function after_install_display
{
    chmod 600 "$SERVER_ROOT/password"
    if [ "$ALLERRORS" = "0" ] ; then
        echoG "Congratulations! Installation finished."
    else
        echoY "Installation finished. Some errors seem to have occured, please check this as you may need to manually fix them."
    fi
    if [ "$INSTALLWORDPRESSPLUS" = "0" ] && [ "$INSTALLWORDPRESS" = "1" ] && [ "${PURE_DB}" = '0' ]; then
        echo "Please access http://server_IP:$WPPORT/ to finish setting up your WordPress site."
        echo "And also you may want to activate the LiteSpeed Cache plugin to get better performance."
    fi
    echoCYAN 'End OpenLiteSpeed one click installation << << << << << << <<'
    echo
}

function test_page
{
    local URL=$1
    local KEYWORD=$2
    local PAGENAME=$3
    curl -skL  $URL | grep -i "$KEYWORD" >/dev/null 2>&1
    if [ $? != 0 ] ; then
        echoR "Error: $PAGENAME failed."
        TESTGETERROR=yes
    else
        echoG "OK: $PAGENAME passed."
    fi
}

function test_ols_admin
{
    test_page https://localhost:7080/ "LiteSpeed WebAdmin" "test webAdmin page"
}

function test_ols
{
    test_page http://localhost:$WPPORT/  Congratulation "test Example HTTP vhost page"
    test_page https://localhost:$SSLWPPORT/  Congratulation "test Example HTTPS vhost page"
}

function test_wordpress
{
    test_page http://localhost:8088/  Congratulation "test Example vhost page"
    test_page http://localhost:$WPPORT/ "WordPress" "test wordpress HTTP first page"
    test_page https://localhost:$SSLWPPORT/ "WordPress" "test wordpress HTTPS first page"
}

function test_wordpress_plus
{
    test_page http://localhost:8088/  Congratulation "test Example vhost page"
    test_page http://$SITEDOMAIN:$WPPORT/ WordPress "test wordpress HTTP first page"
    test_page https://$SITEDOMAIN:$SSLWPPORT/ WordPress "test wordpress HTTPS first page"
}


function main_ols_test
{
    echoCYAN "Start auto testing >> >> >> >>"
    test_ols_admin
    if [ "${PURE_DB}" = '1' ]; then 
        test_ols
    elif [ "$INSTALLWORDPRESS" = "1" ] ; then
        if [ "$INSTALLWORDPRESSPLUS" = "1" ] ; then
            test_wordpress_plus
        else
            test_wordpress
        fi
    else
        test_ols
    fi

    if [ "${TESTGETERROR}" = "yes" ] ; then
        echoG "Errors were encountered during testing. In many cases these errors can be solved manually by referring to installation logs."
        echoG "Service loading issues can sometimes be resolved by performing a restart of the web server."
        echoG "Reinstalling the web server can also help if neither of the above approaches resolve the issue."
    fi

    echoCYAN "End auto testing << << << <<"
    echoG 'Thanks for using OpenLiteSpeed One click installation!'
    echo
}

function main_init_check
{
    check_root
    check_os
    check_cur_status
    check_php_param
}

function main_init_package
{
    update_centos_hashlib
    update_system
    check_wget
    check_curl
}

function main
{
    display_license
    main_init_check
    action_uninstall
    action_purgeall
    update_email
    main_gen_password
    befor_install_display
    main_init_package
    install_openlitespeed
    main_set_password
    gen_selfsigned_cert
    main_install_wordpress
    config_server
    restart_lsws
    after_install_display
    main_ols_test
}

while [ ! -z "${1}" ] ; do
    case "${1}" in
        -[aA] | --adminpassword )  
                check_value_follow "$2" ""
                if [ ! -z "$FOLLOWPARAM" ] ; then shift; fi
                ADMINPASSWORD=$FOLLOWPARAM
                ;;
        -[eE] | --email )          
                check_value_follow "$2" "email address"
                shift
                EMAIL=$FOLLOWPARAM
                ;;
        --lsphp )           
                check_value_follow "$2" "LSPHP version"
                shift
                cnt=${#LSPHPVERLIST[@]}
                for (( i = 0 ; i < cnt ; i++ )); do
                    if [ "$1" = "${LSPHPVERLIST[$i]}" ] ; then LSPHPVER=$1; fi
                done
                ;;
        --mariadbver )      
                check_value_follow "$2" "MariaDB version"
                shift
                cnt=${#MARIADBVERLIST[@]}
                for (( i = 0 ; i < cnt ; i++ )); do 
                    if [ "$1" = "${MARIADBVERLIST[$i]}" ] ; then MARIADBVER=$1; fi 
                done
                ;;
        --pure-mariadb )
                PURE_DB=1
                ;;        
        -[wW] | --wordpress )      
                INSTALLWORDPRESS=1
                ;;
        --wordpressplus )  
                check_value_follow "$2" "domain"
                shift
                SITEDOMAIN=$FOLLOWPARAM
                INSTALLWORDPRESS=1
                INSTALLWORDPRESSPLUS=1
                ;;
        --wordpresspath )  
                check_value_follow "$2" "WordPress path"
                shift
                WORDPRESSPATH=$FOLLOWPARAM
                INSTALLWORDPRESS=1
                ;;
        -[rR] | --dbrootpassword ) 
                check_value_follow "$2" ""
                if [ ! -z "$FOLLOWPARAM" ] ; then shift; fi
                ROOTPASSWORD=$FOLLOWPARAM
                ;;
        --dbname )         
                check_value_follow "$2" "database name"
                shift
                DATABASENAME=$FOLLOWPARAM
                ;;
        --dbuser )         
                check_value_follow "$2" "database username"
                shift
                USERNAME=$FOLLOWPARAM
                ;;
        --dbpassword )     
                check_value_follow "$2" ""
                if [ ! -z "$FOLLOWPARAM" ] ; then shift; fi
                USERPASSWORD=$FOLLOWPARAM
                ;;
        --listenport )      
                check_value_follow "$2" "HTTP listen port"
                shift
                WPPORT=$FOLLOWPARAM
                ;;
        --ssllistenport )   
                check_value_follow "$2" "HTTPS listen port"
                shift
                SSLWPPORT=$FOLLOWPARAM
                ;;
        --wpuser )          
               check_value_follow "$2" "WordPress user"
                shift
                WPUSER=$1
                ;;
        --wppassword )      
                check_value_follow "$2" ""
                if [ ! -z "$FOLLOWPARAM" ] ; then shift; fi
                WPPASSWORD=$FOLLOWPARAM
                ;;
        --wplang )          
                check_value_follow "$2" "WordPress language"
                shift
                WPLANGUAGE=$FOLLOWPARAM
                fixLangTypo
                ;;
        --sitetitle )       
                check_value_follow "$2" "WordPress website title"
                shift
                WPTITLE=$FOLLOWPARAM
                ;;
        -[Uu] | --uninstall )       
                ACTION=UNINSTALL
                ;;
        -[Pp] | --purgeall )        
                ACTION=PURGEALL
                ;;
        -[qQ] | --quiet )           
                FORCEYES=1
                ;;
        -V | --version )     
                display_license
                exit 0
                ;;
        --update )         
                updatemyself
                ;;
        -v | --verbose )             
                VERBOSE=1
                APT='apt-get'
                YUM='yum'
                ;;
        -[hH] | --help )           
                usage
                ;;
        * )                     
                usage
                ;;
    esac
    shift
done

main

./vhsetup.sh php: command not found

Using Ubuntu 20.04 on Hetzner Cloud
Just after I install with ./ols1clk.sh

My command:

./vhsetup.sh -d site.com
./vhsetup.sh: line 139: php: command not found
./vhsetup.sh: line 140: php: command not found
Vhost created success!
Setup finished!

help me

Start OpenLiteSpeed one click installation >> >> >> >> >> >> >>
System update
Start setup OpenLiteSpeed
- add litespeedtech repo
- update list
E: Malformed entry 1 in list file /etc/apt/sources.list.d/lst_debian_repo.list (Component)
E: The list of sources could not be read.
- Install OpenLiteSpeed
An error occured during OpenLiteSpeed installation.
- Install lsphp73
An error occured during lsphp73 installation.
- Setup lsphp symlink
End setup OpenLiteSpeed
ols1clk.sh: line 623: /usr/local/lsws/password: No such file or directory
ols1clk.sh: line 1033: /usr/local/lsws/admin/fcgi-bin/admin_php: No such file or directory
mv: cannot move 'example.key' to '/usr/local/lsws/conf/example.key': No such file or directory
mv: cannot move 'example.crt' to '/usr/local/lsws/conf/example.crt': No such file or directory
chmod: cannot access '/usr/local/lsws/conf/example.key': No such file or directory
chmod: cannot access '/usr/local/lsws/conf/example.crt': No such file or directory
WP CLI already exist
Start setup virtual host config
/usr/local/lsws/conf/httpd_config.conf is missing. It appears that something went wrong during OpenLiteSpeed installation.
ols1clk.sh: line 1154: /usr/local/lsws/PLAT: No such file or directory
End setup virtual host config
Avoid port 80/443 conflict.
Start Install MariaDB
- Install software properties
- Add MariaDB repo
- Update packages
E: Malformed entry 1 in list file /etc/apt/sources.list.d/lst_debian_repo.list (Component)
E: Malformed entry 1 in list file /etc/apt/sources.list.d/mariadb_repo.list (Component)
E: The list of sources could not be read.
- Install MariaDB
An error occured during installation of MariaDB. Please fix this error and try again.
You may want to manually run the command 'apt-get -y -f --allow-unauthenticated install mariadb-server' to check. Aborting installation!

WebAdmin Password Generation

Upon installation on CentOS 7, randomly generated admin password often does not work at login page. Temporarily patched over using -a option at install or admpass.sh in admin/misc

Some tips

1、hope can choose the mysql version and install path.
2、support jemalloc
3、support letsencrypt
Thanks!

--wordpresspath missing on vhsetup.sh

While it's possible to set a path for the wordpress install on the ols1clk, this is apparently not possible when we want to add a second site via the vhsetup.sh script.

The vhsetup.sh script should support the same wordpress customizations as the the ols1clk script.

on CentOS8 it is not working

such as

yum -y install python-hashlib
Last metadata expiration check: 0:05:17 ago on Mon 27 Apr 2020 04:05:29 PM UTC.
No match for argument: python-hashlib
Error: Unable to find a match: python-hashlib

even if it finish with this message

Please be aware that your password was written to file '/usr/local/lsws/password'.
Congratulations! Installation finished.

Testing ...
OK: test webAdmin page passed.
OK: test Example HTTP vhost page passed.
OK: test Example HTTPS vhost page passed.

If you run into any problems, they can sometimes be fixed by running with the --purgeall flag and reinstalling.
If you have an existing certificate and private key for your site, you will need to replace the example.key and example.crt in /usr/local/lsws/conf with these files.
Thanks for using "OpenLiteSpeed One click installation".
Enjoy!

even after a reboot

port 80, 443, 7080 and 8088 are not accessible

ps aux|grep ls

root      1146  0.0  0.4  79348  8736 ?        S    16:09   0:00 openlitespeed (lshttpd - main)
root      1152  0.0  0.0  41120  1132 ?        S    16:09   0:00 openlitespeed (lscgid)
nobody    1155  0.0  0.3  80644  6292 ?        S    16:09   0:00 openlitespeed (lshttpd - #01)
root      1297  0.0  0.0  12108  1024 pts/0    R+   16:15   0:00 grep --color=auto ls

note ps aux|grep php return nothing

cat /usr/local/lsws/logs/error.log

2020-04-27 16:09:59.003150 [NOTICE] [Child: 1155] LiteSpeed/1.6.12 Open
	module versions:
	modgzip 1.1
	cache 1.62
	modinspector 1.1
	uploadprogress 1.1
	mod_security 1.3
 starts successfully!

Additional flags and settings for vhost?

Hi,

I setup OLS with percona and then I am trying to add a new host.
For that I am using:

/bin/bash <( curl -sk https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Setup/vhsetup.sh ) -d dev.example.com -le [email protected] -f --path /home/sites/dev.example.com/www

However, I would also like to be able to:

a) specify a flag to create a database (optional flag) as well as database name, password, host and port.

There is the wordpress option, but not all the time we need to install wordpress while still needing to create a database.
Some other times we just need the virtual host, so creating a database should be optional.

I think an option to create databases and credentials would be useful, and at the same time the options to specify a host and port are also useful when we use a remote server or a service like AWS RDS for example.

b) specify a group and user for the files and suEXEC

On Virtual Host > Security
There are options for:
Follow Symbolic Link | Yes
Enable Scripts/ExtApps | Yes
Restrained | Yes
External App Set UID Mode | DocRoot UID
suEXEC User | myusername
suEXEC Group | myusergroup

This would improve security, if a user/group is specified, else default settings.
Changing this would require changing the ownership and permissions of that directory to match.

c) In addition to --path we should be able to specify --root (or change the --path behaviour)

Currently, --path defines the Virtual Host Root, but according to the help section "This is NOT the document root. It is recommended to place all files related to the virtual host (like log files, html files, CGI scripts, etc.) under this directory. Virtual Host Root can be referred to using the variable $VH_ROOT."

So, we could do --root /home/sites/dev.example.com --path /www for example.

Or just stay as --path /home/sites/dev.example.com and later append /www to the Document Root

By using the last one, you could also set the logs directory to /home/sites/dev.example.com/logs for example, or add another --logs (or similar) option to set the path.

If this is something you can implement, it would be great!

Thank you

Database create is failing

I'm getting this error:
/bin/bash <( curl -sk https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Setup/vhsetup.sh ) -d www.wp-example.com -w
Current platform is
Vhost created success!
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
something went wrong when create new database, please proceed to manual installtion.
Setup finished!

If I run the script without -w flag and don't create DB it passes. It fails during DB create by the looks of it.

The weird thing is on local vm server it works, however, on production it throws this error.
Any clarification about the error will be of help.

Please decouple igbinary from php memcached package

If one wants to install php memcached yum package on CentOS7 but doesn't want php igbinary, they can't due to dependency issues. Maybe have a separate lsphpXX-pecl-memcached-igbinary package for such and leave lsphpXX-pecl-memcached package without igbinary ?

same with lsphpXX-pecl-redis

Error: Package: lsphp56-pecl-redis-2.2.7-1.el7.centos.x86_64 (litespeed)
           Requires: lsphp56-pecl-igbinary(x86-64)
Error: Package: lsphp56-pecl-memcached-5.6.24-2.el7.centos.x86_64 (litespeed-update)
           Requires: lsphp56-pecl-igbinary(x86-64)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
An error occured during openlitespeed installation.

fresh server

Would I need to install anything, or can I execute this script straight away?

I tried without modifying anything on server or script, i can access webadmin page but wont let me login.

Multiple issues and requests

1: Installing Certbot by default
The readme mentions installing Certbot to use '-le' on "vhsetup.sh". It would be better to install it by default with ols1clk.sh

2: Restarting LSWS
The function "restart_lsws" does "systemctl stop lsws" and "systemctl start lsws". This is a problem specifically for Production servers where stopping the webserver can cause issues if the webserver is processing some request. AFAIK "systemctl restart lsws" does a graceful restart without any downtime and it does the same thing as stopping and starting the service. This is also an issue on vhsetup.sh where it adds an extra command "${LSDIR}/bin/lswsctrl stop" including the ones above. "systemctl restart lsws" is just plain better. The "current restart_lsws" function on both the scripts also creates a problem where if I use WP-CLI right after using the script(s), the WordPress site just goes into "ERR TOO MANY REDIRECTS" mode permanently

Ref: https://openlitespeed.org/kb/command-references-for-administration/

3: Default PHP.ini values too low
I run the below commands to increase some values of PHP that are recommended by most WordPress themes and plugins

sed -i 's|memory_limit = 128M|memory_limit = 256M|g' ${PHP_INI_LOCATION}
sed -i 's|max_execution_time = 30|max_execution_time = 120|g' ${PHP_INI_LOCATION}
sed -i 's|max_input_time = 60|max_input_time = 120|g' ${PHP_INI_LOCATION}
sed -i 's|;max_input_vars = 1000|max_input_vars = 10000|g' ${PHP_INI_LOCATION}
sed -i 's|post_max_size = 8M|post_max_size = 16M|g' ${PHP_INI_LOCATION}
sed -i 's|upload_max_filesize = 2M|upload_max_filesize = 16M|g' ${PHP_INI_LOCATION}

4: Installing an object cache by default
Since LSCACHE plugin already has object cache functionality it would be better to just install redis/keydb (2x faster redis implementation) by default

5: Installing Postfix by default since email is a big part of Wordpress

6: SSL fails to install when using Cloudflare (vhsetup.sh)
When the proxy is on in Cloudflare DNS it fails because it is trying to find "Litespeed" in the headers. This is an easy fix.

7: Allow a user to install Woocommerce from the script itself

8: Allow a user to delete useless themes and plugins by default

I can create PRs for all of this on vhsetup.sh if you want but it will take some time. And it would be amazing if there is a consumer friendly version of this like WordOps or EasyEngine but for OLS

Add support for Percona Server for MySQL

While MySQL and MariaDB are great, I (personally) find that Percona usually performs better for high concurrency.
I would like to suggest including it as an alternative on the ols1clk script, as it's basically a drop off replacement like MariaDB.
https://docs.percona.com/percona-server/8.0/installation.html

Script fails due to repo script no longer working

the os1click script when it goes to add the repo gets garbage data
https://github.com/litespeedtech/ols1clk/blob/master/ols1clk.sh#L427

root@openlitespeedtest:~# wget -q -O - https://repo.litespeed.sh/ | sudo bash
bash: line 1: syntax error near unexpected token `newline'
bash: line 1: `<!DOCTYPE html>'
root@openlitespeedtest:~#

Why not inline the repos adding so it can't suddenly fail?

Checking wayback machine it has a script vs an upsell website
http://web.archive.org/web/20230319062507/https://repo.litespeed.sh/

Downloads the proper bootstrap script

#!/usr/bin/env sh

# RHEL:
# CentOS 7 + 8
# Oracle Linux 7 + 8
# RHEL 7 + 8
# AlmaLinux
# Rocky Linux
# VZLinux
# CloudLinux

# Ubuntu:
# Ubuntu 18.04, 20.04
# Debian 9, 10, 11

detect_os () {
  if [ -f '/etc/os-release' ] ; then
    REPO_OS=$(cat /etc/os-release |  grep '^ID=' | head -n1 | awk -F '=' '{print $2}' | tr -d '"')
    REPO_VER=$(cat /etc/os-release |  grep '^VERSION_ID=' | head -n1 | awk -F '=' '{print $2}' | tr -d '"')
    if [ "${REPO_OS}" = 'debian' ] || [ "${REPO_OS}" = 'ubuntu' ] ; then
      REPO_OS_CODENAME=$(cat /etc/os-release |  grep '^VERSION_CODENAME=' | head -n1 | awk -F '=' '{print $2}' | tr -d '"')
    fi
  elif [ -f '/etc/redhat-release' ] ; then
    REPO_OS=$(cat /etc/redhat-release | awk '{print $1}' | tr '[:upper:]' '[:lower:]')
    REPO_VER=$(cat /etc/redhat-release | grep -Eo '[0-9]+([.][0-9]+)?([.][0-9]+)?')
  elif [ -f '/etc/lsb-release' ] ; then
    REPO_OS=$(cat /etc/lsb-release | grep '^DISTRIB_ID=' | awk -F '=' '{print $2}')
    REPO_VER=$(cat /etc/lsb-release | grep '^DISTRIB_RELEASE=' | awk -F '=' '{print $2}')
    REPO_OS_CODENAME=$(cat /etc/lsb-release | grep '^DISTRIB_CODENAME=' | awk -F '=' '{print $2}')
  else
    echo 'Cannot detect the operating system!'
    exit 1
  fi

  if [ "${REPO_OS}" = 'centos' ] || [ "${REPO_OS}" = 'rhel' ] || [ "${REPO_OS}" = 'rocky' ] || [ "${REPO_OS}" = 'almalinux' ] || [ "${REPO_OS}" = 'oracle' ] || [ "${REPO_OS}" = 'redhat' ] || [ "${REPO_OS}" = 'virtuozzo' ] || [ "${REPO_OS}" = 'cloudlinux' ] ; then
    REPO_BASE_OS='epel'
    REPO_OS_VER=$(echo ${REPO_VER} | cut -c1-1)
  elif [ "${REPO_OS}" = 'debian' ] || [ "${REPO_OS}" = 'ubuntu' ] ; then
    REPO_BASE_OS='debian'
  else
    echo "Non-supported operating system: ${REPO_OS}"
    exit 1
  fi

  REPO_ARCH=$(uname -m)
  if [ "${REPO_ARCH}" != 'x86_64' ] ; then
    echo "Non-supported architecture: ${REPO_ARCH}"
    exit 1
  fi
}

check_install () {
  if [ "${REPO_BASE_OS}" = 'epel' ] ; then
    if [ -f '/etc/yum.repos.d/litespeed.repo' ] ; then
      echo 'LiteSpeed repository already setup!'
      exit 1
    fi
  elif [ "${REPO_BASE_OS}" = 'debian' ] ; then
    if [ -f '/etc/apt/sources.list.d/lst_debian_repo.list' ] ; then
      echo 'LiteSpeed repository already setup!'
      exit 1
    fi
  fi
}

clean_install () {
  if [ "${REPO_BASE_OS}" = 'epel' ] ; then
    if [ -f '/etc/yum.repos.d/litespeed.repo' ] ; then
      rm -f /etc/pki/rpm-gpg/RPM-GPG-KEY-litespeed
      rm -f //etc/yum.repos.d/litespeed.repo
      echo 'LiteSpeed repository has been removed!'
      exit 0
    fi
  elif [ "${REPO_BASE_OS}" = 'debian' ] ; then
    if [ -f '/etc/apt/sources.list.d/lst_debian_repo.list' ] ; then
      rm -f /etc/apt/trusted.gpg.d/lst_debian_repo.gpg
      rm -f /etc/apt/trusted.gpg.d/lst_repo.gpg
      rm -f /etc/apt/sources.list.d/lst_debian_repo.list
      echo 'LiteSpeed repository has been removed!'
      exit 0
    fi
  fi
}

setup_rhel () {
  # Install the GPG key
  pushd /tmp/
  curl -O https://rpms.litespeedtech.com/centos/RPM-GPG-KEY-litespeed
  mv RPM-GPG-KEY-litespeed /etc/pki/rpm-gpg/RPM-GPG-KEY-litespeed
  popd

  # Install the repo file
  cat <<EOF >> /etc/yum.repos.d/litespeed.repo
[litespeed]
name=LiteSpeed Tech Repository for CentOS ${REPO_OS_VER} - ${REPO_ARCH}
baseurl=http://rpms.litespeedtech.com/centos/${REPO_OS_VER}/${REPO_ARCH}/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-litespeed

[litespeed-update]
name=LiteSpeed Tech Update Repository for CentOS ${REPO_OS_VER} - ${REPO_ARCH}
baseurl=http://rpms.litespeedtech.com/centos/${REPO_OS_VER}/update/${REPO_ARCH}/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-litespeed

[litespeed-edge]
name=LiteSpeed Tech Edge Repository for CentOS ${REPO_OS_VER} - ${REPO_ARCH}
baseurl=http://rpms.litespeedtech.com/edge/centos/${REPO_OS_VER}/${REPO_ARCH}/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-litespeed
EOF

  echo 'LiteSpeed repository has been setup!'
}

setup_debian () {
  wget -O /etc/apt/trusted.gpg.d/lst_debian_repo.gpg http://rpms.litespeedtech.com/debian/lst_debian_repo.gpg
  wget -O /etc/apt/trusted.gpg.d/lst_repo.gpg http://rpms.litespeedtech.com/debian/lst_repo.gpg

  echo "deb http://rpms.litespeedtech.com/debian/ ${REPO_OS_CODENAME} main" > /etc/apt/sources.list.d/lst_debian_repo.list
  echo "#deb http://rpms.litespeedtech.com/edge/debian/ ${REPO_OS_CODENAME} main" >> /etc/apt/sources.list.d/lst_debian_repo.list

  echo 'LiteSpeed repository has been setup!'
}

main () {
  detect_os

  if [ "${1}" = 'clean' ] ; then
    clean_install
  fi

  check_install

  if [ "${REPO_BASE_OS}" = 'epel' ] ; then
    setup_rhel
  elif [ "${REPO_BASE_OS}" = 'debian' ] ; then
    setup_debian
  fi
}

main "$@"
exit 0

Really seems shortsighted of the upstream url to change so drastically to be a splashpage from the install script without warning and all documentation still references this script as the right one to install

broken

Seems like this no longer works properly. when using it i always get the error that php is missing mysql extension but its installed. used to work fine.

script doesn't install memcached package

script only install memcached php extension and it doesn't install memcached package.

Screenshot 2023-09-02 180030

Screenshot 2023-09-02 180200

it can be simply fixed by manually installing and enabling memcached package

yum install memcached -y

systemctl start memcached

systemctl enable memcached

Screenshot 2023-09-02 180302

image

Support Debian 11

`
#!/bin/bash
##############################################################################

Open LiteSpeed is an open source HTTP server.

Copyright (C) 2013 - 2021 LiteSpeed Technologies, Inc.

This program is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program. If not, see http://www.gnu.org/licenses/.

##############################################################################

Author: [email protected] (David Shue)

TEMPRANDSTR=
OSNAMEVER=UNKNOWN
OSNAME=
OSVER=
OSTYPE=$(uname -m)
MARIADBCPUARCH=
SERVER_ROOT=/usr/local/lsws
WEBCF="$SERVER_ROOT/conf/httpd_config.conf"
OLSINSTALLED=
MYSQLINSTALLED=
TESTGETERROR=no
DATABASENAME=olsdbname
USERNAME=olsdbuser
VERBOSE=0
PURE_DB=0
WORDPRESSPATH=$SERVER_ROOT/wordpress
WPPORT=80
SSLWPPORT=443
WORDPRESSINSTALLED=
INSTALLWORDPRESS=0
INSTALLWORDPRESSPLUS=0
FORCEYES=0
WPLANGUAGE=en_US
WPUSER=wpuser
WPTITLE=MySite
SITEDOMAIN=*
EMAIL=
ADMINPASSWORD=
ROOTPASSWORD=
USERPASSWORD=
WPPASSWORD=
LSPHPVERLIST=(56 70 71 72 73 74 80)
MARIADBVERLIST=(10.2 10.3 10.4 10.5 10.6)
LSPHPVER=80
MARIADBVER=10.6
WEBADMIN_LSPHPVER=80
ALLERRORS=0
TEMPPASSWORD=
ACTION=INSTALL
FOLLOWPARAM=
CONFFILE=myssl.conf
CSR=example.csr
KEY=example.key
CERT=example.crt
EPACE=' '
FPACE=' '
APT='apt-get -qq'
YUM='yum -q'
MYGITHUBURL=https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh

function echoY
{
FLAG=$1
shift
echo -e "\033[38;5;148m$FLAG\033[39m$@"
}

function echoG
{
FLAG=$1
shift
echo -e "\033[38;5;71m$FLAG\033[39m$@"
}

function echoB
{
FLAG=$1
shift
echo -e "\033[38;1;34m$FLAG\033[39m$@"
}

function echoR
{
FLAG=$1
shift
echo -e "\033[38;5;203m$FLAG\033[39m$@"
}

function echoW
{
FLAG=${1}
shift
echo -e "\033[1m${EPACE}${FLAG}\033[0m${@}"
}

function echoNW
{
FLAG=${1}
shift
echo -e "\033[1m${FLAG}\033[0m${@}"
}

function echoCYAN
{
FLAG=$1
shift
echo -e "\033[1;36m$FLAG\033[0m$@"
}

function silent
{
if [ "${VERBOSE}" = '1' ] ; then
"$@"
else
"$@" >/dev/null 2>&1
fi
}

function change_owner
{
chown -R ${USER}:${GROUP} ${1}
}

function check_root
{
local INST_USER=id -u
if [ $INST_USER != 0 ] ; then
echoR "Sorry, only the root user can install."
echo
exit 1
fi
}

function update_system(){
echoG 'System update'
if [ "$OSNAME" = "centos" ] ; then
silent ${YUM} update -y >/dev/null 2>&1
else
silent ${APT} update && ${APT} upgrade -y >/dev/null 2>&1
fi
}

function check_wget
{
which wget >/dev/null 2>&1
if [ $? != 0 ] ; then
if [ "$OSNAME" = "centos" ] ; then
silent ${YUM} -y install wget
else
${APT} -y install wget
fi
which wget >/dev/null 2>&1
if [ $? != 0 ] ; then
echoR "An error occured during wget installation."
ALLERRORS=1
fi
fi
}

function check_curl
{
which curl >/dev/null 2>&1
if [ $? != 0 ] ; then
if [ "$OSNAME" = "centos" ] ; then
silent ${YUM} -y install curl
else
${APT} -y install curl
fi
which curl >/dev/null 2>&1
if [ $? != 0 ] ; then
echoR "An error occured during curl installation."
ALLERRORS=1
fi
fi
}

function update_email
{
if [ "$EMAIL" = '' ] ; then
if [ "$SITEDOMAIN" = "*" ] ; then
EMAIL=root@localhost
else
EMAIL=root@$SITEDOMAIN
fi
fi
}

function restart_lsws
{
systemctl stop lsws >/dev/null 2>&1
systemctl start lsws
}

function usage
{
echo -e "\033[1mOPTIONS\033[0m"
echoNW " -A, --adminpassword [PASSWORD]" "${EPACE}To set the WebAdmin password for OpenLiteSpeed instead of using a random one."
echoNW " -E, --email [EMAIL] " "${EPACE} To set the administrator email."
echoW " --lsphp [VERSION] " "To set the LSPHP version, such as 80. We currently support versions '${LSPHPVERLIST[@]}'."
echoW " --mariadbver [VERSION] " "To set MariaDB version, such as 10.5. We currently support versions '${MARIADBVERLIST[@]}'."
echoNW " -W, --wordpress " "${EPACE} To install WordPress. You will still need to complete the WordPress setup by browser"
echoW " --wordpressplus [SITEDOMAIN] " "To install, setup, and configure WordPress, also LSCache will be enabled"
echoW " --wordpresspath [WP_PATH] " "To specify a location for the new WordPress installation or an existing WordPress."
echoNW " -R, --dbrootpassword [PASSWORD] " " To set the database root password instead of using a random one."
echoW " --dbname [DATABASENAME] " "To set the database name to be used by WordPress."
echoW " --dbuser [DBUSERNAME] " "To set the WordPress username in the database."
echoW " --dbpassword [PASSWORD] " "To set the WordPress table password in MySQL instead of using a random one."
echoW " --listenport [PORT] " "To set the HTTP server listener port, default is 80."
echoW " --ssllistenport [PORT] " "To set the HTTPS server listener port, default is 443."
echoW " --wpuser [WORDPRESSUSER] " "To set the WordPress admin user for WordPress dashboard login. Default value is wpuser."
echoW " --wppassword [PASSWORD] " "To set the WordPress admin user password for WordPress dashboard login."
echoW " --wplang [WP_LANGUAGE] " "To set the WordPress language. Default value is "en_US" for English."
echoW " --sitetitle [WP_TITLE] " "To set the WordPress site title. Default value is mySite."
echoNW " -U, --uninstall " "${EPACE} To uninstall OpenLiteSpeed and remove installation directory."
echoNW " -P, --purgeall " "${EPACE} To uninstall OpenLiteSpeed, remove installation directory, and purge all data in MySQL."
echoNW " -Q, --quiet " "${EPACE} To use quiet mode, won't prompt to input anything."
echoNW " -V, --version " "${EPACE} To display the script version information."
echoNW " -v, --verbose " "${EPACE} To display more messages during the installation."
echoW " --update " "To update ols1clk from github."
echoNW " -H, --help " "${EPACE} To display help messages."
echo
echo -e "\033[1mEXAMPLES\033[0m"
echoW "./ols1clk.sh " "To install OpenLiteSpeed with a random WebAdmin password."
echoW "./ols1clk.sh --lsphp 80 " "To install OpenLiteSpeed with lsphp80."
echoW "./ols1clk.sh -A 123456 -e [email protected] " "To install OpenLiteSpeed with WebAdmin password "123456" and email [email protected]."
echoW "./ols1clk.sh -R 123456 -W " "To install OpenLiteSpeed with WordPress and MySQL root password "123456"."
echoW "./ols1clk.sh --wordpressplus a.com " "To install OpenLiteSpeed with a fully configured WordPress installation at "a.com"."
echo
exit 0
}

function display_license
{
echoY ''
echoY '
Open LiteSpeed One click installation, Version 3.0 '
echoY '
Copyright (C) 2016 - 2021 LiteSpeed Technologies, Inc. '
echoY '
'
}

function check_os
{
if [ -f /etc/redhat-release ] ; then
OSNAME=centos
USER='nobody'
GROUP='nobody'
case $(cat /etc/centos-release | tr -dc '0-9.'|cut -d . -f1) in
6)
OSNAMEVER=CENTOS6
OSVER=6
;;
7)
OSNAMEVER=CENTOS7
OSVER=7
;;
8)
OSNAMEVER=CENTOS8
OSVER=8
;;
esac
elif [ -f /etc/lsb-release ] ; then
OSNAME=ubuntu
USER='nobody'
GROUP='nogroup'
case $(cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2) in
trusty)
OSNAMEVER=UBUNTU14
OSVER=trusty
MARIADBCPUARCH="arch=amd64,i386,ppc64el"
;;
xenial)
OSNAMEVER=UBUNTU16
OSVER=xenial
MARIADBCPUARCH="arch=amd64,i386,ppc64el"
;;
bionic)
OSNAMEVER=UBUNTU18
OSVER=bionic
MARIADBCPUARCH="arch=amd64"
;;
focal)
OSNAMEVER=UBUNTU20
OSVER=focal
MARIADBCPUARCH="arch=amd64"
;;
esac
elif [ -f /etc/debian_version ] ; then
OSNAME=debian
case $(cat /etc/os-release | grep VERSION_CODENAME | cut -d = -f 2) in
wheezy)
OSNAMEVER=DEBIAN7
OSVER=wheezy
MARIADBCPUARCH="arch=amd64,i386"
;;
jessie)
OSNAMEVER=DEBIAN8
OSVER=jessie
MARIADBCPUARCH="arch=amd64,i386"
;;
stretch)
OSNAMEVER=DEBIAN9
OSVER=stretch
MARIADBCPUARCH="arch=amd64,i386"
;;
buster)
OSNAMEVER=DEBIAN10
OSVER=buster
MARIADBCPUARCH="arch=amd64,i386"
;;
bullseye)
OSNAMEVER=DEBIAN11
OSVER=bullseye
MARIADBCPUARCH="arch=amd64,i386"
;;
esac
fi
if [ "$OSNAMEVER" = '' ] ; then
echoR "Sorry, currently one click installation only supports Centos(6-8), Debian(7-10) and Ubuntu(14,16,18,20)."
echoR "You can download the source code and build from it."
echoR "The url of the source code is https://github.com/litespeedtech/openlitespeed/releases."
exit 1
else
if [ "$OSNAME" = "centos" ] ; then
echoG "Current platform is " "$OSNAME $OSVER."
else
export DEBIAN_FRONTEND=noninteractive
echoG "Current platform is " "$OSNAMEVER $OSNAME $OSVER."
fi
fi
}

function update_centos_hashlib
{
if [ "$OSNAME" = 'centos' ] ; then
silent ${YUM} -y install python-hashlib
fi
}

function install_ols_centos
{
local action=install
if [ "$1" = "Update" ] ; then
action=update
elif [ "$1" = "Reinstall" ] ; then
action=reinstall
fi

local JSON=
if [ "x$LSPHPVER" = "x70" ] || [ "x$LSPHPVER" = "x71" ] || [ "x$LSPHPVER" = "x72" ] || [ "x$LSPHPVER" = "x73" ] || [ "x$LSPHPVER" = "x74" ]; then
    JSON=lsphp$LSPHPVER-json
fi
echoB "${FPACE} - add epel repo"
silent ${YUM} -y $action epel-release
echoB "${FPACE} - add litespeedtech repo"
rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el$OSVER.noarch.rpm >/dev/null 2>&1
echoB "${FPACE} - $1 OpenLiteSpeed"
silent ${YUM} -y $action openlitespeed
if [ ! -e $SERVER_ROOT/lsphp$LSPHPVER/bin/lsphp ] ; then
    action=install
fi
echoB "${FPACE} - $1 lsphp$LSPHPVER"
if [ "$action" = "reinstall" ] ; then
    silent ${YUM} -y remove lsphp$LSPHPVER-mysqlnd
fi
silent ${YUM} -y install lsphp$LSPHPVER-mysqlnd
if [ "$LSPHPVER" = "80" ]; then 
    silent ${YUM} -y $action lsphp$LSPHPVER lsphp$LSPHPVER-common lsphp$LSPHPVER-gd lsphp$LSPHPVER-process lsphp$LSPHPVER-mbstring \
    lsphp$LSPHPVER-xml lsphp$LSPHPVER-pdo lsphp$LSPHPVER-imap
else
    silent ${YUM} -y $action lsphp$LSPHPVER lsphp$LSPHPVER-common lsphp$LSPHPVER-gd lsphp$LSPHPVER-process lsphp$LSPHPVER-mbstring \
    lsphp$LSPHPVER-xml lsphp$LSPHPVER-mcrypt lsphp$LSPHPVER-pdo lsphp$LSPHPVER-imap $JSON
fi
echoB "${FPACE} - Setup lsphp symlink"
if [ $? != 0 ] ; then
    echoR "An error occured during OpenLiteSpeed installation."
    ALLERRORS=1
else
    ln -sf $SERVER_ROOT/lsphp$LSPHPVER/bin/lsphp $SERVER_ROOT/fcgi-bin/lsphpnew
    sed -i -e "s/fcgi-bin\/lsphp/fcgi-bin\/lsphpnew/g" "${WEBCF}"
    sed -i -e "s/lsphp${WEBADMIN_LSPHPVER}\/bin\/lsphp/lsphp$LSPHPVER\/bin\/lsphp/g" "${WEBCF}"
fi

}

function uninstall_ols_centos
{
echoB "${FPACE} - Remove OpenLiteSpeed"
silent ${YUM} -y remove openlitespeed
if [ $? != 0 ] ; then
echoR "An error occured while uninstalling OpenLiteSpeed."
ALLERRORS=1
fi
rm -rf $SERVER_ROOT/
}

function uninstall_php_centos
{
ls "${SERVER_ROOT}" | grep lsphp >/dev/null
if [ $? = 0 ] ; then
local LSPHPSTR="$(ls ${SERVER_ROOT} | grep -i lsphp | tr '\n' ' ')"
for LSPHPVER in ${LSPHPSTR}; do
echoB "${FPACE} - Detect LSPHP version $LSPHPVER"
if [ "$LSPHPVER" = "lsphp80" ]; then
silent ${YUM} -y remove lsphp$LSPHPVER lsphp$LSPHPVER-common lsphp$LSPHPVER-gd lsphp$LSPHPVER-process lsphp$LSPHPVER-mbstring
lsphp$LSPHPVER-mysqlnd lsphp$LSPHPVER-xml lsphp$LSPHPVER-pdo lsphp$LSPHPVER-imap lsphp*
else
silent ${YUM} -y remove lsphp$LSPHPVER lsphp$LSPHPVER-common lsphp$LSPHPVER-gd lsphp$LSPHPVER-process lsphp$LSPHPVER-mbstring
lsphp$LSPHPVER-mysqlnd lsphp$LSPHPVER-xml lsphp$LSPHPVER-mcrypt lsphp$LSPHPVER-pdo lsphp$LSPHPVER-imap $JSON lsphp*
fi
if [ $? != 0 ] ; then
echoR "An error occured while uninstalling lsphp$LSPHPVER"
ALLERRORS=1
fi
done
else
echoB "${FPACE} - Uinstall LSPHP"
${YUM} -y remove lsphp*
echoR "Uninstallation cannot get the currently installed LSPHP version."
echoY "May not uninstall LSPHP correctly."
LSPHPVER=
fi
}

function install_ols_debian
{
local action=
local INSTALL_STATUS=0
if [ "$1" = "Update" ] ; then
action="--only-upgrade"
elif [ "$1" = "Reinstall" ] ; then
action="--reinstall"
fi
echoB "${FPACE} - add litespeedtech repo"
grep -Fq "http://rpms.litespeedtech.com/debian/" /etc/apt/sources.list.d/lst_debian_repo.list 2>/dev/null
if [ $? != 0 ] ; then
echo "deb http://rpms.litespeedtech.com/debian/ $OSVER main" > /etc/apt/sources.list.d/lst_debian_repo.list
fi
wget -qO /etc/apt/trusted.gpg.d/lst_debian_repo.gpg http://rpms.litespeedtech.com/debian/lst_debian_repo.gpg
wget -qO /etc/apt/trusted.gpg.d/lst_repo.gpg http://rpms.litespeedtech.com/debian/lst_repo.gpg
echoB "${FPACE} - update list"
${APT} -y update
echoB "${FPACE} - $1 OpenLiteSpeed"
silent ${APT} -y install $action openlitespeed

if [ ${?} != 0 ] ; then
    echoR "An error occured during OpenLiteSpeed installation."
    ALLERRORS=1
    INSTALL_STATUS=1
fi
if [ ! -e $SERVER_ROOT/lsphp$LSPHPVER/bin/lsphp ] ; then
    action=
fi
echoB "${FPACE} - $1 lsphp$LSPHPVER"
silent ${APT} -y install $action lsphp$LSPHPVER lsphp$LSPHPVER-mysql lsphp$LSPHPVER-imap lsphp$LSPHPVER-curl
if [ "$LSPHPVER" = "56" ]; then
    silent ${APT} -y install $action lsphp$LSPHPVER-gd lsphp$LSPHPVER-mcrypt
elif [ "$LSPHPVER" = "80" ]; then
    silent ${APT} -y install $action lsphp$LSPHPVER-common
else
    silent ${APT} -y install $action lsphp$LSPHPVER-common lsphp$LSPHPVER-json
fi
if [ $? != 0 ] ; then
    echoR "An error occured during lsphp$LSPHPVER installation."
    ALLERRORS=1
fi
echoB "${FPACE} - Setup lsphp symlink"
#if [ ${INSTALL_STATUS} = 0 ]; then 
if [ -e $SERVER_ROOT/bin/openlitespeed ]; then 
    ln -sf $SERVER_ROOT/lsphp$LSPHPVER/bin/lsphp $SERVER_ROOT/fcgi-bin/lsphpnew
    sed -i -e "s/fcgi-bin\/lsphp/fcgi-bin\/lsphpnew/g" "${WEBCF}"    
    sed -i -e "s/lsphp${WEBADMIN_LSPHPVER}\/bin\/lsphp/lsphp$LSPHPVER\/bin\/lsphp/g" "${WEBCF}"
fi

}

function uninstall_ols_debian
{
echoB "${FPACE} - Uninstall OpenLiteSpeed"
silent ${APT} -y purge openlitespeed
silent ${APT} -y remove openlitespeed
${APT} clean
#rm -rf $SERVER_ROOT/
}

function uninstall_php_debian
{
echoB "${FPACE} - Uninstall LSPHP"
silent ${APT} -y --purge remove lsphp*
if [ -e /usr/bin/php ] && [ -L /usr/bin/php ]; then
rm -f /usr/bin/php
fi
}

function action_uninstall
{
if [ "$ACTION" = "UNINSTALL" ] ; then
uninstall_warn
uninstall
uninstall_result
exit 0
fi
}

function action_purgeall
{
if [ "$ACTION" = "PURGEALL" ] ; then
uninstall_warn
if [ "$ROOTPASSWORD" = '' ] ; then
passwd=
echoY "Please input the MySQL root password: "
read passwd
ROOTPASSWORD=$passwd
fi
uninstall
purgedatabase
uninstall_result
exit 0
fi
}

function download_wordpress
{
echoG 'Start Download WordPress file'
if [ ! -e "$WORDPRESSPATH" ] ; then
local WPDIRNAME=$(dirname $WORDPRESSPATH)
local WPBASENAME=$(basename $WORDPRESSPATH)
mkdir -p "$WORDPRESSPATH";
cd "$WORDPRESSPATH"
else
echoG "$WORDPRESSPATH exists, will use it."
fi
if [ "${WORDPRESSINSTALLED}" = '0' ];then
wp core download
--locale=$WPLANGUAGE
--path=$WORDPRESSPATH
--allow-root
--quiet
fi
echoG 'End Download WordPress file'
}
function create_wordpress_cf
{
echoG 'Start Create Wordpress config'
cd "$WORDPRESSPATH"
wp config create
--dbname=$DATABASENAME
--dbuser=$USERNAME
--dbpass=$USERPASSWORD
--locale=ro_RO
--allow-root
--quiet
echoG 'Done Create Wordpress config'
}

function install_wordpress_core
{
echoG 'Start Setting Core Wordpress'
cd "$WORDPRESSPATH"
wp core install
--url=$SITEDOMAIN
--title=$WPTITLE
--admin_user=$WPUSER
--admin_password=$WPPASSWORD
--admin_email=$EMAIL
--skip-email
--allow-root
echoG 'Install wordpress Cache plugin'
wp plugin install litespeed-cache
--allow-root
--activate
--quiet
echoG 'End Setting Core Wordpress'
}

function random_password
{
if [ ! -z ${1} ]; then
TEMPPASSWORD="${1}"
else
TEMPPASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 ; echo '')
fi
}

function main_gen_password
{
random_password "${ADMINPASSWORD}"
ADMINPASSWORD="${TEMPPASSWORD}"
random_password "${ROOTPASSWORD}"
ROOTPASSWORD="${TEMPPASSWORD}"
random_password "${USERPASSWORD}"
USERPASSWORD="${TEMPPASSWORD}"
random_password "${WPPASSWORD}"
WPPASSWORD="${TEMPPASSWORD}"
read_password "$ADMINPASSWORD" "webAdmin password"
ADMINPASSWORD=$TEMPPASSWORD

if [ "$INSTALLWORDPRESS" = "1" ] ; then
    read_password "$ROOTPASSWORD" "MySQL root password"
    ROOTPASSWORD=$TEMPPASSWORD
    read_password "$USERPASSWORD" "MySQL user password"
    USERPASSWORD=$TEMPPASSWORD
fi

if [ "$INSTALLWORDPRESSPLUS" = "1" ] ; then
    read_password "$WPPASSWORD" "WordPress admin password"
    WPPASSWORD=$TEMPPASSWORD
fi    

}

function main_set_password
{
echo "WebAdmin username is [admin], password is [$ADMINPASSWORD]." > $SERVER_ROOT/password
set_ols_password
}

function test_mysql_password
{
CURROOTPASSWORD=$ROOTPASSWORD
TESTPASSWORDERROR=0

mysqladmin -uroot -p$CURROOTPASSWORD password $CURROOTPASSWORD
if [ $? != 0 ] ; then
    #Sometimes, mysql will treat the password error and restart will fix it.
    service mysql restart
    if [ $? != 0 ] && [ "$OSNAME" = "centos" ] ; then
        service mysqld restart
    fi

    mysqladmin -uroot -p$CURROOTPASSWORD password $CURROOTPASSWORD
    if [ $? != 0 ] ; then
        printf '\033[31mPlease input the current root password:\033[0m'
        read answer
        mysqladmin -uroot -p$answer password $answer
        if [ $? = 0 ] ; then
            CURROOTPASSWORD=$answer
        else
            echoR "root password is incorrect. 2 attempts remaining."
            printf '\033[31mPlease input the current root password:\033[0m'
            read answer
            mysqladmin -uroot -p$answer password $answer
            if [ $? = 0 ] ; then
                CURROOTPASSWORD=$answer
            else
                echoR "root password is incorrect. 1 attempt remaining."
                printf '\033[31mPlease input the current root password:\033[0m'
                read answer
                mysqladmin -uroot -p$answer password $answer
                if [ $? = 0 ] ; then
                    CURROOTPASSWORD=$answer
                else
                    echoR "root password is incorrect. 0 attempts remaining."
                    echo
                    TESTPASSWORDERROR=1
                fi
            fi
        fi
    fi
fi

export TESTPASSWORDERROR=$TESTPASSWORDERROR
if [ "x$TESTPASSWORDERROR" = "x1" ] ; then
    export CURROOTPASSWORD=
else
    export CURROOTPASSWORD=$CURROOTPASSWORD
fi

}

function centos_install_mysql
{
echoB "${FPACE} - Add MariaDB repo"
local REPOFILE=/etc/yum.repos.d/MariaDB.repo
if [ ! -f $REPOFILE ] ; then
local CENTOSVER=
if [ "$OSTYPE" != "x86_64" ] ; then
CENTOSVER=centos$OSVER-x86
else
CENTOSVER=centos$OSVER-amd64
fi
if [ "$OSNAMEVER" = "CENTOS8" ] ; then
rpm --quiet --import https://downloads.mariadb.com/MariaDB/MariaDB-Server-GPG-KEY
cat >> $REPOFILE <<END
[mariadb]
name = MariaDB
baseurl = https://downloads.mariadb.com/MariaDB/mariadb-$MARIADBVER/yum/rhel/\$releasever/\$basearch
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY
gpgcheck=1
enabled = 1
module_hotfixes = 1
END
else
cat >> $REPOFILE <<END
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/$MARIADBVER/$CENTOSVER
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

END
fi
fi
echoB "${FPACE} - Install MariaDB"
if [ "$OSNAMEVER" = "CENTOS8" ] ; then
silent ${YUM} install -y boost-program-options
silent ${YUM} --disablerepo=AppStream install -y MariaDB-server MariaDB-client
else
silent ${YUM} -y install MariaDB-server MariaDB-client
fi
if [ $? != 0 ] ; then
echoR "An error occured during installation of MariaDB. Please fix this error and try again."
echoR "You may want to manually run the command '${YUM} -y install MariaDB-server MariaDB-client' to check. Aborting installation!"
exit 1
fi
echoB "${FPACE} - Start MariaDB"
if [ "$OSNAMEVER" = "CENTOS8" ] || [ "$OSNAMEVER" = "CENTOS7" ] ; then
silent systemctl enable mariadb
silent systemctl start mariadb
else
service mysql start
fi
}

function debian_install_mysql
{
echoB "${FPACE} - Install software properties"
if [ "$OSNAMEVER" = "DEBIAN7" ] ; then
silent ${APT} -y -f install python-software-properties
silent apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
elif [ "$OSNAMEVER" = "DEBIAN8" ] ; then
silent ${APT} -y -f install software-properties-common
silent apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
elif [ "$OSNAMEVER" = "DEBIAN9" ] ; then
silent ${APT} -y -f install software-properties-common gnupg
silent apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
elif [ "$OSNAMEVER" = "DEBIAN10" ] ; then
silent ${APT} -y -f install software-properties-common gnupg
silent apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
elif [ "$OSNAMEVER" = "DEBIAN11" ] ; then
silent ${APT} -y -f install software-properties-common gnupg
silent apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
elif [ "$OSNAMEVER" = "UBUNTU14" ] ; then
silent ${APT} -y -f install software-properties-common
silent apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
elif [ "$OSNAMEVER" = "UBUNTU16" ] ; then
silent ${APT} -y -f install software-properties-common
silent apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
elif [ "$OSNAMEVER" = "UBUNTU18" ] ; then
silent ${APT} -y -f install software-properties-common
silent apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
elif [ "$OSNAMEVER" = "UBUNTU20" ] ; then
silent ${APT} -y -f install software-properties-common
silent apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
fi
echoB "${FPACE} - Add MariaDB repo"
if [ -e /etc/apt/sources.list.d/mariadb_repo.list ]; then
grep -Fq "http://mirror.jaleco.com/mariadb/repo/" /etc/apt/sources.list.d/mariadb_repo.list >/dev/null 2>&1
if [ $? != 0 ] ; then
echo "deb [$MARIADBCPUARCH] http://mirror.jaleco.com/mariadb/repo/$MARIADBVER/$OSNAME $OSVER main" > /etc/apt/sources.list.d/mariadb_repo.list
fi
else
echo "deb [$MARIADBCPUARCH] http://mirror.jaleco.com/mariadb/repo/$MARIADBVER/$OSNAME $OSVER main" > /etc/apt/sources.list.d/mariadb_repo.list
fi
echoB "${FPACE} - Update packages"
${APT} update
echoB "${FPACE} - Install MariaDB"
silent ${APT} -y -f install mariadb-server
if [ $? != 0 ] ; then
echoR "An error occured during installation of MariaDB. Please fix this error and try again."
echoR "You may want to manually run the command 'apt-get -y -f --allow-unauthenticated install mariadb-server' to check. Aborting installation!"
exit 1
fi
echoB "${FPACE} - Start MariaDB"
service mysql start
}

function install_mysql
{
echoG "Start Install MariaDB"
if [ "$OSNAME" = 'centos' ] ; then
centos_install_mysql
else
debian_install_mysql
fi
if [ $? != 0 ] ; then
echoR "An error occured when starting the MariaDB service. "
echoR "Please fix this error and try again. Aborting installation!"
exit 1
fi

echoB "${FPACE} - Set MariaDB root"
mysql -uroot -e "flush privileges;"
mysqladmin -uroot password $ROOTPASSWORD
if [ $? = 0 ] ; then
    CURROOTPASSWORD=$ROOTPASSWORD
else
    #test it is the current password
    mysqladmin -uroot -p$ROOTPASSWORD password $ROOTPASSWORD
    if [ $? = 0 ] ; then
        #echoG "MySQL root password is $ROOTPASSWORD"
        CURROOTPASSWORD=$ROOTPASSWORD
    else
        echoR "Failed to set MySQL root password to $ROOTPASSWORD, it may already have a root password."
        printf '\033[31mInstallation must know the password for the next step.\033[0m'
        test_mysql_password

        if [ "$TESTPASSWORDERROR" = "1" ] ; then
            echoY "If you forget your password you may stop the mysqld service and run the following command to reset it,"
            echoY "mysqld_safe --skip-grant-tables &"
            echoY "mysql --user=root mysql"
            echoY "update user set Password=PASSWORD('new-password') where user='root'; flush privileges; exit; "
            echoR "Aborting installation."
            echo
            exit 1
        fi

        if [ "$CURROOTPASSWORD" != "$ROOTPASSWORD" ] ; then
            echoY "Current MySQL root password is $CURROOTPASSWORD, it will be changed to $ROOTPASSWORD."
            printf '\033[31mDo you still want to change it?[y/N]\033[0m '
            read answer
            echo

            if [ "$answer" != "Y" ] && [ "$answer" != "y" ] ; then
                echoG "OK, MySQL root password not changed."
                ROOTPASSWORD=$CURROOTPASSWORD
            else
                mysqladmin -uroot -p$CURROOTPASSWORD password $ROOTPASSWORD
                if [ $? = 0 ] ; then
                    echoG "OK, MySQL root password changed to $ROOTPASSWORD."
                else
                    echoR "Failed to change MySQL root password, it is still $CURROOTPASSWORD."
                    ROOTPASSWORD=$CURROOTPASSWORD
                fi
            fi
        fi
    fi
fi
echoG "End Install MariaDB"

}

function setup_mysql
{
echoG "Start setup mysql"
local ERROR=
#delete user if exists
mysql -uroot -p$ROOTPASSWORD -e "DELETE FROM mysql.user WHERE User = '$USERNAME@localhost';"

echo `mysql -uroot -p$ROOTPASSWORD -e "SELECT user FROM mysql.user"` | grep "$USERNAME" >/dev/null
if [ $? = 0 ] ; then
    echoG "user $USERNAME exists in mysql.user"
else
    mysql -uroot -p$ROOTPASSWORD  -e "CREATE USER $USERNAME@localhost IDENTIFIED BY '$USERPASSWORD';"
    if [ $? = 0 ] ; then
        mysql -uroot -p$ROOTPASSWORD  -e "GRANT ALL PRIVILEGES ON *.* TO '$USERNAME'@localhost IDENTIFIED BY '$USERPASSWORD';"
    else
        echoR "Failed to create MySQL user $USERNAME. This user may already exist. If it does not, another problem occured."
        echoR "Please check this and update the wp-config.php file."
        ERROR="Create user error"
    fi
fi

mysql -uroot -p$ROOTPASSWORD  -e "CREATE DATABASE IF NOT EXISTS $DATABASENAME;"
if [ $? = 0 ] ; then
    mysql -uroot -p$ROOTPASSWORD  -e "GRANT ALL PRIVILEGES ON $DATABASENAME.* TO '$USERNAME'@localhost IDENTIFIED BY '$USERPASSWORD';"
else
    echoR "Failed to create database $DATABASENAME. It may already exist. If it does not, another problem occured."
    echoR "Please check this and update the wp-config.php file."
    if [ "x$ERROR" = "x" ] ; then
        ERROR="Create database error"
    else
        ERROR="$ERROR and create database error"
    fi
fi
mysql -uroot -p$ROOTPASSWORD  -e "flush privileges;"

if [ "x$ERROR" = "x" ] ; then
    echoG "Finished MySQL setup without error."
else
    echoR "Finished MySQL setup - some error(s) occured."
fi
echoG "End setup mysql"

}

function resetmysqlroot
{
if [ "x$OSNAMEVER" = "xCENTOS8" ]; then
MYSQLNAME='mariadb'
else
MYSQLNAME=mysql
fi
service $MYSQLNAME stop
if [ $? != 0 ] && [ "x$OSNAME" = "xcentos" ] ; then
service $MYSQLNAME stop
fi

DEFAULTPASSWD=$1

echo "update user set Password=PASSWORD('$DEFAULTPASSWD') where user='root'; flush privileges; exit; " > /tmp/resetmysqlroot.sql
mysqld_safe --skip-grant-tables &
#mysql --user=root mysql < /tmp/resetmysqlroot.sql
mysql --user=root mysql -e "update user set Password=PASSWORD('$DEFAULTPASSWD') where user='root'; flush privileges; exit; "
sleep 1
service $MYSQLNAME restart

}

function purgedatabase
{
if [ "$MYSQLINSTALLED" != "1" ] ; then
echoY "MySQL-server not installed."
else
local ERROR=0
test_mysql_password

    if [ "$TESTPASSWORDERROR" = "1" ] ; then
        echoR "Failed to purge database."
        echo
        ERROR=1
        ALLERRORS=1
    else
        ROOTPASSWORD=$CURROOTPASSWORD
    fi

    if [ "$ERROR" = "0" ] ; then
        mysql -uroot -p$ROOTPASSWORD  -e "DELETE FROM mysql.user WHERE User = '$USERNAME@localhost';"
        mysql -uroot -p$ROOTPASSWORD  -e "DROP DATABASE IF EXISTS $DATABASENAME;"
        echoY "Database purged."
    fi
fi

}

function pure_mariadb
{
if [ "$MYSQLINSTALLED" = "0" ] ; then
install_mysql
ROOTPASSWORD=$CURROOTPASSWORD
setup_mysql
else
echoG 'MariaDB already exist, skip!'
fi
}

function uninstall_result
{
if [ "$ALLERRORS" != "0" ] ; then
echoY "Some error(s) occured. Please check these as you may need to manually fix them."
fi
echoCYAN 'End OpenLiteSpeed one click Uninstallation << << << << << << <<'
}

function install_openlitespeed
{
echoG "Start setup OpenLiteSpeed"
local STATUS=Install
if [ "$OLSINSTALLED" = "1" ] ; then
OLS_VERSION=$(cat "$SERVER_ROOT"/VERSION)
wget -qO "$SERVER_ROOT"/release.tmp http://open.litespeedtech.com/packages/release?ver=$OLS_VERSION
LATEST_VERSION=$(cat "$SERVER_ROOT"/release.tmp)
rm "$SERVER_ROOT"/release.tmp
if [ "$OLS_VERSION" = "$LATEST_VERSION" ] ; then
STATUS=Reinstall
echoY "OpenLiteSpeed is already installed with the latest version, will attempt to reinstall it."
else
STATUS=Update
echoY "OpenLiteSpeed is already installed and newer version is available, will attempt to update it."
fi
fi

if [ "$OSNAME" = "centos" ] ; then
    install_ols_centos $STATUS
else
    install_ols_debian $STATUS
fi
silent killall -9 lsphp
echoG "End setup OpenLiteSpeed"

}

function gen_selfsigned_cert
{
if [ -e $CONFFILE ] ; then
source $CONFFILE 2>/dev/null
if [ $? != 0 ]; then
. $CONFFILE
fi
fi

SSL_COUNTRY="${SSL_COUNTRY:-US}"
SSL_STATE="${SSL_STATE:-New Jersey}"
SSL_LOCALITY="${SSL_LOCALITY:-Virtual}"
SSL_ORG="${SSL_ORG:-LiteSpeedCommunity}"
SSL_ORGUNIT="${SSL_ORGUNIT:-Testing}"
SSL_HOSTNAME="${SSL_HOSTNAME:-webadmin}"
SSL_EMAIL="${SSL_EMAIL:-.}"
COMMNAME=$(hostname)

cat << EOF > $CSR

[req]
prompt=no
distinguished_name=openlitespeed
[openlitespeed]
commonName = ${COMMNAME}
countryName = ${SSL_COUNTRY}
localityName = ${SSL_LOCALITY}
organizationName = ${SSL_ORG}
organizationalUnitName = ${SSL_ORGUNIT}
stateOrProvinceName = ${SSL_STATE}
emailAddress = ${SSL_EMAIL}
name = openlitespeed
initials = CP
dnQualifier = openlitespeed
[server_exts]
extendedKeyUsage=1.3.6.1.5.5.7.3.1
EOF
openssl req -x509 -config $CSR -extensions 'server_exts' -nodes -days 820 -newkey rsa:2048 -keyout ${KEY} -out ${CERT} >/dev/null 2>&1
rm -f $CSR

mv ${KEY}   $SERVER_ROOT/conf/$KEY
mv ${CERT}  $SERVER_ROOT/conf/$CERT
chmod 0600 $SERVER_ROOT/conf/$KEY
chmod 0600 $SERVER_ROOT/conf/$CERT

}

function set_ols_password
{
ENCRYPT_PASS="$SERVER_ROOT/admin/fcgi-bin/admin_php" -q "$SERVER_ROOT/admin/misc/htpasswd.php" $ADMINPASSWORD
if [ $? = 0 ] ; then
echo "admin:$ENCRYPT_PASS" > "$SERVER_ROOT/admin/conf/htpasswd"
if [ $? = 0 ] ; then
echoG "Set OpenLiteSpeed Web Admin access."
else
echoG "OpenLiteSpeed WebAdmin password not changed."
fi
fi
}

function config_server
{
if [ "$INSTALLWORDPRESS" != "1" ]; then
if [ -e "${WEBCF}" ] ; then
sed -i -e "s/adminEmails/adminEmails $EMAIL\n#adminEmails/" "${WEBCF}"
sed -i -e "s/8088/$WPPORT/" "${WEBCF}"
sed -i -e "s/ls_enabled/ls_enabled 1\n#/" "${WEBCF}"

        cat >> ${WEBCF} <<END

listener Defaultssl {
address *:$SSLWPPORT
secure 1
map Example *
keyFile $SERVER_ROOT/conf/$KEY
certFile $SERVER_ROOT/conf/$CERT
}

END
chown -R lsadm:lsadm $SERVER_ROOT/conf/
else
echoR "${WEBCF} is missing. It appears that something went wrong during OpenLiteSpeed installation."
ALLERRORS=1
fi
echo ols1clk > "$SERVER_ROOT/PLAT"
fi
}

function config_vh_wp
{
echoG 'Start setup virtual host config'
if [ -e "${WEBCF}" ] ; then
cat ${WEBCF} | grep "virtualhost wordpress" >/dev/null
if [ $? != 0 ] ; then
sed -i -e "s/adminEmails/adminEmails $EMAIL\n#adminEmails/" "${WEBCF}"
sed -i -e "s/ls_enabled/ls_enabled 1\n#/" "${WEBCF}"

        VHOSTCONF=$SERVER_ROOT/conf/vhosts/wordpress/vhconf.conf
        echoB "${FPACE} - Check existing port"
        grep "address.*:${WPPORT}$\|${SSLWPPORT}$"  ${WEBCF} >/dev/null 2>&1
        if [ ${?} = 0 ]; then
            echoY "Detect port ${WPPORT} || ${SSLWPPORT}, will skip domain setup!"
        else   
            echoB "${FPACE} - Create wordpress listener"  
            cat >> ${WEBCF} <<END

listener wordpress {
address *:$WPPORT
secure 0
map wordpress $SITEDOMAIN
}

listener wordpressssl {
address *:$SSLWPPORT
secure 1
map wordpress $SITEDOMAIN
keyFile $SERVER_ROOT/conf/$KEY
certFile $SERVER_ROOT/conf/$CERT
}

END
fi
echoB "${FPACE} - Insert wordpress virtual host"
cat >> ${WEBCF} <<END

virtualhost wordpress {
vhRoot $WORDPRESSPATH
configFile $VHOSTCONF
allowSymbolLink 1
enableScript 1
restrained 0
setUIDMode 2
}
END
echoB "${FPACE} - Create wordpress virtual host conf"
mkdir -p $SERVER_ROOT/conf/vhosts/wordpress/
cat > $VHOSTCONF <<END
docRoot $VH_ROOT/
index {
useServer 0
indexFiles index.php
}

context / {
location $VH_ROOT
allowBrowse 1
indexFiles index.php

rewrite {
enable 1
inherit 1
rewriteFile $WORDPRESSPATH/.htaccess
}
}

rewrite {
enable 1
autoLoadHtaccess 1
}

END
chown -R lsadm:lsadm $SERVER_ROOT/conf/
else
echoY "${FPACE} - Detect wordpress exist, will skip virtual host conf setup!"
fi
else
echoR "${WEBCF} is missing. It appears that something went wrong during OpenLiteSpeed installation."
ALLERRORS=1
fi
echo ols1clk > "$SERVER_ROOT/PLAT"
echoG 'End setup virtual host config'
}

function activate_cache
{
cat > $WORDPRESSPATH/activate_cache.php <<END

/dev/null 2>&1 if [ $? = 0 ] ; then MYSQLINSTALLED=1 else MYSQLINSTALLED=0 fi } function changeOlsPassword { LSWS_HOME=$SERVER_ROOT ENCRYPT_PASS=`"$LSWS_HOME/admin/fcgi-bin/admin_php" -q "$LSWS_HOME/admin/misc/htpasswd.php" $ADMINPASSWORD` echo "$ADMIN_USER:$ENCRYPT_PASS" > "$LSWS_HOME/admin/conf/htpasswd" echoY "Finished setting OpenLiteSpeed WebAdmin password to $ADMINPASSWORD." } function uninstall { if [ "$OLSINSTALLED" = "1" ] ; then echoB "${FPACE} - Stop OpenLiteSpeed" silent $SERVER_ROOT/bin/lswsctrl stop echoB "${FPACE} - Stop LSPHP" silent killall -9 lsphp if [ "$OSNAME" = "centos" ] ; then uninstall_php_centos uninstall_ols_centos else uninstall_php_debian uninstall_ols_debian fi echoG Uninstalled. else echoY "OpenLiteSpeed not installed." fi } function read_password { if [ "$1" != "" ] ; then TEMPPASSWORD=$1 else passwd= echoY "Please input password for $2(press enter to get a random one):" read passwd if [ "$passwd" = "" ] ; then TEMPPASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 ; echo '') else TEMPPASSWORD=$passwd fi fi } function check_php_param { if [ "$OSNAMEVER" = "UBUNTU20" ] || [ "$OSNAMEVER" = "UBUNTU18" ] || [ "$OSNAMEVER" = "DEBIAN9" ] || [ "$OSNAMEVER" = "DEBIAN10" ] || [ "$OSNAMEVER" = "DEBIAN11" ]; then if [ "$LSPHPVER" = "56" ]; then echoY "We do not support lsphp$LSPHPVER on $OSNAMEVER, lsphp73 will be used instead." LSPHPVER=80 fi fi } function check_value_follow { FOLLOWPARAM=$1 local PARAM=$1 local KEYWORD=$2 if [ "$1" = "-n" ] || [ "$1" = "-e" ] || [ "$1" = "-E" ] ; then FOLLOWPARAM= else local PARAMCHAR=$(echo $1 | awk '{print substr($0,1,1)}') if [ "$PARAMCHAR" = "-" ] ; then FOLLOWPARAM= fi fi if [ -z "$FOLLOWPARAM" ] ; then if [ ! -z "$KEYWORD" ] ; then echoR "Error: '$PARAM' is not a valid '$KEYWORD', please check and try again." usage fi fi } function fixLangTypo { WP_LOCALE="af ak sq am ar hy rup_MK as az az_TR ba eu bel bn_BD bs_BA bg_BG my_MM ca bal zh_CN \ zh_HK zh_TW co hr cs_CZ da_DK dv nl_NL nl_BE en_US en_AU en_CA en_GB eo et fo fi fr_BE fr_FR \ fy fuc gl_ES ka_GE de_DE de_CH el gn gu_IN haw_US haz he_IL hi_IN hu_HU is_IS ido id_ID ga it_IT \ ja jv_ID kn kk km kin ky_KY ko_KR ckb lo lv li lin lt_LT lb_LU mk_MK mg_MG ms_MY ml_IN mr xmf mn \ me_ME ne_NP nb_NO nn_NO ory os ps fa_IR fa_AF pl_PL pt_BR pt_PT pa_IN rhg ro_RO ru_RU ru_UA rue \ sah sa_IN srd gd sr_RS sd_PK si_LK sk_SK sl_SI so_SO azb es_AR es_CL es_CO es_MX es_PE es_PR es_ES \ es_VE su_ID sw sv_SE gsw tl tg tzm ta_IN ta_LK tt_RU te th bo tir tr_TR tuk ug_CN uk ur uz_UZ vi \ wa cy yor" LANGSTR=$(echo "$WPLANGUAGE" | awk '{print tolower($0)}') if [ "$LANGSTR" = "zh_cn" ] || [ "$LANGSTR" = "zh-cn" ] || [ "$LANGSTR" = "cn" ] ; then WPLANGUAGE=zh_CN fi if [ "$LANGSTR" = "zh_tw" ] || [ "$LANGSTR" = "zh-tw" ] || [ "$LANGSTR" = "tw" ] ; then WPLANGUAGE=zh_TW fi echo ${WP_LOCALE} | grep -w "${WPLANGUAGE}" -q if [ ${?} != 0 ]; then echoR "${WPLANGUAGE} language not found." echo "Please check $WP_LOCALE" exit 1 fi } function updatemyself { local CURMD=$(md5sum "$0" | cut -d' ' -f1) local SERVERMD=$(md5sum <(wget $MYGITHUBURL -O- 2>/dev/null) | cut -d' ' -f1) if [ "$CURMD" = "$SERVERMD" ] ; then echoG "You already have the latest version installed." else wget -O "$0" $MYGITHUBURL CURMD=$(md5sum "$0" | cut -d' ' -f1) if [ "$CURMD" = "$SERVERMD" ] ; then echoG "Updated." else echoG "Tried to update but seems to be failed." fi fi exit 0 } function uninstall_warn { if [ "$FORCEYES" != "1" ] ; then echo printf "\033[31mAre you sure you want to uninstall? Type 'Y' to continue, otherwise will quit.[y/N]\033[0m " read answer echo if [ "$answer" != "Y" ] && [ "$answer" != "y" ] ; then echoG "Uninstallation aborted!" exit 0 fi echo fi echoCYAN 'Start OpenLiteSpeed one click Uninstallation >> >> >> >> >> >> >>' } function befor_install_display { echo echoCYAN "Starting to install OpenLiteSpeed to $SERVER_ROOT/ with the parameters below," echoY "WebAdmin password: " "$ADMINPASSWORD" echoY "WebAdmin email: " "$EMAIL" echoY "LSPHP version: " "$LSPHPVER" echoY "MariaDB version: " "$MARIADBVER" if [ "$INSTALLWORDPRESS" = "1" ] ; then echoY "Install WordPress: " Yes echoY "WordPress HTTP port: " "$WPPORT" echoY "WordPress HTTPS port: " "$SSLWPPORT" echoY "WordPress language: " "$WPLANGUAGE" echoY "Web site domain: " "$SITEDOMAIN" echoY "MySQL root Password: " "$ROOTPASSWORD" echoY "Database name: " "$DATABASENAME" echoY "Database username: " "$USERNAME" echoY "Database password: " "$USERPASSWORD" if [ "$INSTALLWORDPRESSPLUS" = "1" ] ; then echoY "WordPress plus: " Yes echoY "WordPress site title: " "$WPTITLE" echoY "WordPress username: " "$WPUSER" echoY "WordPress password: " "$WPPASSWORD" else echoY "WordPress plus: " No fi if [ -e "$WORDPRESSPATH/wp-config.php" ] ; then echoY "WordPress location: " "$WORDPRESSPATH (Exsiting)" WORDPRESSINSTALLED=1 else echoY "WordPress location: " "$WORDPRESSPATH (New install)" WORDPRESSINSTALLED=0 fi else echoY "Server HTTP port: " "$WPPORT" echoY "Server HTTPS port: " "$SSLWPPORT" fi echoNW "Your password will be written to file: $SERVER_ROOT/password" echo if [ "$FORCEYES" != "1" ] ; then printf 'Are these settings correct? Type n to quit, otherwise will continue. [Y/n]' read answer if [ "$answer" = "N" ] || [ "$answer" = "n" ] ; then echoG "Aborting installation!" exit 0 fi fi echoCYAN 'Start OpenLiteSpeed one click installation >> >> >> >> >> >> >>' } function install_wp_cli { if [ -e /usr/local/bin/wp ] || [ -e /usr/bin/wp ]; then echoG 'WP CLI already exist' else echoG "Install wp_cli" curl -sO https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar chmod +x wp-cli.phar echo $PATH | grep '/usr/local/bin' >/dev/null 2>&1 if [ ${?} = 0 ]; then mv wp-cli.phar /usr/local/bin/wp else mv wp-cli.phar /usr/bin/wp fi fi if [ ! -e /usr/bin/php ] && [ ! -L /usr/bin/php ]; then ln -s ${SERVER_ROOT}/lsphp${LSPHPVER}/bin/php /usr/bin/php elif [ ! -e /usr/bin/php ]; then rm -f /usr/bin/php ln -s ${SERVER_ROOT}/lsphp${LSPHPVER}/bin/php /usr/bin/php else echoG '/usr/bin/php symlink exist, skip symlink.' fi } function main_install_wordpress { if [ "${PURE_DB}" = '1' ]; then echoG 'Install MariaDB only' pure_mariadb else if [ "$WORDPRESSINSTALLED" = '1' ] ; then echoY 'Skip WordPress installation!' else if [ "$INSTALLWORDPRESS" = "1" ] ; then install_wp_cli config_vh_wp check_port_usage if [ "$MYSQLINSTALLED" != "1" ] ; then install_mysql else test_mysql_password fi if [ "$TESTPASSWORDERROR" = "1" ] ; then echoY "MySQL setup bypassed, can not get root password." else ROOTPASSWORD=$CURROOTPASSWORD setup_mysql fi download_wordpress create_wordpress_cf if [ "$INSTALLWORDPRESSPLUS" = "1" ] ; then install_wordpress_core echo "WordPress administrator username is [$WPUSER], password is [$WPPASSWORD]." >> $SERVER_ROOT/password fi change_owner ${WORDPRESSPATH} echo "mysql WordPress DataBase name is [$DATABASENAME], username is [$USERNAME], password is [$USERPASSWORD]." >> $SERVER_ROOT/password echo "mysql root password is [$ROOTPASSWORD]." >> $SERVER_ROOT/password fi fi fi } function check_port_usage { if [ "$WPPORT" = "80" ] || [ "$SSLWPPORT" = "443" ]; then echoG "Avoid port 80/443 conflict." killall -9 apache >/dev/null 2>&1 killall -9 apache2 >/dev/null 2>&1 killall -9 httpd >/dev/null 2>&1 killall -9 nginx >/dev/null 2>&1 fi } function after_install_display { chmod 600 "$SERVER_ROOT/password" if [ "$ALLERRORS" = "0" ] ; then echoG "Congratulations! Installation finished." else echoY "Installation finished. Some errors seem to have occured, please check this as you may need to manually fix them." fi if [ "$INSTALLWORDPRESSPLUS" = "0" ] && [ "$INSTALLWORDPRESS" = "1" ] && [ "${PURE_DB}" = '0' ]; then echo "Please access http://server_IP:$WPPORT/ to finish setting up your WordPress site." echo "And also you may want to activate the LiteSpeed Cache plugin to get better performance." fi echoCYAN 'End OpenLiteSpeed one click installation << << << << << << <<' echo } function test_page { local URL=$1 local KEYWORD=$2 local PAGENAME=$3 curl -skL $URL | grep -i "$KEYWORD" >/dev/null 2>&1 if [ $? != 0 ] ; then echoR "Error: $PAGENAME failed." TESTGETERROR=yes else echoG "OK: $PAGENAME passed." fi } function test_ols_admin { test_page https://localhost:7080/ "LiteSpeed WebAdmin" "test webAdmin page" } function test_ols { test_page http://localhost:$WPPORT/ Congratulation "test Example HTTP vhost page" test_page https://localhost:$SSLWPPORT/ Congratulation "test Example HTTPS vhost page" } function test_wordpress { test_page http://localhost:8088/ Congratulation "test Example vhost page" test_page http://localhost:$WPPORT/ "WordPress" "test wordpress HTTP first page" test_page https://localhost:$SSLWPPORT/ "WordPress" "test wordpress HTTPS first page" } function test_wordpress_plus { test_page http://localhost:8088/ Congratulation "test Example vhost page" test_page http://$SITEDOMAIN:$WPPORT/ WordPress "test wordpress HTTP first page" test_page https://$SITEDOMAIN:$SSLWPPORT/ WordPress "test wordpress HTTPS first page" } function main_ols_test { echoCYAN "Start auto testing >> >> >> >>" test_ols_admin if [ "${PURE_DB}" = '1' ]; then test_ols elif [ "$INSTALLWORDPRESS" = "1" ] ; then if [ "$INSTALLWORDPRESSPLUS" = "1" ] ; then test_wordpress_plus else test_wordpress fi else test_ols fi if [ "${TESTGETERROR}" = "yes" ] ; then echoG "Errors were encountered during testing. In many cases these errors can be solved manually by referring to installation logs." echoG "Service loading issues can sometimes be resolved by performing a restart of the web server." echoG "Reinstalling the web server can also help if neither of the above approaches resolve the issue." fi echoCYAN "End auto testing << << << <<" echoG 'Thanks for using OpenLiteSpeed One click installation!' echo } function main_init_check { check_root check_os check_cur_status check_php_param } function main_init_package { update_centos_hashlib update_system check_wget check_curl } function main { display_license main_init_check action_uninstall action_purgeall update_email main_gen_password befor_install_display main_init_package install_openlitespeed main_set_password gen_selfsigned_cert main_install_wordpress config_server restart_lsws after_install_display main_ols_test } while [ ! -z "${1}" ] ; do case "${1}" in -[aA] | --adminpassword ) check_value_follow "$2" "" if [ ! -z "$FOLLOWPARAM" ] ; then shift; fi ADMINPASSWORD=$FOLLOWPARAM ;; -[eE] | --email ) check_value_follow "$2" "email address" shift EMAIL=$FOLLOWPARAM ;; --lsphp ) check_value_follow "$2" "LSPHP version" shift cnt=${#LSPHPVERLIST[@]} for (( i = 0 ; i < cnt ; i++ )); do if [ "$1" = "${LSPHPVERLIST[$i]}" ] ; then LSPHPVER=$1; fi done ;; --mariadbver ) check_value_follow "$2" "MariaDB version" shift cnt=${#MARIADBVERLIST[@]} for (( i = 0 ; i < cnt ; i++ )); do if [ "$1" = "${MARIADBVERLIST[$i]}" ] ; then MARIADBVER=$1; fi done ;; --pure-mariadb ) PURE_DB=1 ;; -[wW] | --wordpress ) INSTALLWORDPRESS=1 ;; --wordpressplus ) check_value_follow "$2" "domain" shift SITEDOMAIN=$FOLLOWPARAM INSTALLWORDPRESS=1 INSTALLWORDPRESSPLUS=1 ;; --wordpresspath ) check_value_follow "$2" "WordPress path" shift WORDPRESSPATH=$FOLLOWPARAM INSTALLWORDPRESS=1 ;; -[rR] | --dbrootpassword ) check_value_follow "$2" "" if [ ! -z "$FOLLOWPARAM" ] ; then shift; fi ROOTPASSWORD=$FOLLOWPARAM ;; --dbname ) check_value_follow "$2" "database name" shift DATABASENAME=$FOLLOWPARAM ;; --dbuser ) check_value_follow "$2" "database username" shift USERNAME=$FOLLOWPARAM ;; --dbpassword ) check_value_follow "$2" "" if [ ! -z "$FOLLOWPARAM" ] ; then shift; fi USERPASSWORD=$FOLLOWPARAM ;; --listenport ) check_value_follow "$2" "HTTP listen port" shift WPPORT=$FOLLOWPARAM ;; --ssllistenport ) check_value_follow "$2" "HTTPS listen port" shift SSLWPPORT=$FOLLOWPARAM ;; --wpuser ) check_value_follow "$2" "WordPress user" shift WPUSER=$1 ;; --wppassword ) check_value_follow "$2" "" if [ ! -z "$FOLLOWPARAM" ] ; then shift; fi WPPASSWORD=$FOLLOWPARAM ;; --wplang ) check_value_follow "$2" "WordPress language" shift WPLANGUAGE=$FOLLOWPARAM fixLangTypo ;; --sitetitle ) check_value_follow "$2" "WordPress website title" shift WPTITLE=$FOLLOWPARAM ;; -[Uu] | --uninstall ) ACTION=UNINSTALL ;; -[Pp] | --purgeall ) ACTION=PURGEALL ;; -[qQ] | --quiet ) FORCEYES=1 ;; -V | --version ) display_license exit 0 ;; --update ) updatemyself ;; -v | --verbose ) VERBOSE=1 APT='apt-get' YUM='yum' ;; -[hH] | --help ) usage ;; * ) usage ;; esac shift done main `

[Feature Request] Support for MariaDB 10.11

Since MariaDB 10.11 is officially a LTS version now and recommended on the WP system requirements, it would be nice to have this version supported over 10.9 as the default version of the script

Add SSL to ols1clk

I suggest adding a -le flag to the ols1clk script, similar to what you already have on the vhsetup.sh script, else when installing it's http only.

Support lsphp74

I know how to install lsphp74 manually. However, it cannot be selected in one click mode. Please update lsphp74 so that it can be installed with one click.

Unable to locate package lsphp70-gd and lsphp70-mcrypt

My SO: Ubuntu16

When I try to install php 7 by default some packages are missing:
E: Unable to locate package lsphp70-gd
E: Unable to locate package lsphp70-mcrypt

~$ sudo apt-cache search lsphp 
lsphp54 - server-side, HTML-embedded scripting language (LSAPI binary)
lsphp54-curl - CURL module for lsphp54
lsphp54-dbg - Debug symbols for LSPHP54
lsphp54-dev - Files for LSPHP56 module development
lsphp54-enchant - Enchant module for lsphp54
lsphp54-gd - GD module for lsphp54
lsphp54-gmp - GMP module for lsphp54
lsphp54-imap - IMAP module for lsphp54
lsphp54-intl - internationalisation module for php5
lsphp54-ldap - LDAP module for lsphp54
lsphp54-mcrypt - MCrypt module for lsphp54
lsphp54-mysql - MySQL module for lsphp54
lsphp54-odbc - ODBC module for lsphp54
lsphp54-pgsql - PostgreSQL module for lsphp54
lsphp54-pspell - pspell module for lsphp54
lsphp54-recode - recode module for lsphp54
lsphp54-snmp - SNMP module for lsphp54
lsphp54-sqlite - SQLite module for lsphp54
lsphp54-tidy - tidy module for lsphp54
lsphp54-xmlrpc - XML-RPC module for lsphp54
lsphp54-xsl - XSL module for lsphp54
lsphp55 - server-side, HTML-embedded scripting language (LSAPI binary)
lsphp55-curl - CURL module for lsphp55
lsphp55-dbg - Debug symbols for LSPHP55
lsphp55-dev - Files for LSPHP56 module development
lsphp55-enchant - Enchant module for lsphp55
lsphp55-gd - GD module for lsphp55
lsphp55-gmp - GMP module for lsphp55
lsphp55-imap - IMAP module for lsphp55
lsphp55-intl - internationalisation module for php5
lsphp55-ldap - LDAP module for lsphp55
lsphp55-mcrypt - MCrypt module for lsphp55                                                                                                                                                      
lsphp55-mysql - MySQL module for lsphp55                                                                                                                                                        
lsphp55-odbc - ODBC module for lsphp55                                                                                                                                                          
lsphp55-pgsql - PostgreSQL module for lsphp55                                                                                                                                                   
lsphp55-pspell - pspell module for lsphp55                                                                                                                                                      
lsphp55-recode - recode module for lsphp55                                                                                                                                                      
lsphp55-snmp - SNMP module for lsphp55                                                                                                                                                          
lsphp55-sqlite - SQLite module for lsphp55                                                                                                                                                      
lsphp55-tidy - tidy module for lsphp55                                                                                                                                                          
lsphp55-xmlrpc - XML-RPC module for lsphp55
lsphp55-xsl - XSL module for lsphp55
lsphp56 - server-side, HTML-embedded scripting language (LSAPI binary)
lsphp56-curl - CURL module for lsphp56
lsphp56-dbg - Debug symbols for LSPHP56
lsphp56-dev - Files for LSPHP56 module development
lsphp56-enchant - Enchant module for lsphp56
lsphp56-gd - GD module for lsphp56
lsphp56-gmp - GMP module for lsphp56
lsphp56-imap - IMAP module for lsphp56
lsphp56-intl - internationalisation module for php5
lsphp56-ldap - LDAP module for lsphp56
lsphp56-mcrypt - MCrypt module for lsphp56
lsphp56-mysql - MySQL module for lsphp56
lsphp56-odbc - ODBC module for lsphp56
lsphp56-pgsql - PostgreSQL module for lsphp56
lsphp56-pspell - pspell module for lsphp56
lsphp56-recode - recode module for lsphp56
lsphp56-snmp - SNMP module for lsphp56
lsphp56-sqlite - SQLite module for lsphp56
lsphp56-tidy - tidy module for lsphp56
lsphp56-xmlrpc - XML-RPC module for lsphp56
lsphp56-xsl - XSL module for lsphp56
lsphp70 - server-side, HTML-embedded scripting language (LSAPI binary)
lsphp70-common - Common files for packages built from the PHP source
lsphp70-curl - CURL module for PHP
lsphp70-dbg - Debug symbols for LSPHP70
lsphp70-dev - Files for PHP70 module development
lsphp70-imap - IMAP module for PHP
lsphp70-intl - Internationalisation module for PHP
lsphp70-json - JSON module for PHP
lsphp70-ldap - LDAP module for PHP
lsphp70-modules-source - PHP 70 modules source package
lsphp70-mysql - MySQL module for PHP
lsphp70-opcache - Zend OpCache module for PHP
lsphp70-pgsql - PostgreSQL module for PHP
lsphp70-pspell - pspell module for PHP
lsphp70-recode - recode module for PHP
lsphp70-snmp - SNMP module for PHP
lsphp70-sqlite3 - SQLite3 module for PHP
lsphp70-sybase - Sybase module for PHP
lsphp70-tidy - tidy module for PHP

"Your PHP installation appears to be missing the MySQL extension which is required by WordPress."

I have installed it with Wordpress and this is the error when I try to access the site via IP.
wget --no-check-certificate https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh && bash ols1clk.sh -a ***** -e *****@gmail.com --lsphp 70 -w --wordpresspath /var/www/***** -r ***** --dbname ***** --dbuser ***** --dbpassword ***** --wpuser ***** --wppassword *****
***** are personal informations so I removed them.

The latest script lacks installation source trust in Debian10

The following error message occurred when I installed debian10:
Are these settings correct? Type n to quit, otherwise will continue. [Y/n]Y
Start OpenLiteSpeed one click installation >> >> >> >> >> >> >>
Start setup OpenLiteSpeed
- add litespeedtech repo
- update list
E: Malformed entry 1 in list file /etc/apt/sources.list.d/lst_debian_repo.list ( Component)
E: The list of sources could not be read.
- Install OpenLiteSpeed
An error occured during OpenLiteSpeed installation.
- Install lsphp80
An error occured during lsphp80 installation.
- Setup lsphp symlink
End setup OpenLiteSpeed
./ols1clk.sh: line 596: /usr/local/lsws/password: No such file or directory
./ols1clk.sh: line 1006: /usr/local/lsws/admin/fcgi-bin/admin_php: No such file or directory
mv: cannot move 'example.key' to '/usr/local/lsws/conf/example.key': No such fil e or directory
mv: cannot move 'example.crt' to '/usr/local/lsws/conf/example.crt': No such fil e or directory
chmod: cannot access '/usr/local/lsws/conf/example.key': No such file or directo ry
chmod: cannot access '/usr/local/lsws/conf/example.crt': No such file or directo ry
Install wp_cli
./ols1clk.sh: line 1364: curl: command not found
chmod: cannot access 'wp-cli.phar': No such file or directory
mv: cannot stat 'wp-cli.phar': No such file or directory
Start setup virtual host config
/usr/local/lsws/conf/httpd_config.conf is missing. It appears that something wen t wrong during OpenLiteSpeed installation.
./ols1clk.sh: line 1127: /usr/local/lsws/PLAT: No such file or directory
End setup virtual host config
Avoid port 80/443 conflict.
Start Install MariaDB
- Install software properties
- Add MariaDB repo
- Update packages
E: Malformed entry 1 in list file /etc/apt/sources.list.d/lst_debian_repo.list ( Component)
E: Malformed entry 1 in list file /etc/apt/sources.list.d/mariadb_repo.list (Com ponent)
E: The list of sources could not be read.
- Install MariaDB
An error occured during installation of MariaDB. Please fix this error and try a gain.
You may want to manually run the command 'apt-get -y -f --allow-unauthenticated install mariadb-server' to check. Aborting installation!

I tried to find the solution on google. I find https://unix.stackexchange.com/questions/511179/linux-mint-error-malformed-entry-1-in-list-file-etc-apt-sources-list-d-lst-de. But I failed to fix it by myself.

Make DB packages optional or skippable

Hi,

Can you please modify the ols1clk script to have some sort of flag to skip installation of MySQL/MariaDB/Percona?

There are cases where we may want to setup OLS but skip installing the database server, for example, when using with a remote server like AWS RDS.

Thank you

Add option to install mysql without -w flag

Hello,
Currently only way to install mariadb is when using -w flag,
however there are many people who don't need wordpress but just mariadb/mysql.

today i have tried, a new installation and since it is not possible to install mariadb alone, i have passed -w flag and the caveat is, default listener names have been changed to wordpress, wordpresssl

and for people like me, who use vHostTemplates, this leads to confusion and errors.

so please think of adding option to install mysql, when flags like -r dbpassword are passed.

thanks.


here, you can see outputs

without -w flag

 bash ols1clk.sh -a randompass -r randompass
**********************************************************************************************
*                    Open LiteSpeed One click installation, Version 2.2                      *
*                    Copyright (C) 2016 - 2020 LiteSpeed Technologies, Inc.                  *
**********************************************************************************************
Current platform is UBUNTU20 ubuntu focal.

Starting to install OpenLiteSpeed to /usr/local/lsws/ with the parameters below,
WebAdmin password:        randompass
WebAdmin email:           root@localhost
LSPHP version:            74
MariaDB version:          10.4
Server HTTP port:         80
Server HTTPS port:        443

Are these settings correct? Type n to quit, otherwise will continue.[Y/n]

with -w flag

bash ols1clk.sh -a randompass -r randompass-w
ols1clk.sh: line 27: warning: command substitution: ignored null byte in input
**********************************************************************************************
*                    Open LiteSpeed One click installation, Version 2.2                      *
*                    Copyright (C) 2016 - 2020 LiteSpeed Technologies, Inc.                  *
**********************************************************************************************
Current platform is UBUNTU20 ubuntu focal.

Starting to install OpenLiteSpeed to /usr/local/lsws/ with the parameters below,
WebAdmin password:        randompass
WebAdmin email:           root@localhost
LSPHP version:            74
MariaDB version:          10.4
Install WordPress:        Yes
WordPress HTTP port:      80
WordPress HTTPS port:     443
Web site domain:          *
MySQL root Password:      randompass
Database name:            olsdbname
Database username:        olsdbuser
Database password:        MDZhODlh
WordPress plus:           No
WordPress location:       /usr/local/lsws/wordpress (New install)

Are these settings correct? Type n to quit, otherwise will continue.[Y/n]

add missing php packages

Hi there,

By default, I see that on debian it installs these packages:

silent ${APT} -y install $action lsphp$LSPHPVER lsphp$LSPHPVER-mysql lsphp$LSPHPVER-imap lsphp$LSPHPVER-curl

Please add other missing packages, as some are required by certain plugins on wordpress:

silent ${APT} -y install $action lsphp$LSPHPVER lsphp$LSPHPVER-mysql lsphp$LSPHPVER-imap lsphp$LSPHPVER-curl lsphp$LSPHPVER-imagick lsphp$LSPHPVER-intl lsphp$LSPHPVER-memcached lsphp$LSPHPVER-opcache lsphp$LSPHPVER-redis

The same for centos as well.


Also probably out of scope... but in the future would be great to have the option to install php-fpm in addition to lsphp, and use it for virtual hosts.

Thank you

Support lsphp74.

--lsphp74 option is not working.

# bash ols1clk.sh -w --lsphp 74
**********************************************************************************************
*                    Open LiteSpeed One click installation, Version 2.2                      *
*                    Copyright (C) 2016 - 2020 LiteSpeed Technologies, Inc.                  *
**********************************************************************************************
Current platform is UBUNTU20 ubuntu focal.

Starting to install OpenLiteSpeed to /usr/local/lsws/ with the parameters below,
WebAdmin password:        
WebAdmin email:           root@localhost
LSPHP version:            73
MariaDB version:          10.4
Install WordPress:        Yes
WordPress HTTP port:      80
WordPress HTTPS port:     443
Web site domain:          *
MySQL root Password:      
Database name:            
Database username:        
Database password:        
WordPress plus:           No
WordPress location:       /usr/local/lsws/wordpress (New install)

fix plz.

One Click Install fails

Following https://openlitespeed.org/kb/1-click-install/

It says to run bash <( curl -k https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh )
On both Ubuntu 20 and 22, it throws a curl: option -k https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh: is unknown

cURLing without the -k (which afaik just stands for ignoring the LTS cert) works.

Not sure why, but it could be that some other users run into this, and doing the commando without -k or --insecure works. With either throws curl: option -k https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh: is unknown

login page error after ssl install

i get 404 litespeed error for wordpress post urls and admin dashboard login page after running the below command to install SSL. (I replaced my domain with example.com). front page loads without a problem.

/bin/bash <( curl -sk https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Setup/vhsetup.sh ) -d www.example.com -le [email protected] -f

default usernames and passwords

please setup a page documenting the default admin usernames and passwords. took me a while to find out what the the default configured 7080 user/pass was (which is admin/123456 btw) and how to change (via cli) that or configure in docker-compose.yml or use docker secrets and howto for the other ways you can install.

thanks

Installion of MariaDB fails

OS: Ubuntu 22.04 (Jammy)
Server Type: Dedicated Server

While installing MariaDB the script fails.

"You may want to manually run the command 'apt-get -y -f --allow-unauthenticated install mariadb-server' to check. Aborting installation!"

I suspect this happens because the web location of the repo (example on line 828 of the script) currently does not exist. MariaDB may have updated the location of the repo.

Possible solution: Update the web location of the repo in the script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.