How install and configure Apache,MariaDB,PHP on Arch Linux. ( Antergos OS )

How install and configure Apache,MariaDB,PHP on Arch Linux. ( Antergos OS )

Today I am going to tell you how install LAMP ( Apache,MariaDB , PHP on Linux ) and configure it.

LAMP stack is set of open source software to up and run web application. Small description about these software will given in each chapter.

To install these software on Arch Linux you can use pacman manager ( graphical tool or terminal ). If you use pacman-manager graphical tool search each software and it will show you latest version available on repository. If you use terminal use this code to update repository first.

 sudo pacman -Syu

Install Apache

Web server is the software which receive the request to web page and take to the web page. Apache is the most widely used web server software which developed and maintain by Apache Software Foundation. Apache is an open-source software available for free.

Now you have up to date pacman repository and can install Apache.

sudo pacman -S apache

After that edit /etc/httpd/conf/httpd.conf file. To open that file on nano,

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

Then comment out the module mention below,

#LoadModule unique_id_module modules/

[ In nano text editor use Ctrl + w search text and remove ‘#’ to comment out a line ]
Then save ( Ctrl + O ) and close ( Ctrl + x ) the file.

Now we can restart Apache server using this command.

sudo systemctl restart httpd

If you get error like ,

httpd: apr_sockaddr_info_get() failed for ####

httpd: Could not reliably determine the server’s fully qualified domain name, using for ServerName

you can add your hostname (To find your hostname just type ‘hostname’ and execute on terminal)  to host file and fix this issue. To do that open host file using nano and add your hostname at the end of line begin with (localhost IP).

 sudo nano /etc/hosts 

Add hostname on this line,       localhost.localdomain       localhost #####(you hostname)

example:       localhost.localdomain      localhost Emalsha-PC

Now you can restart web server using given command. To check whether httpd service run correctly use this command to get service status.

sudo systemctl status httpd

It will give you this kind of result,


Now you can try Apache web server by creating simple html page on /srv/http/ directory.

sudo nano /srv/http/index.html

Then put this html on it,


<title>Welcome Apache Web Server</title>

<h1>This is testing file to Apache web server.</h1>


Save and close the file and browse localhost ( or given IP ex: ) on your browser.If you got this result you successfully installed Apache web server software.


Install MariaDB

MariaDB Server is one of the most popular database servers in the world. It’s made by the original developers of MySQL and guaranteed to stay open source. It is an enhanced, drop-in replacement for MySQL. MariaDB is used because it is fast, scalable and robust, with a rich ecosystem of storage engines, plugins and many other tools make it very versatile for a wide variety of use cases.

Already you have updated your pacman repository and now we can install latest version.

sudo pacman -S mysql

Since 2013 MariaDB is the official default implementation of MySQL in Arch Linux. Therefore when you going to install mysql it will ask whether install MariaDB or Percona server. Use default selection MariaDB and continue installation.

Start MariaDB using this command

sudo systemctl start mysqld

You can check is it running by using this command

sudo systemctl status mysqld

It gives you this kind of result.


Now you have to set up root password and other security settings. To do this use this command.


It will proceed you to some questions and first will ask root password. But very first you haven’t set any password therefore keep it blank and enter. Then it will ask your new password and continue process. It’s better to follow default options it suggested.

If you got error like
error: ‘Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)’
                Check that mysqld is running and that the socket: ‘/var/run/mysqld/mysqld.sock’ exists!

Then try this command.

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


Now MariaDB is ready to use.

Remember :

You want this service run each time therefore you can enable load this service at startup by using this command.

sudo systemctl enable mysqld httpd

If you want these services start use this ,

sudo systemctl start ##### ← service name

if you want to restart

sudo systemctl restart #####

if you want to get current status

sudo systemctl status #####

Install PHP

PHP is a server-side scripting language designed primarily for web development but also used as a general-purpose programming language. Current stable php version is 7.1.2 ( when I write this blog – 18/02/2017) and install using this command.

sudo pacman -S php php-apache

Then edit Apache configuration file

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

First find this line and comment it.

LoadModule mpm_event_module modules/
( put ‘#’ at the beginning)

Then put this lines at the end of the config file.

 LoadModule mpm_prefork_module modules/
 LoadModule php7_module modules/
 AddHandler php7-script php
 Include conf/extra/php7_module.conf
 save and close the file.

Now you can check whether php installed correctly or not by creating simple php file on apache host folder.

nano /srv/http/info.php

and put this lines on it.

<?php     phpinfo(); ?>

You have altered httpd.conf file therefor restart the httpd server to take this updates.

sudo systemctl restart httpd

Now you can browse http://localhost/info.php on your browser and you get result like this.


Wow … You have installed php correctly.

Congratulations ! Now you have LAMP stack and start the building yourself.


2 thoughts on “How install and configure Apache,MariaDB,PHP on Arch Linux. ( Antergos OS )

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s