Your cart is currently empty!
How to Install Nginx, PHP, MariaDB, and PhpMyAdmin (LEMP) on Arch Linux
If you’re running Arch Linux and want a fast, reliable web stack, the LEMP setup is a great choice.
LEMP stands for Linux, Nginx, MariaDB, and PHP, and it’s a lightweight alternative to the more common Apache-based stacks.
In this guide, we’ll walk through installing and configuring:
- Nginx – web server
- PHP – dynamic content
- MariaDB – database
- phpMyAdmin – database management interface
Step 1 – Update Your System
Before installing anything, make sure your system is up to date:
sudo pacman -SyuStep 2 – Install Nginx
sudo pacman -S nginxEnable and start Nginx:
sudo systemctl enable nginx
sudo systemctl start nginxCheck if it’s running by visiting http://localhost in your browser. You should see the “Welcome to Nginx” page.
Step 3 – Install PHP (PHP-FPM) and Extensions
We’ll use PHP-FPM for better performance with Nginx.
sudo pacman -S php php-fpm php-gd php-intl php-mysql php-curl php-zipEnable and start PHP-FPM:
sudo systemctl enable php-fpm
sudo systemctl start php-fpmEdit the PHP-FPM config to use the unix socket:
sudo nano /etc/php/php.ini- Uncomment or set:
cgi.fix_pathinfo=0Then edit PHP-FPM pool config:
sudo nano /etc/php/php-fpm.d/www.conf- Change:
listen = /run/php-fpm/php-fpm.sock- Ensure:
listen.owner = http
listen.group = http
listen.mode = 0660Restart PHP-FPM:
sudo systemctl restart php-fpmStep 4 – Configure Nginx to Work with PHP
Open the default server block:
sudo nano /etc/nginx/sites-available/defaultIf sites-available doesn’t exist (Arch often keeps configs in /etc/nginx/conf.d), create a file:
sudo nano /etc/nginx/conf.d/default.confExample configuration:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.php index.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}Test the Nginx configuration:
sudo nginx -tReload Nginx:
sudo systemctl reload nginxStep 5 – Install and Configure MariaDB
sudo pacman -S mariadbInitialize the database:
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysqlEnable and start MariaDB:
sudo systemctl enable mariadb
sudo systemctl start mariadbRun the secure installation script:
sudo mysql_secure_installationFollow the prompts to set a root password and secure the server.
Step 6 – Install phpMyAdmin
sudo pacman -S phpmyadminLink phpMyAdmin into your Nginx document root:
sudo ln -s /usr/share/webapps/phpMyAdmin /usr/share/nginx/html/phpmyadminEdit your PHP configuration for phpMyAdmin support:
sudo nano /etc/php/php.iniUncomment or add:
extension=mysqli
extension=pdo_mysqlRestart PHP-FPM and Nginx:
sudo systemctl restart php-fpm
sudo systemctl restart nginxNow you can access phpMyAdmin at:
http://localhost/phpmyadminStep 7 – Test PHP
Create a test file:
echo "<?php phpinfo(); ?>" | sudo tee /usr/share/nginx/html/info.phpOpen:
http://localhost/info.phpIf you see the PHP info page, PHP is working.
Step 8 – Final Security Tips
- Remove the
info.phpfile after testing:
sudo rm /usr/share/nginx/html/info.php- Use strong passwords for MariaDB and phpMyAdmin.
- Consider enabling HTTPS with Let’s Encrypt.
Conclusion
You now have a fully working LEMP stack with phpMyAdmin on Arch Linux.
This setup is fast, lightweight, and ready for your PHP-based projects.
If you run into permission errors, check file ownership:
sudo chown -R http:http /usr/share/nginx/htmlThat’s it — you’re ready to start building and deploying web apps.

Tech enthusiast and content creator passionate about making technology simple for everyone. I share practical tips, guides, and reviews on the latest in computers, software, and gadgets. Let’s explore the digital world together!
