Files
shell_sequencer/seqs/webserverUbuntu.sh

97 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
serverName="nginx"
serverPackages="nginx"
phpVersion="7.3"
phpName="php$phpVersion"
phpPackages="${phpName}-fpm ${phpName}-json ${phpName}-mysql ${phpName}-curl ${phpName}-intl ${phpName}-gd ${phpName}-zip ${phpName}-xml ${phpName}-mbstring php-imagick php-apcu"
step_1_info() {
echo "Installation of $serverName packages:"
echoinfo "$serverPackages"
}
step_1_alias() { ALIAS="install"; }
step_1() {
exe apt update
exe apt install $serverPackages
endReturn -o $? "Server package installation error"
}
step_2_info() { echo "Basic nginx configuration for initial letsencrypt certificate creation"; }
step_2() {
# Writing acme-challenge code snipped for certbot web root authentication
addConf -c "$snippetLetsencrypt" "$snippetLetsencryptLoc"
# Writing minimal default (see below)
addConf -c "$siteDefaultIp4" "$siteDefaultLoc"
# try fix errors on first install attempt
# (possible missing ipv6 support on system)
if [ $ERNO -ne 0 ] ; then
exe apt install nginx
fi
# create webroot
exe mkdir -p "$siteLetsencryptWww"
echo -n " [I] Restarting Nginx ... "
exe service nginx restart && echo "ok"
endReturn -o $? "Nginx error during startup"
}
snippetLetsencryptLoc="/etc/nginx/snippets/letsencrypt.conf"
siteLetsencryptWww="/var/www/letsencrypt"
snippetLetsencrypt="\
location ^~ /.well-known/acme-challenge/ {
default_type \"text/plain\";
root ${siteLetsencryptWww};
}"
siteDefaultLoc="/etc/nginx/sites-available/default"
siteDefaultIp4="server {
listen 80 default_server;
include ${snippetLetsencryptLoc};
}"
step_3_info() {
echo "Installation of $phpName packages:"
echoinfo "$phpPackages"
}
step_3() {
exe apt install $phpPackages
endReturn -o $? "$phpName error during startup"
}
phpFpmConfigLocation="/etc/php/${phpVersion}/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/${phpVersion}/cli/conf.d/90-custom_pi.ini"
phpCliConfig="\
date.timezone = Europe/Berlin"
step_4_info() { echo -e "Configuration of ${phpName} fpm and cli\n"; }
step_4() {
addConf -c "$phpFpmConfig" "$phpFpmConfigLocation"
addConf -c "$phpCliConfig" "$phpCliConfigLocation"
echo -n "Restarting ${phpName} ..."
exe service ${phpName}-fpm restart
endReturn -o $? "$phpName error during restart"
echo "ok"
}
VERSION_SEQREV=10
. /usr/local/bin/sequencer.sh