minor changes
This commit is contained in:
parent
46cc0c7b77
commit
98b9898a9d
35
nginxinstall
35
nginxinstall
@ -12,11 +12,11 @@ if [[ $(id -u) -ne 0 ]]; then echo "" && echo "Must be root or use sudo" && echo
|
||||
# Are we in the right directory
|
||||
#
|
||||
scriptdir="nginx-install" && whereami=$(pwd |awk -F'/' '{print $NF}')
|
||||
if [ $whereami != $scriptdir ]; then printf "\nWrong directory! Script must be run from $scriptdir\n\n" ; exit 1; fi
|
||||
if [ "$whereami" != "$scriptdir" ]; then printf "\nWrong directory! Script must be run from %s\n\n" "$scriptdir"; exit 1; fi
|
||||
#
|
||||
# Define variables and functions
|
||||
#
|
||||
line (){ for i in {1..50}; do echo -n "$1"; done && printf "\n"; }
|
||||
line () { printf -- '-%.0s' {1..50}; printf '\n'; }
|
||||
#
|
||||
# Function title
|
||||
#
|
||||
@ -24,7 +24,7 @@ title () { printf "\nNginx install script V1.3\n\n"; }
|
||||
#
|
||||
# Function to check if a service is already running or not
|
||||
#
|
||||
serviceyes () { printf "\n$service is allready running cannot continue...\n\n"; }
|
||||
serviceyes () { printf "\n%s" $service ; printf " is allready 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
|
||||
@ -55,22 +55,22 @@ apt install -y php-fpm php-curl php-dom php-gd php-imagick php-ldap php-mbstring
|
||||
# Configure Nginx
|
||||
#
|
||||
phpver=$(php -v |head -1 |awk -F'.' '{print $1"."$2}' |sed 's/PHP //')
|
||||
phpfpm="php$phpver-fpm" ; phpclidir="/etc/php/$phpver/cli" ; phpfpmdir="/etc/php/$phpver/fpm" ; socket="php$phpver"
|
||||
phpfpm="php$phpver-fpm" ; phpclidir="/etc/php/$phpver/cli" ; phpfpmdir="/etc/php/$phpver/fpm"
|
||||
#
|
||||
# Adjusting a few nginx config files to match the installed php version before moving them to the right place
|
||||
#
|
||||
sed -i "s/VERSION/$phpver/" $nginxconf/nginx.conf
|
||||
sed -i "s/VERSION/$phpver/" $nginxconf/nginx.conf.high.perf
|
||||
sed -i "s/VERSION/$phpver/" $nginxfiles/wphardening.conf
|
||||
cp $phpclidir/php.ini $phpclidir/php.ini.orig
|
||||
cp $phpfpmdir/php.ini $phpfpmdir/php.ini.orig
|
||||
cp $nginxconf/nginx.conf /etc/nginx
|
||||
cp $nginxconf/nginx.conf.high.perf /etc/nginx
|
||||
cp $nginxconf/default /etc/nginx/sites-available/default
|
||||
cp "$phpclidir"/php.ini "$phpclidir"/php.ini.orig
|
||||
cp "$phpfpmdir"/php.ini "$phpfpmdir"/php.ini.orig
|
||||
cp "$nginxconf"/nginx.conf /etc/nginx
|
||||
cp "$nginxconf"/nginx.conf.high.perf /etc/nginx
|
||||
cp "$nginxconf"/default /etc/nginx/sites-available/default
|
||||
#
|
||||
# Creating a high performance www.conf file for optional later use
|
||||
#
|
||||
cp /etc/php/$phpver/fpm/pool.d/www.conf /etc/nginx/www.conf.high.perf
|
||||
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
|
||||
@ -80,11 +80,12 @@ sed -i "s/;pm.max_requests = 500/pm.max_requests = 500/" /etc/nginx/www.conf.hig
|
||||
#
|
||||
# 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 = 20M/' $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
|
||||
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
|
||||
#
|
||||
# Create directory for static websites that don't change much
|
||||
#
|
||||
@ -92,11 +93,11 @@ mkdir /etc/nginx/static-sites
|
||||
#
|
||||
# Restart Nginx and Php-Fpm
|
||||
#
|
||||
systemctl restart $phpfpm && systemctl restart nginx
|
||||
systemctl restart "$phpfpm" && systemctl restart nginx
|
||||
#
|
||||
# All done
|
||||
#
|
||||
clear ; printf "\n" ; line '-' ; printf "All Done...\n" ; line '-' ; printf "\n"
|
||||
clear ; printf "\n" ; line ; printf "All Done...\n" ; line ; printf "\n"
|
||||
#
|
||||
# End of script
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user