Setup official nginx repository

Installation notes
This commit is contained in:
2021-03-13 20:43:09 +01:00
parent 98d8de1eee
commit 1ab8ec6296

View File

@@ -2,24 +2,52 @@
serverName="nginx" serverName="nginx"
serverPackages="nginx" serverPackages="nginx"
serverSourceUrl="https://nginx.org/packages/debian/"
phpVersion="7.3" phpVersion="7.3"
phpName="php${phpVersion}" 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" phpPackages="${phpName}-fpm ${phpName}-json ${phpName}-mysql ${phpName}-curl ${phpName}-intl ${phpName}-gd ${phpName}-zip ${phpName}-xml ${phpName}-mbstring php-imagick php-apcu php-redis"
step_1_info() { aptOpt=
step_config() {
if [ $QUIET -ne 0 ] ; then
aptOpt="-y"
fi
}
step_1_info() {
echo "Setup latest apt source list for $serverName"
echoinfo "$serverSourceUrl"
}
step_1_alias() { ALIAS="setup"; }
step_1() {
shift
local osRelease=$1
endCheckEmpty osRelease "Debian release not provided"
echoseq " [I] Setup apt source for $serverName $serverSourceUrl"
local srvSource="deb $serverSourceUrl $osRelease nginx"
addConf -s "$srvSource" "$serverSourceLoc"
if [ $? -eq 0 ] ; then
echoseq " [I] Get repository key for $serverSourceUrl"Y
exe apt install gnupg $aptOpt
exe apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABF5BD827BD9BF62
fi
}
serverSourceLoc="/etc/apt/sources.list.d/nginx.list"
step_2_info() {
echo "Installation of $serverName packages:" echo "Installation of $serverName packages:"
echoinfo "$serverPackages" echoinfo "$serverPackages"
} }
step_1_alias() { ALIAS=install; } step_2_alias() { ALIAS=install; }
step_1() { step_2() {
exe apt update exe apt update
exe apt install $serverPackages exe apt install $serverPackages $aptOpt
saveReturn $? endReturn -o $? "Failed to install $serverName"
endReturn
} }
step_2_info() { echo "Basic nginx configuration for initial letsencrypt certificate creation"; } step_3_info() { echo "Basic nginx configuration for initial letsencrypt certificate creation"; }
step_2() { step_3() {
# Writing acme-challenge code snipped for certbot web root authentication # Writing acme-challenge code snipped for certbot web root authentication
addConf -c "$snippetLetsencrypt" "$snippetLetsencryptLoc" addConf -c "$snippetLetsencrypt" "$snippetLetsencryptLoc"
@@ -29,16 +57,15 @@ step_2() {
# try fix errors on first install attempt # try fix errors on first install attempt
# (possible missing ipv6 support on system) # (possible missing ipv6 support on system)
if [ $ERNO -ne 0 ] ; then if [ $ERNO -ne 0 ] ; then
exe apt install nginx exe apt install nginx $aptOpt
fi fi
# create webroot # create webroot
exe mkdir -p "$siteLetsencryptWww" exe mkdir -p "$siteLetsencryptWww"
echo -n "Restarting Nginx ... " echoseq -n "Restarting Nginx..."
exe service nginx restart && echo "ok" exe service nginx restart && echoseq "ok"
saveReturn $? endReturn -o $? "Failed to install $serverName"
endReturn
} }
snippetLetsencryptLoc="/etc/nginx/snippets/letsencrypt.conf" snippetLetsencryptLoc="/etc/nginx/snippets/letsencrypt.conf"
siteLetsencryptWww="/var/www/letsencrypt" siteLetsencryptWww="/var/www/letsencrypt"
@@ -54,10 +81,10 @@ listen 80 default_server;
include ${snippetLetsencryptLoc}; include ${snippetLetsencryptLoc};
}" }"
step_3_info() { echo "Installation of $phpName packages:" step_4_info() { echo "Installation of $phpName packages:"
echoinfo "$phpPackages"; } echoinfo "$phpPackages"; }
step_3() { step_4() {
exe apt install $phpPackages exe apt install $phpPackages $aptOpt
} }
phpFpmConfigLocation="/etc/php/${phpVersion}/fpm/conf.d/90-custom_pi.ini" phpFpmConfigLocation="/etc/php/${phpVersion}/fpm/conf.d/90-custom_pi.ini"
phpFpmConfig="post_max_size=64M phpFpmConfig="post_max_size=64M
@@ -79,14 +106,32 @@ phpCliConfigLocation="/etc/php/${phpVersion}/cli/conf.d/90-custom_pi.ini"
phpCliConfig="\ phpCliConfig="\
date.timezone = Europe/Berlin" date.timezone = Europe/Berlin"
step_4_info() { echo -e "Configuration of ${phpName} fpm and cli\n"; } step_5_info() { echo "Configuration of ${phpName} fpm and cli"; }
step_4() { step_5() {
addConf -c "$phpFpmConfig" "$phpFpmConfigLocation" addConf -c "$phpFpmConfig" "$phpFpmConfigLocation"
addConf -c "$phpCliConfig" "$phpCliConfigLocation" addConf -c "$phpCliConfig" "$phpCliConfigLocation"
echo -n "Restarting ${phpName} ... " echoseq -n "Restarting ${phpName} ... "
exe service ${phpName}-fpm restart && echo "ok" exe service ${phpName}-fpm restart && echoseq "ok"
} }
VERSION_SEQREV=9 step_6_info() { echo "Installation notes"; }
step_6_alias() { ALIAS="notes"; }
step_6() {
cat <<NOTES_EOF
# Set user to www-data on debian an tune performance a bit
[/etc/nginx/nginx.conf]
user www-data;
worker_processes 1;
events {
worker_connections 1024;
multi_accept on;
use epoll;
}
NOTES_EOF
}
VERSION_SEQREV=12
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh