PHP-FPM 5.6 & 7.1, Apache2.4, MySQL, Sendmail
# You must be root
sudo su
apt update \
&& apt install -y software-properties-common \
&& add-apt-repository -y ppa:ondrej/apache2 \
&& add-apt-repository -y ppa:ondrej/php \
&& apt update
# Optional
apt -y upgrade
# Optional2 - CertBot for HTTPS
apt update \
&& apt install -y software-properties-common python-software-properties \
&& add-apt-repository ppa:certbot/certbot \
&& apt update \
&& apt install -y python-certbot-apache
# 0) Use ./vhost to create host
# 1) Uncomment all ## in /etc/apache2/sites-available/domain.tld.conf
# 2) Generate LE SSL Certs > sudo certbot --apache certonly -d domain.tld -d www.domain.tld
# 3) Restart webserver > ./vhost.sh -a restart
apt install -y apache2 libapache2-mod-fastcgi \
php7.1 php7.1-fpm php7.1-mysql php7.1-mbstring php7.1-mcrypt \
php7.1-bcmath php7.1-gd php7.1-bz2 php7.1-opcache php7.1-tidy php7.1-imap php7.1-pgsql php7.1-xml php7.1-cli php7.1-phpdbg php7.1-xmlrpc php7.1-common php7.1-intl php7.1-pspell php7.1-xsl php7.1-curl php7.1-json php7.1-readline php7.1-zip php7.1-ldap php7.1-recode php7.1-soap \
php5.6 php5.6-fpm php5.6-mysql php5.6-mbstring php5.6-mcrypt \
php5.6-bcmath php5.6-gd php5.6-bz2 php5.6-opcache php5.6-tidy php5.6-imap php5.6-pgsql php5.6-xml php5.6-cli php5.6-phpdbg php5.6-xmlrpc php5.6-common php5.6-intl php5.6-pspell php5.6-xsl php5.6-curl php5.6-json php5.6-readline php5.6-zip php5.6-ldap php5.6-recode php5.6-soap \
# and go for coffe
# Optional
rm /etc/apache2/sites-available/000-default.conf \
&& echo -e "<VirtualHost *:80>
\t#ServerName www.example.com
\tServerAdmin webmaster@localhost
\tDocumentRoot /var/www/html
\tLogLevel error
\tErrorLog ${APACHE_LOG_DIR}/error.log
\tCustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>" > /etc/apache2/sites-available/000-default.conf
a2enmod actions > /dev/null \
&& a2enmod fastcgi > /dev/null \
&& a2enmod rewrite > /dev/null \
&& service apache2 restart \
&& service php7.1-fpm restart \
&& service php5.6-fpm restart
# Optional
service apache2 stop \
&& sed -i "s/ServerTokens OS/ServerTokens Prod/" /etc/apache2/conf-enabled/security.conf \
&& sed -i "s/ServerSignature On/ServerSignature Off/" /etc/apache2/conf-enabled/security.conf \
&& sed -i "s/index.php/tmp.html/" /etc/apache2/mods-available/dir.conf \
&& sed -i "s/index.html/index.php/" /etc/apache2/mods-available/dir.conf \
&& sed -i "s/tmp.html/index.html/" /etc/apache2/mods-available/dir.conf \
&& service apache2 start
apt install -y mysql-server \
&& mysql_secure_installation
mysql -uroot -ppass
CREATE USER 'jirka'@'localhost' IDENTIFIED WITH mysql_native_password AS 'yourpassword';GRANT ALL PRIVILEGES ON *.* TO 'jirka'@'localhost' REQUIRE NONE WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;FLUSH PRIVILEGES;
quit
apt install -y sendmail \
&& sendmailconfig
# Optional
read -p "What is domain name? etc. example.com : " -e domain \
&& echo -e "root root@$domain" >> /etc/mail/genericstable \
&& sed -i 's/;sendmail_path =/sendmail_path = "sendmail -t -i -fno-reply@'${domain}' -Fno-reply"/' /etc/php/7.1/fpm/php.ini \
&& sed -i 's/;sendmail_path =/sendmail_path = "sendmail -t -i -fno-reply@'${domain}' -Fno-reply"/' /etc/php/5.6/fpm/php.ini \
&& service sendmail restart \
&& service php7.1-fpm restart \
&& service php5.6-fpm restart \
&& service apache2 restart