search
HomeSystem TutorialLINUXHow to Install LAMP Stack with PhpMyAdmin in Arch Linux

Arch Linux provides a flexible cutting-edge system environment and is a powerfully suited solution for developing web applications on small non-critical systems because is a completely open source and provides the latest up-to-date releases on kernels and web software for servers and databases.

The main scope of this tutorial is to guide you through complete step-by-step instructions that in the end will lead to installing one of the most used software combinations in Web Development: LAMP (Linux, Apache, MySQL/MariaDB, and PHP/PhpMyAdmin) on Arch Linux.

Requirements

  • A fresh Arch Linux installation.
  • A LEMP installation on Arch Linux – only the part with configuring a static IP address.

Step 1: Installing LAMP Stack on Arch Linux

1. After minimal system installation with a static IP address and remote system access using SSH, upgrade your Arch Linux box using the pacman utility.

sudo pacman -Syu

2. When the upgrade process finishes, install LAMP from pieces, first install Apache Web Server, and start/verify every server process daemon.

sudo pacman -S apache 
sudo systemctl start httpd 
sudo systemctl enable httpd
sudo systemctl status httpd

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

3. Install PHP dynamic server-side scripting language and its Apache module.

sudo pacman -S php php-apache

4. On the last step install MySQL database, choose 1 (MariaDB) community database fork then start and check daemon status.

sudo pacman -S mysql 
sudo systemctl start mysqld 
sudo systemctl enable mysqld 
sudo systemctl status mysqld

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

Now you have the basic LAMP software installed and started with default configurations so far.

Step 2: Secure MySQL in Arch Linux

5. The next step is to secure the MySQL database by setting a password for the root account, removing anonymous user accounts, removing the test database, and disallowing remote login for the user root (press [Enter] key for the root account current password and answer with Yes on all security questions).

sudo mysql_secure_installation

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

6. Verify MySQL database connectivity by running the following command then leave the database shell with quit or exit statement.

mysql -u root -p

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

Step 3: Modify Apache Main Configuration File

7. The following configurations are most related to Apache Web Server to provide a dynamic interface for Virtual Hosting with PHP scripting language, SSL, or non-SSL Virtual Hosts and can be done by modifying httpd service file configurations.

First, open the main Apache file configuration with your favorite text editor.

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

At the very bottom of the file, append the following two lines.

