RackNerd Billboard Banner

How to Install LAMP (Linux, Apache, MySQL, and PHP/PhpMyAdmin) in Arch Linux

If you’re running Arch Linux and want to set up a web server stack, LAMP (Linux, Apache, MySQL/MariaDB, PHP) is still one of the most common and reliable setups. In this guide, we’ll walk through installing and configuring LAMP along with PhpMyAdmin to make database management easier.


Step 1: Update Your System

Before installing anything, update your packages to ensure you’re working with the latest versions.

sudo pacman -Syu

Step 2: Install Apache

Apache is the web server that will handle requests and serve your content.

sudo pacman -S apache

Enable and start Apache:

sudo systemctl enable httpd
sudo systemctl start httpd

To test, open your browser and go to:

http://localhost

You should see the default Apache page.


Step 3: Install MySQL (MariaDB)

On Arch, MariaDB is the default MySQL drop-in replacement.

sudo pacman -S mariadb

Initialize and start the database:

sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
sudo systemctl enable mariadb
sudo systemctl start mariadb

Secure the installation:

sudo mysql_secure_installation

Follow the prompts to set the root password and remove insecure defaults.


Step 4: Install PHP

PHP is the server-side scripting language that connects Apache and MySQL.

sudo pacman -S php php-apache

Edit Apache’s configuration to enable PHP. Open /etc/httpd/conf/httpd.conf and:

  1. Comment out:
    LoadModule mpm_event_module modules/mod_mpm_event.so
  2. Uncomment or add:
    LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
    LoadModule php_module modules/libphp.so
    AddHandler php-script php
    Include conf/extra/php_module.conf

Restart Apache:

sudo systemctl restart httpd

Step 5: Test PHP

Create a PHP test file:

echo "<?php phpinfo(); ?>" | sudo tee /srv/http/info.php

Go to:

http://localhost/info.php

If PHP’s info page loads, you’re good.


Step 6: Install PhpMyAdmin

PhpMyAdmin provides a web interface to manage MySQL/MariaDB.

sudo pacman -S phpmyadmin php-mysqli

Edit /etc/httpd/conf/httpd.conf and add:

Include conf/extra/phpmyadmin.conf

Create the config file:

sudo nano /etc/httpd/conf/extra/phpmyadmin.conf

Add:

Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
<Directory "/usr/share/webapps/phpMyAdmin">
    DirectoryIndex index.php
    AllowOverride All
    Options FollowSymlinks
    Require all granted
</Directory>

Restart Apache:

sudo systemctl restart httpd

Visit:

http://localhost/phpmyadmin

Log in with your MySQL root credentials.


Step 7: Secure Your Setup

  • Delete info.php after testing:
    sudo rm /srv/http/info.php
  • Configure strong MySQL passwords.
  • Restrict PhpMyAdmin access to trusted IPs.

✅ You now have a fully functional LAMP stack with PhpMyAdmin running on Arch Linux.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
RackNerd Billboard Banner
© 2025 Computer Everywhere
Your Everyday Guide to the Digital World.
Terms of Service | Privacy Policy
Copy link