This guide walks readers through building a LAMP stack on Slackware 15.0 while avoiding the pitfalls of third‑party repositories, so every component comes straight from the official Slackware mirror. It details downloading and compiling Apache, MariaDB (the MySQL drop‑in), and PHP‑fpm with options that enable dynamic module loading and secure database initialization. After configuring a Unix‑socket pool for PHP‑fpm and linking it to Apache via a simple handler rule, the tutorial shows how to start all services and verify functionality with phpinfo(). Finally, it suggests optional tweaks such as hardening MariaDB by limiting root access and turning on OPcache to improve performance.
Setup Lamp in Slackware 15.0 – Spin Up Apache, MySQL and PHP in a Snap
You’ll learn how to pull together a working LAMP stack on Slackware 15.0 without having to wrestle with third‑party repos or endless dependencies. By the end of this guide, your web server will be listening on port 80, MariaDB will be up, and PHP will serve dynamic pages.
1. Grab the official packages
Slackware ships everything you need in its x86_64 directory. The first thing to do is install Apache, MariaDB (the drop‑in replacement for MySQL), and PHP‑fpm.
# cd /usr/local/src/ # or any working dir you prefer # wget http://ftp.slackware.com/pub/slackware/slackware-15.0/x86_64/applications/apache2/httpd-2.4.54.tar.gz # tar xzf httpd-*.tar.gz # Repeat for MariaDB and PHP, e.g. # wget http://ftp.slackware.com/pub/slackware/slackware-15.0/x86_64/applications/mariadb-server/mariadb-10.6.12.tar.gz # tar xzf mariadb-*.tar.gz # wget http://ftp.slackware.com/pub/slackware/slackware-15.0/x86_64/applications/php-fpm/7.4.33.tgz # tar xzf 7.4.*.tgz
Slackware’s philosophy is “install what you want, no surprises.” By pulling the official sources you avoid the headaches of broken package dependencies that sometimes crop up in third‑party repos.
2. Compile and install Apache
# cd httpd-*
# ./configure --prefix=/usr/local/apache2 \
--enable-so \
--enable-mods=all
# make && make install
The --enable-so flag tells Apache to load modules dynamically, a big win if you need to swap out PHP or mod_wsgi later. The --enable-mods=all pulls in everything by default—if you’re on a lean system you can trim it down after.
I once had an older Slackware box where the default httpd shipped with mod_php disabled, which meant I could never get a simple index.php to work until I recompiled. Not ideal if you want out‑of‑the‑box PHP support.
3. Set up MariaDB
# cd mariadb-* # ./configure --prefix=/usr/local/mariadb # make && make install
After installing, initialize the data directory and set a root password:
# /usr/local/mariadb/bin/mysql_install_db # /usr/local/mariadb/bin/mysqld_safe & # /usr/local/mariadb/bin/mysql_secure_installation
During mysql_secure_installation you’ll be prompted for the root password; pick something memorable but safe. Once finished, stop the daemon to keep things tidy:
# pkill mysqld
4. Install PHP‑fpm and link it to Apache
# cd php-7.4.33
# ./configure --prefix=/usr/local/php-fpm \
--enable-mysqlnd \
--with-config-file-path=/etc/php-fpm.d \
--enable-opcache
# make && make install
Create the PHP-FPM pool configuration:
# cat <<EOF >/etc/php-fpm.d/www.conf [www] listen = /var/run/php-fpm.sock user = nobody group = nogroup pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 EOF
Why the socket? It keeps traffic local and avoids opening a TCP port that could be sniffed. The pool settings are modest; feel free to bump max_children if you expect heavy traffic.
5. Hook PHP‑fpm into Apache
Edit /usr/local/apache2/conf/httpd.conf (or create an include file) to add the following:
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php-fpm.sock|fcgi://localhost"
</FilesMatch>
This tells Apache to forward any request ending in .php to PHP‑fpm via the Unix socket we just created.
6. Start everything and test
# /usr/local/apache2/bin/httpd -k start # mkdir /usr/local/apache2/htdocs/test # echo "<?php phpinfo(); ?>" > /usr/local/apache2/htdocs/test/info.php
Now point your browser to http://<your-server>/test/info.php. If you see the PHP info page, congratulations—you’ve got a working LAMP stack on Slackware.
On one machine I had a stray php5 package installed that clobbered my PHP‑fpm binary path. The result was Apache serving plain text instead of executing PHP. Removing the legacy package fixed the issue instantly.
7. Optional tweaks
- Security – Create an admin user in MariaDB and lock out root over network:
# mysql -u root -p CREATE USER 'admin'@'localhost' IDENTIFIED BY 'strongpass'; GRANT ALL PRIVILEGES ON . TO 'admin'@'localhost' WITH GRANT OPTION; REVOKE ALL PRIVILEGES, GRANT OPTION FROM root@'localhost'; FLUSH PRIVILEGES;
- Performance – Enable OPcache in /etc/php-fpm.d/www.conf by adding:
opcache.enable=1 opcache.memory_consumption=128