Install and configure LAMP (Linux Apache MySQL and PHP) on Arch Linux 2016

This tutorial is going to show you how to install and configure LAMP stack on Arch Linux 2016. LAMP (Linux, Apache, MySQL and PHP) is a fundamental tool to build a powerful web server and web applications.

System Summary:

  • Arch Linux 2016
  • IP address:

Step 1. Install Apache Web Server

To install Apache web server on Arch Linux, use the following command on Terminal

sudo pacman -S apache

Now start the httpd service

sudo systemctl start httpd.service
sudo systemctl enable httpd.service

Check the status :

sudo systemctl status httpd.service


[dhani@arch-linux]: ~>$ systemctl status httpd.service
● httpd.service – Apache Web Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor prese
Active: active (running) since Sat 2016-12-17 18:04:52 WIB; 51min ago
Main PID: 699 (httpd)
Tasks: 82 (limit: 4915)
CGroup: /system.slice/httpd.service
├─699 /usr/bin/httpd -k start -DFOREGROUND
├─700 /usr/bin/httpd -k start -DFOREGROUND
├─701 /usr/bin/httpd -k start -DFOREGROUND
└─702 /usr/bin/httpd -k start -DFOREGROUND

Dec 17 18:04:52 arch-linux systemd[1]: Started Apache Web Server.

Now check if the web server is running. Open web browser and type the server ip address:

Step 2. Install MySQL / MariaDb

sudo pacman -S mysql

Initialize MariaDb data directory

sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Start MariaDb server

sudo systemctl start mysqld
sudo systemctl enable mysqld

Verify the MariaDb status

sudo systemctl status mysqld

Secure MySQL installation

The following command should be executed in order to change the default root password for MySQL


At this point, MySQL server is ready.

Step 3. Install PHP

sudo pacman -S php php-apache

Configure apache PHP module

sudo nano /etc/httpd/conf/httpd.conf

Comment out the following line

#LoadModule mpm_event_module modules/

Also copy and paste the following lines to the bottom of the httpd.conf file

LoadModule mpm_prefork_module modules/
LoadModule php7_module modules/
AddHandler php7-script php
Include conf/extra/php7_module.conf

At this point PHP is now installed on Arch Linux. It is good to make sure that PHP is working well on our Arch Linux. Now do the following to test it.

sudo nano /srv/http/test.php

Now paste the following lines


Restart the web server

sudo systemctl restart httpd

Now open web browser and point to the server IP address as follow

Ok at this point we have installed Apache web server, MySQL Server and also PHP.


Leave a Reply

Your email address will not be published. Required fields are marked *