Welcome to kriss.run!


Back

install_webserver.sh

#!/usr/bin/env bash

# FUNCTION: __install_apache2
__install_apache2() {
    apt-get install apache2 -y
}

# FUNCTION: __install_php
__install_php() {
    apt-get install php8.3  -y
    apt-get install php8.3-common -y
    apt-get install php8.3-bcmath -y
    apt-get install php8.3-bz2 -y
    apt-get install php8.3-curl -y
    apt-get install php8.3-intl -y
    apt-get install php8.3-json -y
    apt-get install php8.3-mbstring -y
    apt-get install php8.3-mcrypt -y
    apt-get install php8.3-yaml -y
    apt-get install php8.3-xml -y
    apt-get install php8.3-xmlrpc -y
    apt-get install php8.3-zip -y
    apt-get install php8.3-mysql -y
    apt-get install php8.3-sqlite3 -y
    apt-get install php8.3-uuid -y
    apt-get install php8.3-fpm -y
    apt-get install php8.3-cli -y
    apt-get install php8.3-dev -y
    apt-get install php8.3-gd -y
    apt-get install php8.3-imagick -y
    apt-get install php8.3-imap -y
    apt-get install php8.3-ldap -y
}

# FUNCTION: __install_composer
__install_composer() {
    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    php composer-setup.php
    php -r "unlink('composer-setup.php');"
    sudo mv composer.phar /usr/local/bin/composer
}

# FUNCTION: __enable_modules
__enable_modules() {
    a2enmod rewrite
    a2enmod ssl
    if [ -f /etc/apache2/mods-available/php8.3.load ]; then
        a2enmod php8.3
    fi
}

# FUNCTION: main
main() {
    echo "Select what you want to install:"
    echo "1) Apache2"
    echo "2) PHP"
    echo "3) Composer"
    echo "4) All of the above"
    read -p "Enter your choice [1-4]: " choice

    case $choice in
        1)
            __install_apache2
            ;;
        2)
            __install_php
            ;;
        3)
            __install_composer
            ;;
        4)
            __install_apache2
            __install_php
            __install_composer
            __enable_modules
            ;;
        *)
            echo "Invalid choice. Exiting."
            exit 1
            ;;
    esac
}

main