#!/bin/bash # This will be a basic script for installing Nginx, Mariadb, and php. # Mostly created with a few guides and my knowledge of this stuff. # Set these to true depending on if installing all of them. # By default, these are set to false. INSTALL_NGINX=false INSTALL_PHP=false INSTALL_MARIADB=false # Set the php version here, on Ubuntu Server 24 the latest is 8.3 # Using php 8.5 from the PHP PPA. PHP_VERSION=8.5 # Setup to use the Ondrej PHP PPA from here # https://php.watch/articles/php-84-install-upgrade-guide-debian-ubuntu # Adding the PPA for Ubuntu Server: # sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php # sudo apt update # Adding the PPA for Debian (Some of these packages may already be installed): # sudo apt-get update # sudo apt-get -y install lsb-release ca-certificates curl apt-transport-https # sudo curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb # sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb # sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' # sudo apt-get update # First, check if user is root. # https://stackoverflow.com/questions/18215973/how-to-check-if-running-as-root-in-a-bash-script if [ "$EUID" -ne 0 ]; then echo "This script requires root." exit 1 fi # Install nginx if [ "$INSTALL_NGINX" = true ]; then apt install nginx -y fi # Removed # php$PHP_VERSION-json \ # https://stackoverflow.com/a/40816033 if [ "$INSTALL_PHP" = true ]; then apt install \ php$PHP_VERSION-bcmath \ php$PHP_VERSION-bz2 \ php$PHP_VERSION-cli \ php$PHP_VERSION-common \ php$PHP_VERSION-curl \ php$PHP_VERSION-dev \ php$PHP_VERSION-fpm \ php$PHP_VERSION-gd \ php$PHP_VERSION-mbstring \ php$PHP_VERSION-mcrypt \ php$PHP_VERSION-mysql \ php$PHP_VERSION-sqlite3 \ php$PHP_VERSION-tokenizer \ php$PHP_VERSION-xml \ php$PHP_VERSION-zip -y fi if [ "$INSTALL_MARIADB" = true ]; then apt install mariadb-server -y fi