Pre requesitos
Instalar Sistema Operativo
rfs@webserver:~ $ sudo apt update && sudo apt upgrade -y
Instalar Apache2 no Raspberry Pi
rfs@webserver:~ $ sudo apt install apache2 -y
rfs@webserver:~ $ cd /var/www/html
rfs@webserver:/var/www/html $ ls -al
index.html
Instalar PHP no Raspberry Pi
pi@raspberrypi:/var/www/html $ sudo apt install php -y
rfs@webserver:/var/www/html $ sudo rm index.html
rfs@webserver:/var/www/html $ sudo nano index.php
rfs@webserver:/var/www/html $ sudo service apache2 restart
Instalar MySQL (MariaDB Server) no Raspberry Pi
rfs@webserver:/var/www/html $ sudo apt install mariadb-server php-mysql -y
rfs@webserver:/var/www/html $ sudo mysql_secure_installation
rfs@webserver:/var/www/html $ sudo mysql --user=root --password
> create user rfs@localhost identified by 'poplab';
> grant all privileges on *.* to rfs@localhost;
> FLUSH PRIVILEGES;
> exit;
Instalar phpMyAdmin no Raspberry Pi
rfs@webserver:/var/www/html $ sudo apt install phpmyadmin -y
rfs@webserver:/var/www/html $ sudo phpenmod mysqli
rfs@webserver:/var/www/html $ sudo service apache2 restart
rfs@webserver:/var/www/html $ sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
Create a virtual server
Apos todos os serviços instalados vamos configurar o Apache para suportar virtual hosts
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster@example.com
DocumentRoot /var/www/example.com/public_html
<Directory /var/www/example.com/public_html>
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
</VirtualHost>
Hardening Web Server
rfs@webserver:~ $ ls -lh /var/www/
rfs@webserver:~ $ sudo chown -R rfs:www-data /var/www/html/
rfs@webserver:~ $ sudo chmod -R 770 /var/www/html/
rfs@webserver:~ $ ls -lh /var/www/
cd /var/www/html/
sudo find . -type f -exec chmod 0644 {} \;
sudo find . -type d -exec chmod 0755 {} \;