• WordPress
  • cPanel
  • Softaculous
  • KVM Virtualization
  • Vmware Virtualization
  • Proxmox
Saturday, June 14, 2025
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
No Result
View All Result
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux

How to Set Up LAMP Stack on Arch Linux

in Arch Linux, Linux OS
How to Set Up LAMP Stack on Arch Linux

Setting up a LAMP stack on Arch Linux can be a bit challenging, but the benefits of a Linux, Apache, MySQL, and PHP environment are undeniable. This powerful combination is the backbone of many popular websites and applications. In this tutorial, we’ll walk you through the process of how to set up a LAMP stack on Arch Linux step by step.

Prerequisites

Before you begin, make sure you have Arch Linux installed on your system. You should also have sudo privileges and an internet connection to download and install the necessary packages.

How to Set Up LAMP Stack on Arch Linux

Update Your System

First, it’s important to ensure that your Arch Linux system is up to date. To do this, run the following command:

sudo pacman -Syu

Install Apache on Arch Linux

To install the Apache web server on Arch Linux, execute the following command:

sudo pacman -S apache

Once the installation is complete, enable and start the Apache service:

sudo systemctl enable httpd
sudo systemctl start httpd

To verify that Apache is running, open a web browser and navigate to http://localhost. You should see the Apache default page.

Install MySQL (MariaDB) on Arch Linux

Arch Linux does not provide MySQL by default, but you can use MariaDB as a drop-in replacement. To install MariaDB, run:

sudo pacman -S mariadb

Next, run the following command to set up the initial database:

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

Enable and start the MariaDB service:

sudo systemctl enable mysqld
sudo systemctl start mysqld

Secure your MariaDB installation by running the following command and following the prompts

sudo mysql_secure_installation

You can learn more about MariaDB installation in our guide on how to install MariaDB on Arch Linux.

Install PHP on Arch Linux

To install PHP on Arch Linux, execute the following command:

sudo pacman -S php php-apache

Next, you’ll need to configure Apache to use PHP. Open the /etc/httpd/conf/httpd.conf file with your favorite text editor, such as Vim, and add the following lines at the end of the LoadModule section:

LoadModule php7_module modules/libphp7.so
Include conf/extra/php7_module.conf

After adding these lines, restart the Apache service:

sudo systemctl restart httpd

To test PHP, create a file named info.php in the /srv/http/ directory with the following content:

<?php
phpinfo();
?>

Now, open a web browser and navigate to http://localhost/info.php. You should see the PHP information page.

Configure Firewall

To allow external access to your web server, you’ll need to configure your firewall. If you’re using iptables, you can follow our guide on how to install and configure fail2ban on Arch Linux for an extra layer of security.

For other firewalls, consult their respective documentation for instructions on how to open port 80 (HTTP) and 443 (HTTPS).

Install phpMyAdmin (Optional)

If you want to manage your MySQL databases through a web interface, you can install phpMyAdmin. This is an optional step, but it can make database management much easier, especially if you’re not familiar with command-line database management.

  1. First, install the necessary packages from the Arch Linux repository using the following command:
sudo pacman -S phpmyadmin
  1. Next, you need to configure Apache to serve phpMyAdmin. Create a new configuration file for phpMyAdmin by running:
sudo nano /etc/httpd/conf/extra/phpmyadmin.conf
  1. Add the following content to the phpmyadmin.conf file:
Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
<Directory "/usr/share/webapps/phpMyAdmin">
    DirectoryIndex index.php
    AllowOverride All
    Options FollowSymlinks
    Require all granted
</Directory>
  1. Save and exit the file by pressing Ctrl + X, then Y, and finally Enter.
  2. Now, include the phpmyadmin.conf file in the main Apache configuration file by opening it:
sudo nano /etc/httpd/conf/httpd.conf
  1. Add the following line at the end of the httpd.conf file:
Include conf/extra/phpmyadmin.conf
  1. Save and exit the file.
  2. Restart Apache to apply the changes:
sudo systemctl restart httpd
  1. Finally, open your browser and visit http://your_server_ip/phpmyadmin. Log in with your MySQL or MariaDB credentials to start managing your databases.

Step 7: Secure Your LAMP Stack

To ensure the security of your LAMP stack, you should take some additional measures:

  1. Disable root login on Arch Linux.
  2. Use SSH public key authentication instead of passwords.
  3. Enable two-factor authentication for extra security.
  4. Install and configure Fail2Ban to protect your server from brute-force attacks.
  5. Set up Let’s Encrypt SSL to secure your web server with HTTPS.

By following these steps, you’ll have a fully functional and secure LAMP stack on your Arch Linux server. You can now start deploying your web applications and enjoy the flexibility and power of Arch Linux as a web server platform.

ShareTweet
Previous Post

Set Up File Sharing Server on Arch Linux

Next Post

How to Set up FTP Server on Arch Linux

Related Posts

How to Install Tomcat on Rocky Linux

How to Install Apache Tomcat on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

Leave a Reply Cancel reply

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

Golden Host VPS
  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.

  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.