fallocate -l 2G /swapfile &&\
chmod 600 /swapfile &&\
mkswap /swapfile &&\
swapon /swapfile &&\
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab &&\
free -h
Setup Timezone + System Update + Reboot
ln -fs /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime \
&& dpkg-reconfigure -f noninteractive tzdata \
&& apt-get update && apt-get dist-upgrade -y && reboot
Apache + PHP + Common tweaks
add-apt-repository ppa:ondrej/php -y &&\
add-apt-repository ppa:ondrej/apache2 -y &&\
apt-get update &&\
apt-get install apache2 php8.1-fpm php8.1-mysql php8.1-xml php8.1-mbstring php8.1-gd php8.1-curl php8.1-zip -y &&\
a2enmod proxy proxy_fcgi headers expires rewrite ssl &&\
sed -i 's/post_max_size.*/post_max_size = 500M/' /etc/php/*/fpm/php.ini &&\
sed -i 's/upload_max_filesize.*/upload_max_filesize = 500M/' /etc/php/*/fpm/php.ini &&\
apt-get install -y mysql-client &&\
echo "Done! =)"
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin junior@dinhost.com.br
DocumentRoot "/var/www/site/public"
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/\.well\-known/acme\-challenge/
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
ServerAdmin junior@dinhost.com.br
DocumentRoot "/var/www/site/public"
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
<Directory /var/www/site/public>
Require all granted
Options +FollowSymLinks
AllowOverride All
</Directory>
<IfModule setenvif_module>
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
</IfModule>
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/run/php/php8.1-fpm-site.sock|fcgi://localhost"
</FilesMatch>
<FilesMatch ".+\.phps$">
Require all denied
</FilesMatch>
<FilesMatch "^\.ph(ar|p|ps|tml)$">
Require all denied
</FilesMatch>
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</VirtualHost>
MySQL 5.7 on Ubuntu 20.04
wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb \
&& dpkg -i mysql-apt-config_0.8.12-1_all.deb \
&& sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29 \
&& apt-get update \
&& apt install -f mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7*