Install NginX and start the service:
pacman -S install nginx
systemctl start nginx

Test default html homepage is loading: should be greeted by the default html ‘Welcome to nginx’ page

Now to get php working:
There are a few ways you can get php to serve via nginx and plenty of blogs that discuss the different options available including pros and cons of each method. The method I’ve chosen is to proxy requests to php-fpm via the FCGI protocol using unix sockets.

First I’m going to neaten up my nginx.conf file and separate my virtual hosts file similar to Debian simply because I like my config files that way. To do so we’ll move everything after the server{ directive into a debian style virtual hosts file and add the following line at the end of your nginx.conf file:

nano /etc/nginx/nginx.conf

include /etc/nginx/sites-enabled/*;

mkdir sites-enabled
nano /etc/nginx/sites-enabled/default

Paste everything after the server{ directive into your virtual hosts file. The virtual hosts file will still be a bit of a mess, but we’ll tidy this up later, for now I just wanted to separate the config.

Next install php components:
pacman -S php php-fpm

Ensure that php is listening in the right place:
nano /etc/php/php-fpm.conf

;listen =
listen = /run/php-fpm/php-fpm.sock

Now I’m going to tidy up my virtual hosts file to serve php and remove any extraneous config at the same time:
nano /etc/nginx/sites-enabled/default

server {
listen 80;
server_name www.homecomputerlab.com;
root /var/www;
index index.html index.htm index.php;

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;


Next we need to ensure that php is allowed to execute from our web root directory:
nano /etc/php/php.ini

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

Restart both php-fpm and nginx:
systemctl restart php-fpm
systemctl restart nginx

Create a php info script for testing:
nano /var/www/info.php

<?php phpinfo(); ?>

Finally test that php is now being served correctly:

Once php is loading correctly its just a simple matter of installing and configuring mariadb for your sql database:
pacman -S mariadb
systemctl start mysqld

Ensure that the mysql extension is uncommented to allow mysql and php to communicate:
nano /etc/php/php.ini

uncomment extension=mysql.so

You can now download wordpress as follows:
cd /var/www/
wget http://wordpress.org/latest.tar.gz
tar -xvf latest.tar.gz

And from here you should now be able to then follow the famous wordpress 5min install:

Finally it’s a good idea to set the following services to automatically start at boot time so that your webserver/wordpress site is available immediately after a reboot:
systemctl enable nginx php-fpm mysqld

5 comments so far

Add Your Comment
  1. Hey thanks a bunch. This tutorial worked great! Keep up the good work and thanks for sharing.

  2. thanks for sharing!
    only a note: the 1st line “pacman -S install nginx” should read “pacman -S nginx”


  3. Thanks for posting this. I’ve tried to do this with a symlink from my own project folder to /var/www and I get a 403 status code. Have you faced this situation before?

  4. Thanks! It works!!

    @José Mota
    You should check if user `http` has permissions to access the content available through your symlink.

  5. I cοuldn’t resist commenting. Perfectly written!