IncludeOptional conf/sites-enabled/*.conf
IncludeOptional conf/mods-enabled/*.conf

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

The role of Include statements here is to tell Apache that from now on, it should read further configurations from all files that reside in /etc/httpd/conf/sites-enabled/ (for Virtual Hosting) and /etc/httpd/conf/mods-enabled/ ( for enabled server modules) system paths that end in an .conf extension.

8. After Apache has been instructed with these two directives, create the necessary system directories issuing the following commands.

sudo mkdir /etc/httpd/conf/sites-available
sudo mkdir /etc/httpd/conf/sites-enabled
sudo mkdir /etc/httpd/conf/mods-enabled

The sites-available path holds all Virtual Hosts configuration files that are not activated on Apache, but the next Bash script will use this directory to link and enable websites that are located there.

Step 4: Create a2eniste and a2diste Apache Commands

9. Now it’s time to create a2ensite and a2dissite Apache scripts that will serve as commands to enable or disable the Virtual Host configuration file.

Type the cd command to return to your $HOME user path and create your bash a2eniste and a2dissite scripts using your favorite editor.

sudo nano a2ensite

Add the following content to this file.

#!/bin/bash
if test -d /etc/httpd/conf/sites-available && test -d /etc/httpd/conf/sites-enabled  ; then
echo "-------------------------------"
else
mkdir /etc/httpd/conf/sites-available
mkdir /etc/httpd/conf/sites-enabled
fi

avail=/etc/httpd/conf/sites-available/\.conf
enabled=/etc/httpd/conf/sites-enabled
site=`ls /etc/httpd/conf/sites-available/`

if [ "$#" != "1" ]; then
        echo "Use script: n2ensite virtual_site"
        echo -e "\nAvailable virtual hosts:\n$site"
        exit 0
else
if test -e $avail; then
sudo ln -s $avail $enabled
else
echo -e "$avail virtual host does not exist! Please create one!\n$site"
exit 0
fi
if test -e $enabled/\.conf; then
echo "Success!! Now restart Apache server: sudo systemctl restart httpd"
else
echo  -e "Virtual host $avail does not exist!\nPlease see avail virtual hosts:\n$site"
exit 0
fi
fi

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

Now create a2dissite bash script file.

sudo nano a2dissite

Append the following content.

#!/bin/bash
avail=/etc/httpd/conf/sites-enabled/\.conf
enabled=/etc/httpd/conf/sites-enabled
site=`ls /etc/httpd/conf/sites-enabled`

if [ "$#" != "1" ]; then
        echo "Use script: n2dissite virtual_site"
        echo -e "\nAvailable virtual hosts: \n$site"
        exit 0
else
if test -e $avail; then
sudo rm  $avail
else
echo -e "$avail virtual host does not exist! Exiting"
exit 0
fi
if test -e $enabled/\.conf; then
echo "Error!! Could not remove $avail virtual host!"
else
echo  -e "Success! $avail has been removed!\nsudo systemctl restart httpd"
exit 0
fi
fi

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

10. After the files have been created allocate execute permissions and copy them to an $PATH executable directory to make them system-wide available.

sudo chmod  x a2ensite a2dissite
sudo cp a2ensite a2dissite /usr/local/bin/
sudo a2ensite

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

Step 5: Create Virtual Hosts in Apache

11. Virtual Host default configuration file for Apache Web server on Arch Linux is provided by httpd-vhosts.conf file located in /etc/httpd/conf/extra/ path but if you have a system that uses a lot of Virtual Hosts can be very difficult to keep track of what website is activated or not and.

If you want to disable a website you must comment or delete all of its directives and that can be a difficult mission if your system provides a lot of websites and your website has more configuration directives.

Using sites-available and sites-enabled paths greatly simplify the job of enabling or disabling websites and also preserve all your website’s configuration files even whether they are activated or not.

In the next step, we are going to construct the first Virtual Host configuration file for tecmint.com in the sites-available directory that points to the default DocumentRoot path for serving website files (/srv/http.

sudo nano /etc/httpd/conf/sites-available/tecmint.com.conf

Add the following content to configure the virtual host for tecmint.com.

<virtualhost>
    ServerName tecmint.com
    ServerAlias www.tecmint.com
    <strong>DocumentRoot /srv/http/tecmint.com</strong>
    ServerAdmin [email protected]

    ErrorLog "/var/log/httpd/tecmint.com-error_log"
    CustomLog "/var/log/httpd/tecmint.com-access_log" combined

    <directory>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </directory>
</virtualhost>

The most important statements here are Port and ServerName directives that instruct Apache to open a network connection on port 80 and redirect all queries with domain name to serve files located in /srv/http/tecmint.com path.

12. Next, create the document root directory for tecmint.com with appropriate permissions.

sudo mkdir -p /srv/http/tecmint.com
sudo chown -R $USER:$USER /srv/http/tecmint.com
sudo chmod -R 755 /srv/http/tecmint.com

13. Enable the tecmint.com virtual host by creating a symlink in the sites-enabled directory.

sudo ln -s /etc/httpd/conf/sites-available/tecmint.com.conf /etc/httpd/conf/sites-enabled/

14. After the virtual host configuration file has been created, activate it then restart the httpd daemon to view changes.

sudo a2ensite tecmint.com
sudo systemctl restart httpd

15. To verify the virtual host, create a simple index.html file for testing.

echo '<h1 id="Welcome-to-TecMint">Welcome to TecMint!</h1>' | sudo tee /srv/http/tecmint.com/index.html

and then point your browser to https://tecmint.com, if you run it from an Arch system or http://Arch_IP if you use a remote system.

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

Step 6: Enable SSL with Virtual Hosting on LAMP

16. SSL (Secure Sockets Layer) is a protocol designed to encrypt HTTP connections over networks or the Internet, which makes data flow to be transmitted over a secure channel using symmetric/asymmetric cryptography keys and is provided in Arch Linux by mod_ssl and Certbot packages.

sudo yum install certbot python3-certbot-apache mod_ssl

17. Next, use certbot to automatically obtain and install the SSL certificate for your domain.

sudo certbot --apache -d tecmint.com -d www.tecmint.com

Certbot will automatically configure Apache to use the obtained SSL certificate and it will also set up automatic HTTP to HTTPS redirection.

18. Again point your browser to your domain name, but this time using HTTPS protocol – https://tecmint.com – this time you can now see your Apache Virtual Host serves the same content using an HTTPS secure connection.

Step 7: Enable PHP for Apache on Arch Linux

19. By default Apache only serves HTML static file content in Arch Linux with no dynamic scripting language support.

To activate PHP first open Apache main configuration file, then search and uncomment the following LoadModule statement (php-apache does not work with mod_mpm_event in Arch Linux).

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

Using [Ctrl] [w] search and comment on the following line to look like this.

#LoadModule mpm_event_module modules/mod_mpm_event.so

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

20. Then create a new file for the PHP module in the mods-enabled path with the following content.

sudo nano /etc/httpd/conf/mods-enabled/php.conf

Add the exact following content (you must use mod_mpm_prefork).

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
LoadModule php_module modules/libphp.so
AddHandler php-script .php
Include conf/extra/php_module.conf

21. To verify the setting create PHP a file named info.php in your DocumnetRoot (/srv/http/tecmint.com), then restart Apache and point your browser to the info.php file: https://tecmint.com/info.php.

echo "<?php phpinfo(); ?>" | sudo tee /srv/http/tecmint.com/info.php
sudo systemctl restart httpd

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

That’s it! If everything looks like the image above, you now have PHP dynamic server-side scripting language enabled on Apache and you can now develop websites using Open Source CMS like WordPress for example.

If you want to verify Apache syntax configurations and see a list of loaded modules without restarting the httpd daemon run the following commands.

sudo apachectl configtest
sudo apachectl -M

Step 8: Install PhpMyAdmin in Arch Linux

22. If you don’t master the MySQL command line and want simple remote access to the MySQL database provided through the web interface then you need the PhpMyAdmin package installed on your Arch box.

sudo pacman -S phpmyadmin

23. After the packages have been installed you need to enable some PHP extensions (mysqli.so for internal authentication) and you can, also, enable other modules needed for future CMS platforms like openssl.so, imap.so or iconv.so etc.

sudo nano /etc/php/php.ini

Locate and uncomment the above extensions.

extension=mysqli.so
extension=mysqli
mysqli.allow_local_infile = On

Also, on the same file, search and locate open_basedir statement and add PhpMyAdmin system path (/etc/webapps/ and /usr/share/webapps/) to make sure PHP can access and read files under those directories (If you, also, change Virtual Hosts DocumentRoot path from /srv/http/ to another location you need to append the new path here too).

open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

24. The last thing you need to do in order to access PhpMyAdmin Web Interface is to add PhpMyAdmin Apache statements on Virtual Hosts.

As a security measure will make sure that the PhpMyAdmin Web Interface can be accessible only from localhost (or system IP address) using HTTPS protocol and not from other different Virtual Hosts. So, open your tecmint.com.conf.conf Apache file, and at the bottom, add the following content.

sudo nano /etc/httpd/conf/sites-available/tecmint.com.conf

Add the following configuration to ensure proper access:

Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"

<directory>
    DirectoryIndex index.html index.php
    AllowOverride All
    Options FollowSymlinks
    Require all granted
</directory>

25. Afterwards restart the Apache daemon and create a symbolic link between the /usr/share/webapps/phpMyAdmin/ path and our newly defined Virtual Host path (/srv/http/tecmint.com).

sudo systemctl restart httpd
sudo ln -s /usr/share/webapps/phpMyAdmin/ /srv/http/tecmint.com/

26. Finally point your browser to the following address and you should be able to access your PhpMyAdmin Web Interface at:

https://tecmint.com/phpmyadmin
OR
https://system_IP/phpmyadmin

How to Install LAMP Stack with PhpMyAdmin in Arch Linux

These are some of the main configuration settings on LAMP needed to transform an Arch Linux system into a simple but powerful, fast, and robust web platform with cutting-edge server software for small non-critical environments.

If you get stubborn and still want to use it in a large production environment you should arm yourself with plenty of patience pay extra attention to package updates and make regular system backup images for a fast system restoration in case of system failures.

The above is the detailed content of How to Install LAMP Stack with PhpMyAdmin in Arch Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to Create GUI Applications In Linux Using PyGObjectHow to Create GUI Applications In Linux Using PyGObjectMay 13, 2025 am 11:09 AM

Creating graphical user interface (GUI) applications is a fantastic way to bring your ideas to life and make your programs more user-friendly. PyGObject is a Python library that allows developers to create GUI applications on Linux desktops using the

How to Install LAMP Stack with PhpMyAdmin in Arch LinuxHow to Install LAMP Stack with PhpMyAdmin in Arch LinuxMay 13, 2025 am 11:01 AM

Arch Linux provides a flexible cutting-edge system environment and is a powerfully suited solution for developing web applications on small non-critical systems because is a completely open source and provides the latest up-to-date releases on kernel

How to Install LEMP (Nginx, PHP, MariaDB) on Arch LinuxHow to Install LEMP (Nginx, PHP, MariaDB) on Arch LinuxMay 13, 2025 am 10:43 AM

Due to its Rolling Release model which embraces cutting-edge software Arch Linux was not designed and developed to run as a server to provide reliable network services because it requires extra time for maintenance, constant upgrades, and sensible fi

12 Must-Have Linux Console [Terminal] File Managers12 Must-Have Linux Console [Terminal] File ManagersMay 13, 2025 am 10:14 AM

Linux console file managers can be very helpful in day-to-day tasks, when managing files on a local machine, or when connected to a remote one. The visual console representation of the directory helps us quickly perform file/folder operations and sav

qBittorrent: A Powerful Open-Source BitTorrent ClientqBittorrent: A Powerful Open-Source BitTorrent ClientMay 13, 2025 am 10:12 AM

qBittorrent is a popular open-source BitTorrent client that allows users to download and share files over the internet. The latest version, qBittorrent 5.0, was released recently and comes packed with new features and improvements. This article will

Setup Nginx Virtual Hosts, phpMyAdmin, and SSL on Arch LinuxSetup Nginx Virtual Hosts, phpMyAdmin, and SSL on Arch LinuxMay 13, 2025 am 10:03 AM

The previous Arch Linux LEMP article just covered basic stuff, from installing network services (Nginx, PHP, MySQL, and PhpMyAdmin) and configuring minimal security required for MySQL server and PhpMyadmin. This topic is strictly related to the forme

Zenity: Building GTK  Dialogs in Shell ScriptsZenity: Building GTK Dialogs in Shell ScriptsMay 13, 2025 am 09:38 AM

Zenity is a tool that allows you to create graphical dialog boxes in Linux using the command line. It uses GTK , a toolkit for creating graphical user interfaces (GUIs), making it easy to add visual elements to your scripts. Zenity can be extremely u

Top 22 Best Music Players for LinuxTop 22 Best Music Players for LinuxMay 13, 2025 am 09:25 AM

Some may describe it as their passion, while others may consider it a stress reliever or a part of their daily life. In every form, listening to music has become an inseparable part of our lives. Music plays different roles in our lives. Sometimes it

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment