How to install LAMP Server on Arch Linux

Arch Linux Tutorial - Hello Arch Linux users, today we will guide you how to install LAMP Server on Arch Linux. On this tutorial, we use Arch Linux 2017, Linux Kernel 4.12. But, this tutorial should works on any Arch version. LAMP Server stands for Linux, Apache, MySQL/MariaDB and PHP. These are great packages to create a powerful web application server.

Prerequisites

  • Internet connection
  • root access

Steps to install LAMP Server on Arch Linux

Step 1. Update Arch

This is important to keep our system up to date. Use the following command to update Arch Linux

sudo pacman -Syu

Step 2. Install Apache web server

Apache is a lightweight and powerful web server used by millions of internet users. You can install it using this single command.

sudo pacman -S apache

Output

[dhani@archServer /]$ sudo pacman -S apache
[sudo] password for dhani: 
resolving dependencies...
looking for conflicting packages...

Packages (3) apr-1.6.2-1  apr-util-1.6.0-1  apache-2.4.27-1

Total Download Size:   1.82 MiB
Total Installed Size:  7.34 MiB

:: Proceed with installation? [Y/n] 

Now start and enable httpd

sudo systemctl start httpd
sudo systemctl status httpd

Now open web browser and type the IP address of the Arch Linux to see if the web server is running well. You should see something like this.

apache arch linux

Step 3. Install MariaDB

Now its time to install MariaDB server on Arch. Use the following command to install MySQL Server (MariaDB) on Arch Linux.

sudo pacman -S mysql

Configure MariaDB

First, we need to initialize the database.

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

Secure MySQL installation

mysql_secure_installation

Follow on screen wizard by answering some question such as changing the root password etc.

Start and enable MySQL

sudo systemctl start mariadb
sudo systemctl enable mariadb

Step 4. Install PHP

Now install PHP and some modules with this command

sudo pacman -Sy php php-apache php-gd php-mcrypt

Output sample

install php on arch[5]

Edit php configuration

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

Add the following lines to the conf file

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

Now comment line below

#LoadModule mpm_event_module modules/mod_mpm_event.so

And uncomment line below

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

Now restart apache

sudo systemctl restart httpd

At this point, our LAMP Server is ready. Thanks for reading this how to install LAMP Server on Arch Linux. See you in another tutorial.

Latest

1 comments:

Thanks for the article, maybe a tip for firewall changes may help:
ERR_CONNECTION_REFUSED


EmoticonEmoticon