168 lines
5.8 KiB
Bash
168 lines
5.8 KiB
Bash
###============================================================
|
|
## Ubuntu 18.04 LAMP Stack Installer
|
|
###============================================================
|
|
## Zet comments hieronder:
|
|
#
|
|
#
|
|
#
|
|
##=============================================================
|
|
|
|
##----------------##
|
|
# Pre-Config #
|
|
##----------------##
|
|
|
|
# Setup domain folder
|
|
mkdir -p /var/www/"$domain"/html
|
|
chmod -R 755 /var/www
|
|
|
|
##------------##
|
|
# Apache #
|
|
##------------##
|
|
|
|
apt install -y apache2
|
|
if [ $datauser= = 1 ]; then
|
|
source /root/data-user_setup.sh
|
|
|
|
fi
|
|
cat <<EOF > /etc/apache2/mods-enabled/dir.conf
|
|
<IfModule mod_dir.c>
|
|
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
|
|
</IfModule>
|
|
EOF
|
|
|
|
cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/"$domain.conf"
|
|
cat <<EOF > /etc/apache2/sites-available/"$domain.conf"
|
|
<VirtualHost *:80>
|
|
#netdata here
|
|
ServerAdmin $email
|
|
ServerName $domain
|
|
ServerAlias www.$domain
|
|
DocumentRoot /var/www/$domain/html
|
|
<Directory "/var/www/$domain/html">
|
|
Options FollowSymLinks
|
|
AllowOverride All
|
|
Order allow,deny
|
|
Allow from all
|
|
</Directory>
|
|
ErrorLog \${APACHE_LOG_DIR}/error.log
|
|
CustomLog \${APACHE_LOG_DIR}/access.log combined
|
|
</VirtualHost>
|
|
EOF
|
|
a2ensite $domain
|
|
a2dissite 000-default
|
|
a2enmod http2
|
|
a2enmod proxy
|
|
a2enmod proxy_http
|
|
a2enmod rewrite
|
|
|
|
##---------##
|
|
# PHP #
|
|
##---------##
|
|
|
|
apt install -y libapache2-mod-php php${phpver}-mysql php${phpver}-cgi php${phpver}-common php${phpver}-pear php${phpver}-mbstring php${phpver}-curl php${phpver}-gd php${phpver}-intl php${phpver}-soap php${phpver}-xml php${phpver}-xmlrpc php${phpver}-zip
|
|
|
|
sed -i 's/;opcache.memory_consumption=128/opcache.memory_consumption=256/g' /etc/php/"$phpver"/apache2/php.ini
|
|
sed -i 's/;opcache.enable=1/opcache.enable=1/g' /etc/php/"$phpver"/apache2/php.ini
|
|
sed -i 's/;opcache.interned_strings_buffer=8/opcache.interned_strings_buffer=8/g' /etc/php/"$phpver"/apache2/php.ini
|
|
sed -i 's/;opcache.max_accelerated_files=10000/opcache.max_accelerated_files=50000/g' /etc/php/"$phpver"/apache2/php.ini
|
|
sed -i 's/;opcache.max_wasted_percentage=5/opcache.max_wasted_percentage=5/g' /etc/php/"$phpver"/apache2/php.ini
|
|
sed -i 's/;opcache.revalidate_freq=2/opcache.revalidate_freq=0/g' /etc/php/"$phpver"/apache2/php.ini
|
|
sed -i 's/; max_input_vars = 1000/max_input_vars = 10000/g' /etc/php/"$phpver"/apache2/php.ini
|
|
sed -i 's/upload_max_filesize = 2/upload_max_filesize = 128/g' /etc/php/"$phpver"/apache2/php.ini
|
|
sed -i 's/post_max_size = 8/post_max_size = 64/g' /etc/php/"$phpver"/apache2/php.ini
|
|
|
|
|
|
##-------------##
|
|
# Postfix #
|
|
##-------------##
|
|
|
|
debconf-set-selections <<< "postfix postfix/mailname string $hostname"
|
|
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
|
|
apt install -y mailutils
|
|
sed -i 's/#inet_interfaces = all/inet_interfaces = loopback-only/g' /etc/postfix/main.cf
|
|
sed -i 's/mydestination/#mydestination/g' /etc/postfix/main.cf
|
|
sed -i 's/relayhost =/mydestination = '$hostname', localhost.'$hostname', '$hostname'/g' /etc/postfix/main.cf
|
|
cat <<EOF > /etc/aliases
|
|
# See man 5 aliases for format
|
|
postmaster: root
|
|
root: $email
|
|
EOF
|
|
newaliases
|
|
|
|
##-------------##
|
|
# Netdata #
|
|
##-------------##
|
|
|
|
apt install -y netdata
|
|
sed -i 's/SEND_EMAIL="YES"/SEND_EMAIL="NO"/g' /etc/netdata/health_alarm_notify.conf
|
|
ufw allow 19999/tcp
|
|
sed -i 's+#netdata here+RewriteEngine On\n ProxyRequests Off\n ProxyPreserveHost On\n <Proxy *>\n Require all granted\n </Proxy>\n ProxyPass "/netdata/" "http://localhost:19999/" connectiontimeout=5 timeout=30 keepalive=on\n ProxyPassReverse "/netdata/" "http://localhost:19999/"\n #RewriteRule ^/netdata$ http://%{HTTP_HOST}/netdata/ [L,R=301] #HTTP\n RewriteRule ^/netdata$ https://%{HTTP_HOST}/netdata/ [L,R=301] #HTTPS+g' /etc/apache2/sites-available/"$domain.conf"
|
|
systemctl stop netdata
|
|
systemctl disable netdata
|
|
|
|
##---------------##
|
|
# Memcached #
|
|
##---------------##
|
|
|
|
if [ $memcached = 1 ]; then
|
|
apt install -y memcached
|
|
# systemctl stop memcached
|
|
# systemctl disable memcached
|
|
fi
|
|
|
|
##-----------##
|
|
# Redis #
|
|
##-----------##
|
|
|
|
if [ $redis = 1 ]; then
|
|
apt install -y redis-server
|
|
sed -i 's/supervised no/supervised systemd/g' /etc/redis/redis.conf
|
|
sed -i 's/# bind 127.0.0.1 ::1/bind 127.0.0.1 ::1/g' /etc/redis/redis.conf
|
|
sed -i 's/# requirepass foobared/requirepass '$password'/g' /etc/redis/redis.conf
|
|
# systemctl stop redis
|
|
# systemctl disable redis
|
|
fi
|
|
|
|
##-------------##
|
|
# Certbot #
|
|
##-------------##
|
|
|
|
apt install -y python-certbot-apache
|
|
|
|
if [ $domainwww = 1 ]; then
|
|
certbot --apache -n -d "$domain" -d "www.$domain" -m "$email" --hsts --redirect --no-eff-email --agree-tos
|
|
echo "certbot --apache -n -d $domain -d www.$domain -m $email --hsts --redirect --no-eff-email --agree-tos" > ~/certbotactivate.sh
|
|
|
|
elif [ $domainwww = 0 ]; then
|
|
certbot --apache -n -d "$domain" -m "$email" --hsts --redirect --no-eff-email --agree-tos
|
|
echo "certbot --apache -n -d $domain -m $email --hsts --redirect --no-eff-email --agree-tos" > ~/certbotactivate.sh
|
|
fi
|
|
|
|
##-----------------##
|
|
# Opcache GUI #
|
|
##-----------------##
|
|
|
|
wget https://raw.githubusercontent.com/amnuts/opcache-gui/master/index.php -O /var/www/"$domain"/html/opcache.php
|
|
|
|
##--------------##
|
|
# Info.php #
|
|
##--------------##
|
|
|
|
cat > /var/www/"$domain"/html/info.php <<- "EOF"
|
|
<?php
|
|
phpinfo();
|
|
EOF
|
|
|
|
##-----------------------##
|
|
# Html Folder Perms #
|
|
##-----------------------##
|
|
|
|
chown -R www-data:www-data /var/www/"$domain"/html
|
|
|
|
##----------------------##
|
|
# Apache HTTP2 fix #
|
|
##----------------------##
|
|
|
|
sed -i '3i\ Protocols h2 http/1.1\' /etc/apache2/sites-available/ictdagbesteding.nl-le-ssl.conf
|
|
wget https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Web/raw/branch/master/Apache_PHP-FPM_Installer.sh -O h2_fix.sh
|
|
source h2_fix.sh |