Guides 11792 Published by

This guide walks a Clear Linux user through setting up a LAMP stack by first updating the system and adding the necessary bundles for Apache, MariaDB, and PHP. It then details how to enable and verify the services with systemd, secure MariaDB using the mysql_secure_installation script, and fine‑tune PHP’s memory limits and execution time in its configuration file. The article explains how to connect PHP to Apache via an alias or FastCGI for better performance, and ends by testing the stack with a simple phpinfo page. Finally, it offers optional steps to enable mod_fastcgi, reminds readers to keep their system updated and back up databases, and concludes with encouragement to enjoy the lean, production‑ready setup.



How to Configure a LAMP Server with Clear Linux OS

If you’re running Clear Linux and need a rock‑solid LAMP stack, this quick run‑through will get Apache, MariaDB (the MySQL drop‑in), and PHP up and running in under an hour. No fluff, just the steps that actually matter.

1. Update first, then add bundles

Before you start pulling packages, make sure your system is current.

sudo swupd update

Clear Linux’s swupd keeps everything lean; if it skips a bundle, you’ll end up with broken dependencies later on.

Now pull the core LAMP components in one go:

sudo swupd bundle-add apache2 mariadb php

Bundles are pre‑built sets of packages that ship together. Adding them guarantees you get matching versions that play nicely with Clear’s runtime patches.

2. Spin up the services

Clear Linux uses systemd everywhere, so enable Apache and MariaDB to start on boot:

sudo systemctl enable --now httpd.service
sudo systemctl enable --now mariadb.service

A quick check confirms they’re alive:

systemctl status httpd mariadb | grep Active

If either shows failed, you’ll see the exact error in the journal logs.

3. Secure MariaDB

Just like on any distro, a fresh MariaDB install is open to anyone who can reach port 3306. Run the quick‑start security script:

sudo mysql_secure_installation

Answer the prompts: set a root password, remove anonymous users, disallow remote root login, and drop the test database. I’ve seen servers crash into denial of service when an unauthenticated user drops the entire mysql schema—don’t let that happen.

4. Fine‑tune PHP for Apache

Clear Linux ships PHP as a FastCGI Process Manager (php-fpm) by default, which is lighter than mod_php and eliminates per‑request PHP daemon overhead.

Edit /etc/php/7.4/php.ini (or the appropriate version directory):

sudo nano /etc/php/7.4/php.ini

Make sure these two directives are set:

memory_limit = 256M
max_execution_time = 60

Why: The default 128 MB often bites on larger scripts; 60 seconds gives scripts a little breathing room without letting rogue PHP run forever.

5. Hook PHP up to Apache

Create an alias for PHP in Apache’s config:

sudo bash -c 'cat <<EOF > /etc/httpd/conf.d/php.conf
<IfModule php7_module>
    AddHandler application/x-httpd-php .php
</IfModule>
EOF'

Then restart Apache so the new handler takes effect:

sudo systemctl reload httpd.service
6. Test the stack

Drop a quick PHP file into your web root and hit it from a browser:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Navigate to http://localhost/info.php (or replace localhost with your server’s IP). If you see the PHP configuration page, congratulations—your LAMP stack is alive and kicking.

7. Optional: Turn on mod_fastcgi for extra speed

Clear Linux ships FastCGI modules that let Apache talk to PHP via sockets instead of HTTP. It saves a few bytes per request:

sudo swupd bundle-add httpd-fastcgi

Then edit /etc/httpd/conf.d/fastcgi.conf to point at your php-fpm.sock. Restart Apache, and you’ll notice a measurable drop in CPU usage on high‑traffic sites.

That’s it. You now have a minimal but production‑ready LAMP server running on Clear Linux. Keep the system updated, run regular backups of /var/lib/mysql, and enjoy the performance gains that come from a lean distro that doesn’t bundle more than you need.