Continued work
This commit is contained in:
128
installer.sh
128
installer.sh
@ -1,8 +1,41 @@
|
||||
#!/bin/bash
|
||||
# installer.sh - LiteSpeed Server Appliance Installer
|
||||
# LiteSpeed Server Appliance Installer
|
||||
# An Open Source Appliance from Robbie Ferguson
|
||||
# (c) 2025 Robbie Ferguson - Licensed under Apache 2.0
|
||||
|
||||
HTMLSITE_CONF="html-site"
|
||||
|
||||
if [[ "$1" == "--purge" ]]; then
|
||||
echo "WARNING: This will completely uninstall LiteSpeed and delete all data (vhosts, configs, logs, web root)."
|
||||
read -p "Are you sure you want to continue? [y/N]: " confirm
|
||||
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
|
||||
echo "Purge cancelled."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Purging LiteSpeed Server Appliance..."
|
||||
|
||||
# Stop LiteSpeed service
|
||||
systemctl stop lsws || true
|
||||
|
||||
# Uninstall LiteSpeed and dependencies
|
||||
apt-get remove --purge -y openlitespeed || true
|
||||
apt-get autoremove --purge -y
|
||||
|
||||
# Remove configuration and vhost data
|
||||
rm -rf /usr/local/lsws
|
||||
rm -rf /var/www/html
|
||||
rm -rf /var/log/lsws
|
||||
rm -rf /etc/lsws
|
||||
|
||||
# Remove user and group if they exist
|
||||
userdel -r lsadm 2>/dev/null || true
|
||||
groupdel nogroup 2>/dev/null || true
|
||||
|
||||
echo "LiteSpeed Server Appliance has been purged."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
# Variables
|
||||
@ -37,9 +70,9 @@ sleep 2
|
||||
PHPVER=82
|
||||
apt install -y lsphp$PHPVER lsphp$PHPVER-common lsphp$PHPVER-mysql lsphp$PHPVER-curl lsphp$PHPVER-imagick lsphp$PHPVER-intl lsphp$PHPVER-opcache lsphp$PHPVER-redis
|
||||
|
||||
# Set lsphp as default for LiteSpeed
|
||||
systemctl stop lsws
|
||||
sed -i 's/lsphp.*/lsphp$PHPVER/' /usr/local/lsws/conf/httpd_config.conf
|
||||
# Set lsphp as default for LiteSpeed
|
||||
sed -i "s|path .*|path /usr/local/lsws/lsphp$PHPVER/bin/php|" /usr/local/lsws/conf/httpd_config.conf
|
||||
systemctl start lsws
|
||||
|
||||
# Enable GZIP and Brotli compression
|
||||
@ -60,6 +93,95 @@ systemctl start redis-server
|
||||
mkdir -p /var/www/html
|
||||
chown -R www-data:www-data /var/www/html
|
||||
|
||||
# Create custom virtual host 'html-site'
|
||||
mkdir -p /usr/local/lsws/conf/vhosts/${HTMLSITE_CONF}
|
||||
cat <<EOF > /usr/local/lsws/conf/vhosts/${HTMLSITE_CONF}/vhconf.conf
|
||||
docRoot /var/www/html
|
||||
vhDomain *
|
||||
vhAliases *
|
||||
adminEmails root@localhost
|
||||
|
||||
errorlog /usr/local/lsws/logs/${HTMLSITE_CONF}_error.log {
|
||||
useServer 0
|
||||
logLevel WARN
|
||||
rollingSize 10M
|
||||
}
|
||||
|
||||
accesslog /usr/local/lsws/logs/${HTMLSITE_CONF}_access.log {
|
||||
useServer 0
|
||||
rollingSize 10M
|
||||
}
|
||||
|
||||
index {
|
||||
useServer 0
|
||||
indexFiles index.php, index.html
|
||||
}
|
||||
|
||||
scripthandler {
|
||||
add lsapi:lsphp82 php
|
||||
}
|
||||
|
||||
extprocessor lsphp82 {
|
||||
type lsapi
|
||||
address uds://tmp/lshttpd/lsphp82.sock
|
||||
maxConns 35
|
||||
env PHP_LSAPI_CHILDREN=35
|
||||
env LSAPI_AVOID_FORK=200M
|
||||
initTimeout 60
|
||||
retryTimeout 0
|
||||
persistConn 1
|
||||
respBuffer 0
|
||||
autoStart 1
|
||||
path /usr/local/lsws/lsphp82/bin/php
|
||||
backlog 100
|
||||
instances 1
|
||||
priority 0
|
||||
memSoftLimit 2047M
|
||||
memHardLimit 2047M
|
||||
procSoftLimit 400
|
||||
procHardLimit 500
|
||||
}
|
||||
|
||||
phpIniOverride {
|
||||
php_admin_value open_basedir "/var/www/html/:/tmp/"
|
||||
}
|
||||
EOF
|
||||
|
||||
# Map listeners to html-site instead of Example
|
||||
sed -i 's/vhMap.*Example.*/vhMap ${HTMLSITE_CONF} */' /usr/local/lsws/conf/httpd_config.conf
|
||||
|
||||
# Delete the broken Example vhost
|
||||
if [[ -e /usr/local/lsws/conf/vhosts/Example ]]; then
|
||||
rm -rf /usr/local/lsws/conf/vhosts/Example
|
||||
fi
|
||||
|
||||
# Update main config to use new vhost
|
||||
HTTPD_CONF="/usr/local/lsws/conf/httpd_config.conf"
|
||||
VHOSTS_DIR="/usr/local/lsws/conf/vhosts"
|
||||
|
||||
# 1. Remove "Example" vhost from httpd_config.conf
|
||||
if grep -q 'virtualHost Example' "$HTTPD_CONF"; then
|
||||
echo "Removing Example virtual host from httpd_config.conf..."
|
||||
sed -i '/virtualHost Example {/,/^}/d' "$HTTPD_CONF"
|
||||
fi
|
||||
|
||||
# 2. Register html-site virtual host if not already present
|
||||
if ! grep -q "virtualHost $HTMLSITE_CONF" "$HTTPD_CONF"; then
|
||||
echo "Adding ${HTMLSITE_CONF} virtual host to httpd_config.conf..."
|
||||
cat <<EOL >> "$HTTPD_CONF"
|
||||
|
||||
virtualHost $HTMLSITE_CONF {
|
||||
vhRoot $VHOSTS_DIR/$HTMLSITE_CONF/
|
||||
configFile \$VH_ROOT/vhconf.conf
|
||||
allowSymbolLink 1
|
||||
enableScript 1
|
||||
restrained 0
|
||||
setUIDMode 2
|
||||
}
|
||||
EOL
|
||||
fi
|
||||
|
||||
|
||||
# Generate self-signed certificate for HTTPS
|
||||
mkdir -p /etc/ssl/litespeed
|
||||
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
|
||||
|
Reference in New Issue
Block a user