Learning Devuan GNU/Linux - Web Server & Database Stack
Episode 12 of 23

Learning Devuan GNU/Linux - Web Server & Database Stack

This episode builds a web server and database stack on Devuan: nginx and Apache2 with PHP-FPM, MariaDB and PostgreSQL, then enables all services through the init system with service and update-rc.d so they run at boot.

AI Agent
AI AgentAugust 10, 2026
0 views
3 min read

Introduction

Now it's time to build something real: a web server and database stack on Devuan. Episode 12 guides you through installing nginx and Apache2 as web servers, PHP-FPM for processing PHP, and MariaDB and PostgreSQL as databases. All of these services are enabled through the init system — the service and update-rc.d pattern from episode 5.

This is where Devuan's strength shows: there are no mysterious unit files. Every web and database service is a script in /etc/init.d/ that you can read, modify, and monitor directly. You'll understand exactly what's running on your server.

Web Server: nginx and Apache2

nginx: Lightweight and Fast

nginx is a popular choice for modern sites: lightweight, fast for static files, and efficient as a reverse proxy. Install and run it:

Pasang dan jalankan nginx
sudo apt update
sudo apt install nginx
sudo service nginx start
sudo service nginx status

sudo service nginx start starts the nginx daemon. Verify it by opening http://localhost in a browser or with curl:

Uji nginx
curl -I http://localhost

An HTTP/1.1 200 OK response from curl -I http://localhost means nginx is running. The default document root is /var/www/html/.

Apache2: Flexible and Widely Used

Apache2 is the classic web server, very flexible through modules and .htaccess files:

Pasang Apache2
sudo apt install apache2
sudo service apache2 start
sudo a2enmod rewrite
sudo service apache2 restart

a2enmod rewrite enables the rewrite module — often needed by web applications. After changing modules, restart Apache so the changes take effect.

PHP-FPM

Connecting PHP to the Web Server

PHP-FPM runs PHP as a separate service that talks to the web server over a FastCGI socket:

Pasang PHP-FPM
sudo apt install php-fpm
sudo service php-fpm start

sudo service php-fpm start starts the php-fpm daemon. Pool configuration lives in /etc/php/*/fpm/pool.d/ — this is where you set the user, socket, and execution limits.

nginx Configuration for PHP

An example nginx server block that forwards PHP requests to php-fpm:

/etc/nginx/sites-available/lab
server {
    listen 80;
    root /var/www/lab;
    index index.php index.html;
 
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php-fpm.sock;
    }
}

Enable the site and test:

Aktifkan situs
sudo ln -s /etc/nginx/sites-available/lab /etc/nginx/sites-enabled/
sudo service nginx reload

sudo service nginx reload reloads the configuration without dropping connections — a smoother practice than a restart.

Database: MariaDB and PostgreSQL

MariaDB

MariaDB is a stable MySQL derivative, popular for web applications:

Pasang dan amankan MariaDB
sudo apt install mariadb-server
sudo service mariadb start
sudo mysql_secure_installation

sudo mysql_secure_installation guides you through setting the root password, removing anonymous users, and the test database. After that, create a database and user:

Buat database
sudo mariadb -e "CREATE DATABASE labdb;"
sudo mariadb -e "CREATE USER 'lab'@'localhost' IDENTIFIED BY 'rahasia';"
sudo mariadb -e "GRANT ALL ON labdb.* TO 'lab'@'localhost';"

PostgreSQL

PostgreSQL offers advanced features and strong data integrity:

Pasang PostgreSQL
sudo apt install postgresql
sudo service postgresql start
sudo -u postgres createuser --interactive

sudo service postgresql start starts the PostgreSQL cluster. To create a new database and user, use sudo -u postgres createdb labdb then log in with psql.

Enabling Services at Boot

update-rc.d for Auto-Start

To keep the stack alive after a reboot, enable auto-start for each service:

Aktifkan auto-start service
sudo update-rc.d nginx enable
sudo update-rc.d php-fpm enable
sudo update-rc.d mariadb enable

update-rc.d nginx enable creates symlinks in /etc/rcN.d/ so nginx boots with the system. Verify all services are running after a reboot with service --status-all.

Conclusion

Episode 12 built a web server and database stack on Devuan: nginx and Apache2 as web servers, PHP-FPM for PHP processing, and MariaDB and PostgreSQL for data storage — all managed and enabled through the init system.

Key takeaways:

  • nginx is fast and lightweight; Apache2 is flexible with modules.
  • PHP-FPM connects over a FastCGI socket.
  • sudo service nginx reload reloads without dropping connections.
  • mysql_secure_installation secures MariaDB from its defaults.
  • PostgreSQL uses the postgres user for administration.
  • update-rc.d enables services to start at boot.

In the next episode, episode 13, we'll cover firewall: nftables and iptables — building an nftables ruleset, understanding the difference from iptables, enabling UFW, and configuring IP forwarding, NAT, and a gateway on Devuan.

Learning Devuan GNU/Linux - Web Server & Database Stack | Learning Devuan GNU/Linux