How to install LAMP Server on Arch Linux 2017 Server

Hello, today we will show you how to install LAMP Server on Arch Linux 2017 Server. Please don’t get confuse with the term I used here. Arch Linux Server refers to a headless Arch Linux with no Desktop Environment installed. We want to try how this Arch Linux performs as a server on a working environment. We believed that Arch Linux is a rock solid distribution and its not only great for Desktop but also for Server use. Installing LAMP Server on Arch Linux wasn’t hard. All packages are available in Pacman repository. With a little efforts, we can have a powerful web server on top of Arch Linux.

Before we go through the installation steps, you may want to check out our other tutorial to install LAMP Server on other distributions below:

LAMP stands for Linux Apache MySQL/MariaDB and PHP. After we have LAMP Server on Arch Linux, we can then install some appliance such as Owncloud, Nextcloud, Pydio, and many more.

Steps to install LAMP Server on Arch Linux 2017

  • Install Apache web server
  • Install MySQL Server (MariaDB)
  • Install PHP

Step 1. Install Apache web server on Arch Linux

sudo pacman -S apache

Output:

[root@archServer]: ~># pacman -S apache
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 Apache

 

sudo systemctl start httpd
sudo systemctl enable httpd

Now open a web browser and point it to the Arch Linux IP address. You should see something like this

install lamp server on arch linux

Step 2. Install MariaDB Server

Now install MariaDB with the following command

pacman -S mysql

Output

[root@archServer]: ~># pacman -S mysql
:: There are 2 providers available for mysql:
:: Repository extra
   1) mariadb
:: Repository community
   2) percona-server

Enter a number (default=1): 1
resolving dependencies...
looking for conflicting packages...

Packages (6) boost-libs-1.64.0-4  jemalloc-1:5.0.1-3  libevent-2.1.8-1  libmariadbclient-10.1.25-1  mariadb-clients-10.1.25-1  mariadb-10.1.25-1

Total Download Size:    34.31 MiB
Total Installed Size:  239.91 MiB

:: Proceed with installation? [Y/n]

After installing MariaDB, execute the following command first. Otherwise, you will get error when trying to enable the service.

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

#Start Mariadb
systemctl start mariadb

Secure MySQL installation

mysql_secure_installation

Output:

[root@archServer]: ~># mysql_secure_installation

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

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

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

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

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


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

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

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

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

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

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!

Step 3. Install PHP

Use this command to install PHP on Arch Linux

pacman -S php php-apache

Output:

[root@archServer]: ~># pacman -S php
resolving dependencies...
looking for conflicting packages...

Packages (2) libzip-1.2.0-1  php-7.1.8-1

Total Download Size:    3.27 MiB
Total Installed Size:  16.91 MiB

:: Proceed with installation? [Y/n]

So now we have installed Apache, MySQL and PHP. And now we have a fully functioning LAMP Server. We hope this article is useful for you who want to build a web server on Arch Linux. Thanks to read the tutorial how to install LAMP Server on Arch Linux 2017 and stay tuned on this blog to get more article like this.

Update:

After installing PHP, we need to configure it, otherwise it will not work properly.

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

Next, comment the following line

#LoadModule mpm_event_module modules/mod_mpm_event.so

Next uncomment the following line

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

Finally restart httpd service

systemctl restart httpd

That’s it.

3 Comments

  1. Got this message:
    httpd: Syntax error on line 538 of /etc/httpd/conf/httpd.conf: Cannot load modules/libphp7.so into server: /etc/httpd/modules/libphp7.so: cannot open shared object file: No such file or directory

1 Trackback / Pingback

  1. Arch Linux Tutorial - How to install Owncloud 10 on Arch Linux 2017

Leave a Reply

Your email address will not be published.


*