2026 rebuild: use the current Arch documentation as the source of truth
Arch Linux changes quickly, which is why a successful local setup is more useful when it is reproducible than when it follows an old command list. This page now keeps only the local LAMP notes that remain useful as an archive. Before installing or changing a service, check the current ArchWiki page for the installed package and inspect the output on the machine in front of you.
For a local project, make the runtime explicit: record the PHP version and extensions, use a named database account, keep credentials out of version control, and test the application after an upgrade. MariaDB is the current Arch implementation of MySQL; initialise and start the installed service using the current MariaDB guidance. For PHP on Apache, choose the supported integration for the workload and test the server configuration before exposing it beyond a local development network.
The older phpMyAdmin configuration has been removed from this page. A database administration login should not be treated as a normal public site feature. Prefer a private route, VPN, SSH tunnel or other access boundary; use HTTPS, current packages and separate least-privilege accounts where browser access is necessary.
Retained local-development notes
Install Apache, PHP, and MySQL
Install Apache
sudo pacman -S apache
sudo systemctl start httpd
sudo systemctl status httpd
Install PHP
sudo pacman -S php php-apache
Install MySQL (MariaDB)
sudo pacman -S mysql
When prompted, choose MariaDB. Then initialize and start the database:
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
sudo systemctl start mysqld
sudo systemctl status mysqld
Next, secure your MySQL installation by setting a root password, removing anonymous users, removing the test database, and disabling remote root login. Press Enter for the current root password and answer “Yes” to all security questions:
sudo mysql_secure_installation
Verify it’s working:
mysql -u root -p
Enable Apache and MySQL on Startup
sudo systemctl enable mysqld httpd
Configure Apache
Open the main Apache configuration file:
sudo nano /etc/httpd/conf/httpd.conf
At the very bottom of the file, add the following lines:
ServerName localhost
IncludeOptional conf/sites-enabled/*.conf
IncludeOptional conf/mods-enabled/*.conf
Create the directory structure for managing virtual hosts:
sudo mkdir /etc/httpd/conf/sites-available
sudo mkdir /etc/httpd/conf/sites-enabled
sudo mkdir /etc/httpd/conf/mods-enabled
Create a2ensite and a2dissite Scripts
Arch doesn’t ship with Debian-style a2ensite / a2dissite commands, but we can create our own. These scripts make it easy to enable and disable virtual hosts with symlinks, just like you would on Debian or Ubuntu.
a2ensite
#!/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/$1.conf
enabled=/etc/httpd/conf/sites-enabled
site=`ls /etc/httpd/conf/sites-available/`
if [ "$#" != "1" ]; then
echo "Use script: a2ensite 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/$1.conf; then
echo "Success!! Now restart Apache server: sudo systemctl restart httpd"
else
echo -e "Virtual host $avail does not exist!nPlease see available virtual hosts:n$site"
exit 0
fi
fi
a2dissite
#!/bin/bash
avail=/etc/httpd/conf/sites-enabled/$1.conf
enabled=/etc/httpd/conf/sites-enabled
site=`ls /etc/httpd/conf/sites-enabled`
if [ "$#" != "1" ]; then
echo "Use script: a2dissite 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/$1.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
Give the scripts execute permission and copy them to your bin directory:
sudo chmod +x a2ensite a2dissite
sudo cp a2ensite a2dissite /usr/local/bin/
Create a Default Virtual Host
sudo nano /etc/httpd/conf/sites-available/localhost.conf
<VirtualHost *:80>
DocumentRoot "/srv/http"
ServerName localhost
ServerAdmin [email protected]
ErrorLog "/var/log/httpd/localhost-error_log"
TransferLog "/var/log/httpd/localhost-access_log"
<Directory />
Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
Enable the virtual host (note: leave off the .conf extension):
cd /etc/httpd/conf/sites-available/
sudo a2ensite localhost
sudo systemctl restart httpd
Visit http://localhost to confirm it’s working.
Enable PHP on Apache
Open the Apache config:
sudo nano /etc/httpd/conf/httpd.conf
Find and comment out the following line:
#LoadModule mpm_event_module modules/mod_mpm_event.so
Then create a new PHP module configuration file:
sudo nano /etc/httpd/conf/mods-enabled/php.conf
Add the following content:
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
LoadModule php_module modules/libphp.so
Include conf/extra/php_module.conf
Create a test PHP file to verify everything works:
sudo nano /srv/http/info.php
<?php phpinfo(); ?>
Restart Apache and visit http://localhost/info.php:
sudo systemctl restart httpd
You can also verify your Apache configuration and loaded modules with:
sudo apachectl configtest
sudo apachectl -M
Configure PHP Extensions
Install the PHP extensions you’ll need for development:
sudo pacman -S php-gd php-sqlite php-intl php-cgi
Open your PHP configuration file:
sudo nano /etc/php/php.ini
Find and uncomment the following extensions:
extension=gd.so
extension=mysqli.so
extension=iconv.so
extension=intl.so
extension=zip.so
extension=bz2.so
extension=bcmath.so
extension=pdo_mysql.so
extension=pdo_sqlite.so
Install Xdebug
sudo pacman -S xdebug
Edit /etc/php/conf.d/xdebug.ini and uncomment the following lines:
zend_extension=xdebug.so
xdebug.remote_enable=on
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_autostart=on
Install Composer
sudo pacman -S composer
Keep the working directory, database and test data disposable. A local LAMP stack is ready when another developer can reproduce it, the project dependencies are declared, and the services can be checked after an update—not merely when a phpinfo() page happens to load.
Current references: ArchWiki: PHP · ArchWiki: Apache HTTP Server · ArchWiki: MariaDB · Web Development