You've already forked nginx-ubuntu
initial commit
This commit is contained in:
99
nginxinstall
Executable file
99
nginxinstall
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author : Allan Christensen
|
||||
# First Created : 05012022 (DD-MM-YYYY)
|
||||
# Description : Installs Nginx on Ubuntu 24.04
|
||||
# License : MIT License (see LICENSE file for details)
|
||||
|
||||
#
|
||||
# Are we root
|
||||
#
|
||||
if [[ $(id -u) -ne 0 ]]; then echo "" && echo "Must be root or use sudo" && echo "" ; exit 1; fi
|
||||
|
||||
#
|
||||
# Function to check if a service is already running or not
|
||||
#
|
||||
serviceyes () { printf "\n%s" $service ; printf " is already running cannot continue...\n\n"; }
|
||||
servicealive () { status=$(systemctl is-active $service); if [[ "$status" == "active" ]]; then serviceyes ; exit; fi; }
|
||||
|
||||
#
|
||||
# If Nginx is allready running then die
|
||||
#
|
||||
service="nginx" ; servicealive
|
||||
|
||||
#
|
||||
# Let's go
|
||||
#
|
||||
clear
|
||||
|
||||
#
|
||||
# Install and configure Nginx
|
||||
#
|
||||
apt install -y nginx
|
||||
rm /var/www/html/index.nginx-debian.html > /dev/null 2>&1
|
||||
rm /etc/nginx/snippets/snakeoil.conf > /dev/null 2>&1
|
||||
mkdir -p /var/cache/nginx/fcgi
|
||||
mkdir -p /etc/nginx/static-sites
|
||||
|
||||
#
|
||||
# Clone nginx-snippets; if nginx-snippets exists then just pull latest changes
|
||||
#
|
||||
nginxsnippets="/etc/nginx/nginx-snippets"
|
||||
repo="https://git.x-files.dk/webserver/nginx-snippets.git"
|
||||
if [[ -d "$nginxsnippets/.git" ]]; then git -C "$nginxsnippets" pull --quiet; else git clone --quiet "$repo" "$nginxsnippets"; fi
|
||||
|
||||
#
|
||||
# Install Php-Fpm
|
||||
#
|
||||
apt install -y php-fpm php-curl php-dom php-gd php-imagick php-ldap php-mbstring php-mysql php-pear php-soap php-xml php-zip
|
||||
|
||||
#
|
||||
# Determine Php version
|
||||
#
|
||||
phpver=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')
|
||||
phpfpm="php$phpver-fpm"; phpclidir="/etc/php/$phpver/cli"; phpfpmdir="/etc/php/$phpver/fpm"
|
||||
|
||||
#
|
||||
# Configure Nginx
|
||||
#
|
||||
cp "$phpclidir"/php.ini "$phpclidir"/php.ini.orig
|
||||
cp "$phpfpmdir"/php.ini "$phpfpmdir"/php.ini.orig
|
||||
cp "$nginxsnippets"/nginxconf/nginx.conf /etc/nginx
|
||||
cp "$nginxsnippets"/nginxconf/nginx.conf.high.perf /etc/nginx
|
||||
cp "$nginxsnippets"/nginxconf/default /etc/nginx/sites-available/default
|
||||
sed -i "s/VERSION/$phpver/" /etc/nginx/nginx.conf
|
||||
sed -i "s/VERSION/$phpver/" /etc/nginx/nginx.conf.high.perf
|
||||
|
||||
#
|
||||
# Creating a high performance www.conf file for optional or later use
|
||||
#
|
||||
cp /etc/php/"$phpver"/fpm/pool.d/www.conf /etc/nginx/www.conf.high.perf
|
||||
sed -i "s/pm.max_children = 5/pm.max_children = 50/" /etc/nginx/www.conf.high.perf
|
||||
sed -i "s/pm.start_servers = 2/pm.start_servers = 15/" /etc/nginx/www.conf.high.perf
|
||||
sed -i "s/pm.max_spare_servers = 3/pm.max_spare_servers = 10/" /etc/nginx/www.conf.high.perf
|
||||
sed -i "s/;pm.process_idle_timeout = 10s/pm.process_idle_timeout = 10s/" /etc/nginx/www.conf.high.perf
|
||||
sed -i "s/;pm.max_requests = 500/pm.max_requests = 500/" /etc/nginx/www.conf.high.perf
|
||||
|
||||
#
|
||||
# Adjusting php.ini with stuff I usually forget
|
||||
#
|
||||
sed -i 's/;max_input_vars = 1000/max_input_vars = 3000/' "$phpclidir"/php.ini
|
||||
sed -i 's/;max_input_vars = 1000/max_input_vars = 3000/' "$phpfpmdir"/php.ini
|
||||
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/' "$phpfpmdir"/php.ini
|
||||
sed -i 's/max_file_uploads = 20/max_file_uploads = 100/' "$phpfpmdir"/php.ini
|
||||
sed -i 's/;date.timezone =/date.timezone = Europe\/Copenhagen/' "$phpclidir"/php.ini
|
||||
sed -i 's/;date.timezone =/date.timezone = Europe\/Copenhagen/' "$phpfpmdir"/php.ini
|
||||
|
||||
#
|
||||
# Restart Nginx and Php-Fpm
|
||||
#
|
||||
systemctl restart "$phpfpm" && systemctl restart nginx
|
||||
|
||||
#
|
||||
# All done
|
||||
#
|
||||
printf "\n\nAll Done...\n\n"
|
||||
|
||||
#
|
||||
# End of script
|
||||
#
|
||||
Reference in New Issue
Block a user