kelson8 revised this gist 4 months ago. Go to revision
1 file changed, 66 insertions
install-nginx.sh(file created)
| @@ -0,0 +1,66 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | # This will be a basic script for installing Nginx, Mariadb, and php. | |
| 3 | + | # Mostly created with a few guides and my knowledge of this stuff. | |
| 4 | + | ||
| 5 | + | # Set these to true depending on if installing all of them. | |
| 6 | + | # By default, these are set to false. | |
| 7 | + | INSTALL_NGINX=false | |
| 8 | + | INSTALL_PHP=false | |
| 9 | + | INSTALL_MARIADB=false | |
| 10 | + | # Set the php version here, on Ubuntu Server 24 the latest is 8.3 | |
| 11 | + | # Using php 8.5 from the PHP PPA. | |
| 12 | + | PHP_VERSION=8.5 | |
| 13 | + | ||
| 14 | + | # Setup to use the Ondrej PHP PPA from here | |
| 15 | + | # https://php.watch/articles/php-84-install-upgrade-guide-debian-ubuntu | |
| 16 | + | ||
| 17 | + | # Adding the PPA for Ubuntu Server: | |
| 18 | + | # sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php | |
| 19 | + | # sudo apt update | |
| 20 | + | ||
| 21 | + | # Adding the PPA for Debian (Some of these packages may already be installed): | |
| 22 | + | # sudo apt-get update | |
| 23 | + | # sudo apt-get -y install lsb-release ca-certificates curl apt-transport-https | |
| 24 | + | # sudo curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb | |
| 25 | + | # sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb | |
| 26 | + | # 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' | |
| 27 | + | # sudo apt-get update | |
| 28 | + | ||
| 29 | + | # First, check if user is root. | |
| 30 | + | # https://stackoverflow.com/questions/18215973/how-to-check-if-running-as-root-in-a-bash-script | |
| 31 | + | if [ "$EUID" -ne 0 ]; then | |
| 32 | + | echo "This script requires root." | |
| 33 | + | exit 1 | |
| 34 | + | fi | |
| 35 | + | ||
| 36 | + | # Install nginx | |
| 37 | + | if [ "$INSTALL_NGINX" = true ]; then | |
| 38 | + | apt install nginx -y | |
| 39 | + | fi | |
| 40 | + | ||
| 41 | + | # Removed | |
| 42 | + | # php$PHP_VERSION-json \ | |
| 43 | + | ||
| 44 | + | # https://stackoverflow.com/a/40816033 | |
| 45 | + | if [ "$INSTALL_PHP" = true ]; then | |
| 46 | + | apt install \ | |
| 47 | + | php$PHP_VERSION-bcmath \ | |
| 48 | + | php$PHP_VERSION-bz2 \ | |
| 49 | + | php$PHP_VERSION-cli \ | |
| 50 | + | php$PHP_VERSION-common \ | |
| 51 | + | php$PHP_VERSION-curl \ | |
| 52 | + | php$PHP_VERSION-dev \ | |
| 53 | + | php$PHP_VERSION-fpm \ | |
| 54 | + | php$PHP_VERSION-gd \ | |
| 55 | + | php$PHP_VERSION-mbstring \ | |
| 56 | + | php$PHP_VERSION-mcrypt \ | |
| 57 | + | php$PHP_VERSION-mysql \ | |
| 58 | + | php$PHP_VERSION-sqlite3 \ | |
| 59 | + | php$PHP_VERSION-tokenizer \ | |
| 60 | + | php$PHP_VERSION-xml \ | |
| 61 | + | php$PHP_VERSION-zip -y | |
| 62 | + | fi | |
| 63 | + | ||
| 64 | + | if [ "$INSTALL_MARIADB" = true ]; then | |
| 65 | + | apt install mariadb-server -y | |
| 66 | + | fi | |
Newer
Older