Kodename JPG
IDEN

Installing Apache, MySQL, PHP, and phpMyAdmin on Arch Linux


Written: 2021 · Level: Beginner · Category: Linux


Home > Tutorial > Installing Apache, MySQL, PHP, and phpMyAdmin on Arch Linux

بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم




Apache is a very popular web server, developed by the Apache Software Foundation. This time I'll share my experience on how to set up Apache and how to optionally integrate it with PHP.

Installation



1. sudo pacman -S php apache mariadb php-apache phpmyadmin 2. yay -S php-mcrypt

Configuration



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

Comment out the following line:
LoadModule mpm_event_module modules/mod_mpm_event.so

then uncomment the following line:
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

then add the following and save:

LoadModule php_module modules/libphp.so

AddHandler php-script .php

Include conf/extra/php_module.conf


Start httpd, then check its status:

1. sudo systemctl enable httpd

2. sudo systemctl restart httpd

3. sudo systemctl status httpd


img1

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

then run:

1. sudo systemctl enable mysqld

2. sudo systemctl start mysqld

3. sudo systemctl status mysqld


img2

Once it's running, set a root password for MySQL (if asked any questions, just press Enter. See the image below for an example):
mysql_secure_installation

img3

Let's test PHP. First, create a test.php file in /srv/http/:
sudo nano /srv/http/test.php

img4

Open http://localhost/test.php in your browser:
img5

Next, configure phpMyAdmin:
sudo nano /etc/php/php.ini

then enable the following extensions by removing the semicolon ";" in front of them, or add the extension if it's not in the list:

extension=pdo_mysql

extension=mysqli

extension=bz2

extension=zip

extension=iconv.so


Configure the phpMyAdmin file:
sudo nano /etc/httpd/conf/extra/phpmyadmin.conf

img6

add it to /etc/httpd/conf/httpd.conf, then restart httpd:
Include conf/extra/phpmyadmin.conf

Open http://localhost/phpmyadmin/ in your browser:
img7

Hope this helps.

References



  1. https://wiki.archlinux.org/title/Apache_HTTP_Server
  2. https://wiki.archlinux.org/title/PHP
  3. https://wiki.archlinux.org/title/phpMyAdmin

Like this tutorial? Support the author so there are more free tutorials.

Support via Saweria

Comments