Install LAMP on Gentoo

Brooks Computing Systems - Jacksonville
Server administration and Linux setup

This guide shows the clean Gentoo-native way to install a full LAMP stack: Apache, MariaDB, and PHP. Instead of using a bundled package like XAMPP, this method keeps everything managed by Portage so updates, dependencies, and configuration stay under control.

Infrastructure and network overview

Gentoo does not need the old all-in-one LAMPP bundle. The better path is to install the individual packages directly through Portage:

  • Apache for the web server
  • MariaDB for the database server
  • PHP for server-side scripting

This gives you a clean, maintainable setup that fits the Gentoo way of building systems.

Terminal command work

Start by syncing your package tree:

emerge --sync

This updates the local Portage repository so Gentoo knows about the newest available ebuilds before you install Apache, MariaDB, or PHP.

Web server racks

Install Apache with Portage:

emerge --ask www-servers/apache

Enable Apache at boot and start it now:

rc-update add apache2 default
rc-service apache2 start

Test Apache:

http://localhost

Once Apache starts, browsing to localhost should show the default web page. That confirms the web server is running properly.

Database and analytics concept

Install MariaDB:

emerge --ask dev-db/mariadb

Initialize the database:

emerge --config dev-db/mariadb

Enable and start the service:

rc-update add mariadb default
rc-service mariadb start

Secure the installation:

mysql_secure_installation

The secure installation step is where you set the root password, remove insecure defaults, and lock the system down for production-style use.

Programming and PHP development

Install PHP:

emerge --ask dev-lang/php

PHP is the application layer that lets Apache serve dynamic pages. After installation, it still needs to be tied into Apache.

System configuration work

Edit Apache configuration:

nano /etc/conf.d/apache2

Set:

APACHE2_OPTS="-D PHP"

This enables PHP support in Apache so the server will process PHP files rather than serving them as plain text.

Server-side application configuration

Choose the prefork MPM and the installed PHP version:

eselect apache2 set mpm prefork
eselect apache2 set php <your-php-version>

Example:

eselect apache2 set php php8.2

Replace the version with the one actually installed on your system.

Restarting server services

Apply the PHP changes:

rc-service apache2 restart

Restarting Apache loads the new PHP integration settings and makes the server ready to process PHP pages.

Web application testing

Create a PHP info page:

echo "<?php phpinfo(); ?>" > /var/www/localhost/htdocs/info.php

Open:

http://localhost/info.php

If the PHP information page loads, your LAMP stack is working.

Database management interface

Install phpMyAdmin if you want a browser-based database tool:

emerge --ask dev-db/phpmyadmin

Linux system management

You can manually force a XAMPP-style bundle onto Gentoo, but it is usually the wrong move.

  • It is not integrated with Portage
  • Dependency management becomes messy
  • Security updates are harder to manage
  • It fights the normal Gentoo workflow

Installing Apache, MariaDB, and PHP separately gives you a much cleaner result.

Development environment setup

Add useful PHP-related USE flags:

echo "dev-lang/php apache2 mysqli pdo mysql" >> /etc/portage/package.use/php

Then rebuild packages affected by USE changes:

emerge --ask --changed-use @world

This makes sure PHP is built with the features commonly needed for Apache and MariaDB-backed sites.

Production-ready server environment

After completing the steps, you have:

  • Apache running
  • MariaDB running
  • PHP working
  • A Gentoo-managed stack instead of a bundled shortcut install

This is the proper foundation for a production website, CRUD platform, admin dashboard, or RBAC app.

Quality, Reliability & Service
Quality, Reliability & Service
Thank You For Visiting
Brooks Computing Systems - Jacksonville
Visit https://bcs.archman.us