diff --git a/installer.sh b/installer.sh index eed2d42..655365e 100755 --- a/installer.sh +++ b/installer.sh @@ -31,6 +31,10 @@ if [[ "$1" == "--purge" ]]; then # Remove admin user userdel -r lsadm 2>/dev/null || true + if [[ ! -e /usr/local/bin/php ]]; then + rm -f /usr/local/bin/php + fi + echo "LiteSpeed Server Appliance has been purged." exit 0 fi @@ -77,11 +81,13 @@ systemctl start lsws sleep 2 # PHP and extensions -PHPVER='8.4' +PHPVER='8.3' apt install -y lsphp${PHPVER//./} lsphp${PHPVER//./}-{common,mysql,curl,imagick,intl,opcache,redis} # Create a symlink that gives PHP CLI capability but uses the LSPHP version of PHP to coincide with server -ln -s /usr/local/lsws/lsphp83/bin/php /usr/local/bin/php +if [[ ! -e /usr/local/bin/php ]]; then + ln -s /usr/local/lsws/lsphp83/bin/php /usr/local/bin/php +fi systemctl stop lsws # Set lsphp as default for LiteSpeed @@ -145,7 +151,7 @@ extprocessor lsphp${PHPVER//./} { persistConn 1 respBuffer 0 autoStart 1 - path /usr/local/lsws/lsphp${PHPVER//./}/bin/php + path /usr/local/lsws/lsphp${PHPVER//./}/bin/lsphp backlog 100 instances 1 priority 0 @@ -188,6 +194,7 @@ if ! grep -q "virtualHost $HTMLSITE_CONF" "$HTTPD_CONF"; then cat <> "$HTTPD_CONF" virtualHost $HTMLSITE_CONF { + vhEnabled 1 vhRoot $VHOSTS_DIR/$HTMLSITE_CONF/ configFile \$VH_ROOT/vhconf.conf allowSymbolLink 1 @@ -213,7 +220,6 @@ listener SSL { secure 1 keyFile /etc/ssl/litespeed/selfsigned.key certFile /etc/ssl/litespeed/selfsigned.crt - vhRoot /var/www/html vhMap $HTMLSITE_CONF * } EOF @@ -228,13 +234,81 @@ ufw allow 443/tcp # HTTPS ufw allow 7080/tcp # LiteSpeed WebAdmin ufw --force enable +cat > /var/www/html/index.php << 'EOF' + + + + + + + LiteSpeed Server Appliance + + + +
+

LiteSpeed Server Appliance

+

This is a placeholder site located at /var/www/html/.

+

PHP is working! You're running PHP

+

You can now deploy your application or configure your virtual host as needed.

+

An Open Source Appliance from Robbie Ferguson. https://baldnerd.com

+
+ + +EOF + # Restart OpenLiteSpeed to apply changes systemctl restart lsws +echo "Reloading OpenLiteSpeed configuration..." +if [[ -e /usr/local/lsws/admin/conf/.httpd_config.xml ]]; then + rm -f /usr/local/lsws/admin/conf/.httpd_config.xml +fi +/usr/local/lsws/bin/lswsctrl restart + # Print completion message echo "LiteSpeed Server Appliance installed successfully!" echo "Default Web Root: /var/www/html" echo "Access OpenLiteSpeed WebAdmin at: https://:7080" -echo "Default admin login: admin / 123456 (change this immediately)" echo "Run '/usr/local/lsws/admin/misc/admpass.sh' as root to change WebAdmin password" echo "Self-signed SSL enabled for main site. Run Certbot later to upgrade to Let's Encrypt."