ubuntu-nginx-web-server/scripts/init.sh

145 lines
5.7 KiB
Bash

#!/bin/bash
# automated EasyEngine server configuration script
# dev currently in progress, not ready to be used
CSI="\\033["
CEND="${CSI}0m"
CRED="${CSI}1;31m"
CGREEN="${CSI}1;32m"
# Check if user is root
if [ "$(id -u)" != "0" ]; then
echo "Error: You must be root to run this script, please use the root user to install the software."
exit 1
fi
clear
# additionals modules choice
echo ""
echo "Welcome to the nginx-ee bash script."
echo ""
#echo ""
#echo "Do you want to install ProFTPd ? (y/n)"
#read -r proftpd
#echo ""
#echo "What ssh port do you want to use ?"
#read -r ssh_port_custom
# sed -i "s/Port.*/Port ${ssh_port_custom}/" /etc/ssh/sshd_config
ufw logging on
ufw default allow outgoing
ufw default deny incoming
ufw allow 22
ufw allow 53
ufw allow http
ufw allow https
ufw allow 21
ufw allow 123
ufw allow 161
ufw allow 6556
ufw allow 19999
ufw allow 22222
ufw enable
#if [ "$proftpd" = "y" ]
#then
sudo apt-get install proftpd
#RequireValidShell
#DefaultRoot
# sudo systemctl restart proftpd0
#else
# ngx_naxsi=""
#fi
apt-get update && apt-get upgrade -y && apt-get autoremove -y && apt-get clean >> /tmp/ubuntu-nginx-web-server
apt install haveged curl git unzip zip fail2ban htop -y >> /tmp/ubuntu-nginx-web-server
wget -O /etc/sysctl.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/sysctl.conf >> /tmp/ubuntu-nginx-web-server
sysctl -p >> /tmp/ubuntu-nginx-web-server
wget -O /etc/security/limits.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/security/limits.conf >> /tmp/ubuntu-nginx-web-server
echo never > /sys/kernel/mm/transparent_hugepage/enabled
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup \
| sudo bash -s -- --mariadb-server-version=10.2 --skip-maxscale -y | sudo tee -a /tmp/ubuntu-nginx-web-server
sudo apt update
ROOT_SQL_PASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1; echo;)
export DEBIAN_FRONTEND=noninteractive
sudo debconf-set-selections <<< 'mariadb-server mysql-server/root_password password $ROOT_SQL_PASS'
sudo debconf-set-selections <<< 'mariadb-server mysql-server/root_password_again password $ROOT_SQL_PASS'
sudo apt-get install -y mariadb-server
cat <<EOF >~/.my.cnf
[client]
user=root
password=$ROOT_SQL_PASS
EOF
cp ~/.my.cnf /etc/mysql/conf.d/my.cnf
wget -qO ee rt.cx/ee && bash ee
ee stack install
ee stack install --php7 --redis --admin --phpredisadmin
bash <(wget --no-check-certificate -O - https://git.virtubox.net/virtubox/debian-config/raw/master/composer.sh)
sudo -u www-data composer update -d /var/www/22222/htdocs/db/pma/
sudo wp --allow-root cli update --nightly
usermod -s /bin/bash www-data
apt update && apt install php7.1-fpm php7.1-cli php7.1-zip php7.1-opcache php7.1-mysql php7.1-mcrypt php7.1-mbstring php7.1-json php7.1-intl \
php7.1-gd php7.1-curl php7.1-bz2 php7.1-xml php7.1-tidy php7.1-soap php7.1-bcmath -y
wget -O /etc/php/7.1/fpm/pool.d/www.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/php/7.1/fpm/pool.d/www.conf
service php7.1-fpm restart
#apt update && apt install php7.2-fpm php7.2-xml php7.2-bz2 php7.2-zip php7.2-mysql php7.2-intl php7.2-gd php7.2-curl php7.2-soap php7.2-mbstring -y
#wget -O /etc/php/7.2/fpm/pool.d/www.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/php/7.2/fpm/pool.d/www.conf
#service php7.2-fpm restart
wget -O /etc/nginx/conf.d/upstream.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/nginx/conf.d/upstream.conf
service nginx reload
cd /etc/nginx/common || exit
wget https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/common.zip
unzip common.zip
wget -O /etc/php/7.0/cli/php.ini https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/php/7.0/cli/php.ini >> /tmp/ubuntu-nginx-web-server
wget -O /etc/php/7.0/fpm/php.ini https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/php/7.0/fpm/php.ini >> /tmp/ubuntu-nginx-web-server
wget -O /etc/fail2ban/filter.d/ddos.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/fail2ban/filter.d/ddos.conf >> /tmp/ubuntu-nginx-web-server
wget -O /etc/fail2ban/filter.d/ee-wordpress.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/fail2ban/filter.d/ee-wordpress.conf >> /tmp/ubuntu-nginx-web-server
wget -O /etc/fail2ban/jail.d/custom.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/fail2ban/jail.d/custom.conf >> /tmp/ubuntu-nginx-web-server
wget -O /etc/fail2ban/jail.d/ddos.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/fail2ban/jail.d/ddos.conf >> /tmp/ubuntu-nginx-web-server
fail2ban-client reload >> /tmp/ubuntu-nginx-web-server
wget -O /etc/nginx/nginx.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/nginx/nginx-intermediate.conf >> /tmp/ubuntu-nginx-web-server
wget -O /etc/nginx/sites-available/default https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/nginx/sites-available/default >> /tmp/ubuntu-nginx-web-server
wget -O /etc/nginx/sites-available/22222 https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/nginx/sites-available/22222 >> /tmp/ubuntu-nginx-web-server
wget -O /etc/nginx/common/wpcommon-php7.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/nginx/common/wpcommon-php7.conf >> /tmp/ubuntu-nginx-web-server
wget -O /etc/nginx/common/wpcommon-php71.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/nginx/common/wpcommon-php71.conf >> /tmp/ubuntu-nginx-web-server