Working PHP, drop a sample index file
This commit is contained in:
84
installer.sh
84
installer.sh
@ -31,6 +31,10 @@ if [[ "$1" == "--purge" ]]; then
|
|||||||
# Remove admin user
|
# Remove admin user
|
||||||
userdel -r lsadm 2>/dev/null || true
|
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."
|
echo "LiteSpeed Server Appliance has been purged."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -77,11 +81,13 @@ systemctl start lsws
|
|||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
# PHP and extensions
|
# PHP and extensions
|
||||||
PHPVER='8.4'
|
PHPVER='8.3'
|
||||||
apt install -y lsphp${PHPVER//./} lsphp${PHPVER//./}-{common,mysql,curl,imagick,intl,opcache,redis}
|
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
|
# 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
|
systemctl stop lsws
|
||||||
# Set lsphp as default for LiteSpeed
|
# Set lsphp as default for LiteSpeed
|
||||||
@ -145,7 +151,7 @@ extprocessor lsphp${PHPVER//./} {
|
|||||||
persistConn 1
|
persistConn 1
|
||||||
respBuffer 0
|
respBuffer 0
|
||||||
autoStart 1
|
autoStart 1
|
||||||
path /usr/local/lsws/lsphp${PHPVER//./}/bin/php
|
path /usr/local/lsws/lsphp${PHPVER//./}/bin/lsphp
|
||||||
backlog 100
|
backlog 100
|
||||||
instances 1
|
instances 1
|
||||||
priority 0
|
priority 0
|
||||||
@ -188,6 +194,7 @@ if ! grep -q "virtualHost $HTMLSITE_CONF" "$HTTPD_CONF"; then
|
|||||||
cat <<EOL >> "$HTTPD_CONF"
|
cat <<EOL >> "$HTTPD_CONF"
|
||||||
|
|
||||||
virtualHost $HTMLSITE_CONF {
|
virtualHost $HTMLSITE_CONF {
|
||||||
|
vhEnabled 1
|
||||||
vhRoot $VHOSTS_DIR/$HTMLSITE_CONF/
|
vhRoot $VHOSTS_DIR/$HTMLSITE_CONF/
|
||||||
configFile \$VH_ROOT/vhconf.conf
|
configFile \$VH_ROOT/vhconf.conf
|
||||||
allowSymbolLink 1
|
allowSymbolLink 1
|
||||||
@ -213,7 +220,6 @@ listener SSL {
|
|||||||
secure 1
|
secure 1
|
||||||
keyFile /etc/ssl/litespeed/selfsigned.key
|
keyFile /etc/ssl/litespeed/selfsigned.key
|
||||||
certFile /etc/ssl/litespeed/selfsigned.crt
|
certFile /etc/ssl/litespeed/selfsigned.crt
|
||||||
vhRoot /var/www/html
|
|
||||||
vhMap $HTMLSITE_CONF *
|
vhMap $HTMLSITE_CONF *
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
@ -228,13 +234,81 @@ ufw allow 443/tcp # HTTPS
|
|||||||
ufw allow 7080/tcp # LiteSpeed WebAdmin
|
ufw allow 7080/tcp # LiteSpeed WebAdmin
|
||||||
ufw --force enable
|
ufw --force enable
|
||||||
|
|
||||||
|
cat > /var/www/html/index.php << 'EOF'
|
||||||
|
<?php
|
||||||
|
$phpver = phpversion();
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
|
<title>LiteSpeed Server Appliance</title>
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
color-scheme: light dark;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font-family: system-ui, sans-serif;
|
||||||
|
margin: 0;
|
||||||
|
padding: 2em;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body {
|
||||||
|
background-color: #121212;
|
||||||
|
color: #e0e0e0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
main {
|
||||||
|
max-width: 800px;
|
||||||
|
margin: auto;
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
padding: 2em;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 0 10px rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 2em;
|
||||||
|
margin-bottom: 0.25em;
|
||||||
|
}
|
||||||
|
.ver {
|
||||||
|
font-size: 0.9em;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
code {
|
||||||
|
background: rgba(0,0,0,0.05);
|
||||||
|
padding: 0.2em 0.4em;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
<h1>LiteSpeed Server Appliance</h1>
|
||||||
|
<p>This is a placeholder site located at <code>/var/www/html/</code>.</p>
|
||||||
|
<p>PHP is working! You're running PHP <strong><?= htmlspecialchars($phpver) ?></strong></p>
|
||||||
|
<p>You can now deploy your application or configure your virtual host as needed.</p>
|
||||||
|
<p>An Open Source Appliance from <strong>Robbie Ferguson</strong>. <a href="https://baldnerd.com" target="_blank">https://baldnerd.com</a></p>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
EOF
|
||||||
|
|
||||||
# Restart OpenLiteSpeed to apply changes
|
# Restart OpenLiteSpeed to apply changes
|
||||||
systemctl restart lsws
|
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
|
# Print completion message
|
||||||
echo "LiteSpeed Server Appliance installed successfully!"
|
echo "LiteSpeed Server Appliance installed successfully!"
|
||||||
echo "Default Web Root: /var/www/html"
|
echo "Default Web Root: /var/www/html"
|
||||||
echo "Access OpenLiteSpeed WebAdmin at: https://<your-server-ip>:7080"
|
echo "Access OpenLiteSpeed WebAdmin at: https://<your-server-ip>: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 "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."
|
echo "Self-signed SSL enabled for main site. Run Certbot later to upgrade to Let's Encrypt."
|
||||||
|
Reference in New Issue
Block a user