#!/bin/bash -x PUSHD=`pwd` BASEURL=https://ukr.pw # Random TCP port for php-fpm PORT=$(($RANDOM+9000)) # Interface to the Internet - i.e. the one default gateway is reachable throug IF=`ip route show | grep default | cut -d' ' -f 5` # IP address of the Internet interface, will be used as a hostname #IP=`ifconfig $IF | grep "inet addr" | cut -d':' -f 2 | cut -d' ' -f 1` IP=`ip addr show | grep $IF | grep inet | awk '{ print $2 }' | cut -d'/' -f 1` # # Install simple random password generator if it has not been installed yet, distro-independent # if [ ! -x /bin/gp ]; then wget -O /bin/gp $BASEURL/gp.txt chmod 755 /bin/gp fi # # Install and configure nginx # apt-get -y install nginx service nginx stop cd /etc/nginx/ wget -q -O - $BASEURL/nginx/antiddos.conf.txt | sed -e "s/59038/$PORT/" -e "s/localhost/$IP/" -e "s/user nginx/user www-data/" > nginx.conf rm -rf conf.d sites* naxsi* scgi_params uwsgi_params wget -O static.conf $BASEURL/nginx/static.conf.txt service nginx start # nginx configured and started # # Install and configure php-fpm # echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu focal main" > /etc/apt/sources.list.d/php.list apt-get -y install gnupg apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C apt-get update apt-get -y install php8.1-fpm php8.1-mysql php8.1-mbstring php8.1-xml libfcgi0ldbl service php8.1-fpm stop cd /etc/php/8.1/fpm/pool.d rm -f *.conf wget -q -O - $BASEURL/nginx/xxx.conf.txt | sed -e "s/59038/$PORT/" -e "s/nginx/www-data/" > xxx.conf service php8.1-fpm start # Install a simple script which shows php status from command line wget -q -O - $BASEURL/nginx/sf.txt | sed -e "s/59038/$PORT/" > /bin/sf chmod 755 /bin/sf # php8.1-fpm configured and started # # Create /www/pma directory , distro-independent # if [ ! -d /www/pma ]; then mkdir -p /www/pma fi cd /www/pma # # Create empty index.html, so http://IP/ shows blank page (security feature, phpmyadmin is buggy) # touch index.html # # Make nginx logs rotate reasonably, not like crazy: # sed -i -e 's/weekly/monthly/' -e '/monthly/a minsize 1M' -e 's/rotate 52/rotate 2/' /etc/logrotate.d/nginx sed -i -e "s/^min/ min/" -e "s/{/\/n\/\*.log {/" /etc/logrotate.d/nginx cd $PUSHD