#!/bin/bash serverName="nginx" databaseName="mariadb" phpPackages="php7.0-fpm php7.0-json php7.0-mysql php7.0-curl php7.0-intl php7.0-mcrypt php7.0-gd php7.0-zip php7.0-xml php7.0-mbstring php-imagick php-apcu" step_1_info() { echo "Installation of $serverName and $databaseName"; } step_1_alias() { ALIAS=install; } step_1() { apt update apt install mariadb-server mariadb-client saveReturn $? endReturn apt install nginx saveReturn $? } step_2_info() { echo "Basic nginx configuration for initial letsencrypt reception"; } step_2() { echo "$siteLetsencrypt" > "$siteLetsencryptLoc" cp -ar "$siteDefaultLoc" "$siteDefaultLoc".bck read -p "Enter your domain: " siteName setMyDomain $siteName if [ $ERNO -ne 0 ] ; then apt install nginx fi mkdir -p /var/www/letsencrypt echo "Restarting Nginx ..." service nginx restart } setMyDomain() { echo -n "$siteDefaultIp4" > "$siteDefaultLoc" echo -n "$1" >> "$siteDefaultLoc" echo "$siteDefaultIp42" >> "$siteDefaultLoc" } siteLetsencryptLoc="/etc/nginx/snippets/letsencrypt.conf" siteLetsencrypt="\ location ^~ /.well-known/acme-challenge/ { default_type \"text/plain\"; root /var/www/letsencrypt; }" siteDefaultLoc="/etc/nginx/sites-available/default" siteDefaultIp4="server { listen 80; #listen [::]:80; server_name " siteDefaultIp42="; include ${siteLetsencryptLoc}; }" step_3_info() { echo "Secure mariadb installation"; } step_3() { mysql_secure_installation } step_4_info() { echo "Mariadb configuration"; } step_4() { echo "$mariadbConfig" > "$mariadbConfigLoc" echo -n "Restarting mysql ... " service mysql restart && echo "ok" } mariadbConfigLoc="/etc/mysql/mariadb.conf.d/90-myconfig.cnf" mariadbConfig="\ [mysqld] innodb_large_prefix=on innodb_file_format=barracuda innodb_file_per_table=true lower_case_table_names=0 #innodb_force_recovery=6" step_5_info() { echo "Installation of PHP7.0"; } step_5() { apt install $phpPackages } phpFpmConfigLocation="/etc/php/7.0/fpm/conf.d/90-custom_pi.ini" phpFpmConfig="\ post_max_size=64M max_execution_time=600 apc.enable_cli=1 date.timezone = Europe/Berlin opcache.enable=1 opcache.enable_cli=1 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=10000 opcache.memory_consumption=128 opcache.save_comments=1 opcache.revalidate_freq=1" phpCliConfigLocation="/etc/php/7.0/cli/conf.d/90-custom_pi.ini" phpCliConfig="\ date.timezone = Europe/Berlin" step_6_info() { echo "Configuration of PHP fpm and cli"; } step_6() { echo -n "Writing $phpFpmConfigLocation ... " echo "$phpFpmConfig" > "$phpFpmConfigLocation" && echo "ok" echo -n "Writing $phpCliConfigLocation ... " echo "$phpCliConfig" > "$phpCliConfigLocation" && echo "ok" service php7.0-fpm restart } VERSION_SEQREV=2 . sequencer.sh