Install LAMP Stack (Apache, MariaDB, PHP, phpMyAdmin) on Arch Linux based systems

LAMP Stands for Linux, Apache, MySQL, MariaDB, MongoDB, PHP, PERL, PYTHON, PhpMyAdmin. LAMP is combination of operating system and bunch of open-source software which is developed by different organizations.

In this tutorial, we will show you about LAMP Stack installation On Arch Linux.

Assume we have already installed Arch Linux & Desktop Environment too. If no, follow the below articles for further installation procedure.

Arch Linux additional articles

1) Update your system upto date

Use the below command to keep your system upto date.

[Update your system to latest package]
$ sudo pacman -Syu

2) Install Apache

Apache is a Free open-source multi-platform web server. It’s support wide range of language such as (.html, .php, .pl, .cgi, etc..,) Apache is developed and maintained by open community of developers under Apache Software Foundation. The default apache directory location in Fedora are /srv/http

[Install Apache]
$ sudo pacman -S apache

[Start the Apache service]
$ sudo systemctl start httpd.service

[Enable Apache in boot]
$ sudo systemctl enable httpd.service

[Check Apache Status]
$ sudo systemctl status httpd.service

By default you will not get apache index page, how other distros shows. We have to create apache index.html file manually and add the below contents.

$ sudo nano /srv/http/index.html
<html>
<title>Welcome</title>
<body>
<h2>Hello, Welcome to Arch</h2>
</body>
</html>

Open your web browser and navigate to http://localhost/ or http://your-server-ip-address/ or http://127.0.0.1/
install-lamp-on-manjaro-arch-linux-1
Now, You have successfully installed and configured apache on your Arch Linux system.

3) Install MariaDB

MariaDB is the default implementation of MySQL in Arch Linux, provided with the mariadb package , so just fire the below command to install it. MariaDB is open-source relational database management system (RDBMS) which is supporting database access. It’s robust, scalable, and reliable SQL server for high availability databases as free of cost.

[Install MariaDB]
$ sudo pacman -S mysql

Run the following command before starting the mysqld.service to initializes the MariaDB data directory, MariaDB installation directory and creates the system tables.

[Initializes the MariaDB date directory]
$ sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

[Start the MariaDB service]
$ sudo systemctl start mysqld

[Enable MariaDB in boot]
$ sudo systemctl enable mysqld

[Check MariaDB Status]
$ sudo systemctl status mysqld.service

3a) Set MySQL root password

By default there is no password for MySQL instant and you need to run the below command to set the root password for security reason. I advise you to secure MySQL installation using mysql_secure_installation method which will set root password and adjust other settings to make more secure.

[MariaDB Secure installation]
$ sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

Enter current password for root (enter for none): Press Enter
OK, successfully used password, moving on...

Set root password? [Y/n] y
New password: ******
Re-enter new password: ******
Password updated successfully!
Reloading privilege tables..
 ... Success!

Remove anonymous users? [Y/n] y
 ... Success!

Disallow root login remotely? [Y/n] y
 ... Success!

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Access the MariaDB database on terminal by issuing below command.

$ sudo mysql -u root -p
Enter the password: *****

install-lamp-on-manjaro-arch-linux-2

One Comment on “Install LAMP Stack (Apache, MariaDB, PHP, phpMyAdmin) on Arch Linux based systems”

  1. Excelent!

    A step by step tutorial without dificulties, and easy to understand. Thanks for your effort.

    NOTE: Sorry for my bad English, my native language is Spanish.

Leave a Reply

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