Installing MariaDB 10.5
apt update; apt upgrade -y apt -y install curl software-properties-common gnupg2
then
curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
bash mariadb_repo_setup --mariadb-server-version=10.5
then
apt install mariadb-server mariadb-client -y
then
mariadb-secure-installation
when prompted…
Switch to unix_socket authentication [Y/n] (Answer: n) Change the root password? [Y/n] (Answer: n) Remove anonymous users? [Y/n] (Answer: y) Disallow root login remotely? [Y/n] (Answer: n) Remove test database and access to it? [Y/n] (Answer: y) Reload privilege tables now? [Y/n] (Answer: y)
Install Apache2
apt install apache2 -y
Install PHP
We are using this server strictly for MariaDB, to make things simple, we can install our OS’s native PHP version, in Debian 11’s case that would be PHP 7.4. If needed PHP8 will also work.
apt install php php-common php-mysql php-gd php-cli -y service apache2 restart
Install PHPMyAdmin
apt install phpmyadmin -y
log into MariaDB and create our Database Administrative user.
mysql -u root -p
once you’ve logged in, we create our new Administrative user via MySQL/MariaDB cli, take note of the bold words, don’t forget to use unique values if copy and pasting.
CREATE USER Administrator@localhost IDENTIFIED BY "mysecretpassword"; GRANT ALL PRIVILEGES ON *.* TO Administrator@localhost WITH GRANT OPTION; FLUSH PRIVILEGES; exit
once outside MariaDB’s cli and back into Debian’s terminal
service mysql restart
Install Vim (text editor)
apt install vim -y
Adding SSL/HTTPS Support to Apache/PHPMyAdmin
a2enmod ssl a2enmod rewrite
Prepare our apache folder for SSL cert storage
mkdir /etc/apache2/certs/ssl
then
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/certs/ssl/ssl.key -out /etc/apache2/certs/ssl/ssl.crt
once completed with cert detail prompts you will want to edit apache’s defaut site config
vim /etc/apache2/sites-available/000-default.conf
Add the following three lines of code before the </VirtualHost> closing tag.
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
Finally we enable our ssl configuration and restart our apache services
a2ensite default-ssl.conf && systemctl restart apache2
to get your local server IP address, inside terminal use the following
ip addr
once you have your server’s local network address you should be able to access it from any computer on the same subnet using putty.
For this example, the server sits on the same local network. If you wanted to host the server remotely and access phpmyadmin you would likely use certbot to autogenerate validated ssl certs.