This article covers installation and configuration of LEMP (Linux + NGINX + MySQL + PHP) on Arch Linux.



See this guide.


There are 2 versions of NGINX available in the repo: mainline and stable. NGINX blog recommends installing the mainline version. This can be done with:

pacman -S nginx-mainline


Install mariadb with:

pacman -S mariadb


Install php and php-fpm with:

pacman -S php php-fpm


  1. Uncomment in /etc/php/php.ini:
  2. Add a server in NGINX (assuming document root is /srv/http/localhost):

    server {
        listen              80;
        listen              443 ssl;
        server_name         localhost;
        root                /srv/http/localhost;
        index               index.php;
        location ~ \.php$ {
            include         fastcgi.conf;
            fastcgi_index   index.php;
            fastcgi_pass    unix:/run/php-fpm/php-fpm.sock;

    Some people may notice that: in /etc/nginx, there is another file fastcgi_params very similar to fastcgi.conf. The difference is explained here. In general, using fastcgi.conf is recommended because it sets fastcgi parameter SCRIPT_FILENAME for you.


  1. Create document root:

    mkdir -p /srv/http/localhost
  2. Add file index.php in document root:

    $host = "localhost";
    $user = "root";
    $passwd = "";
    $conn = new mysqli($host, $user, $passwd);
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    echo "Connected successfully";
  3. Start systemd services:

    systemctl start mysqld
    systemctl start php-fpm
    systemctl start nginx
  4. Open browser at http://localhost/. You should be able to see a line:

    Connected successfully