Table of Contents
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $300 by adding new articles!

How to Install PHP 7.3 on an Arch Linux Webserver

Last Updated: Fri, May 31, 2019
Arch Linux Guides PHP


  • A Vultr server running up to date Arch Linux (see this article.)
  • A running webserver, either Apache or Nginx
  • Sudo access.
    • Commands required to be ran as root are prefixed by #. The recommended way to run commands as root is to, as a regular user, prefix each of them with sudo.
  • Have a text editor installed, and be familiar with it, such as vi, vim, nano, emacs or a similar editor

Install PHP 7.3 On Your Webserver

Install PHP and FastCGI for PHP:

# pacman -S php-fpm

Visit PHP's timezone list

Set your timezone. For example, if you chose the category "America" and wanted to use "New_York", edit /etc/php/php.ini and set the following:

date.timezone = America/New_York

Start FastCGI for PHP, and make it start after every boot:

# systemctl enable --now php-fpm

Configure PHP for your webserver.

For Apache

Create the file /etc/httpd/conf/extra/php-fpm.conf, with the following contents. Make sure to copy this exactly as-is; a common error is putting spaces around the pipe character, but this is not a shell command, and there can be no spaces:

DirectoryIndex index.php index.html
<FilesMatch \.php$>
    SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/"

Allow Apache to use FastCGI by editing /etc/httpd/conf/httpd.conf, and add the following to the end of the LoadModule list:

LoadModule proxy_module modules/
LoadModule proxy_fcgi_module modules/

To allow using .php files on all websites hosted by Apache, edit /etc/httpd/conf/httpd.conf, and add this to the end. If you're running multiple host directories; for example, virtual hosts, or separate HTTP/HTTPS directories; and you want to only allow .php files on some of them, edit their configuration files. Within the VirtualHost block, add the following:

Include conf/extra/php-fpm.conf

Finally, restart Apache:

# systemctl restart httpd

For Nginx

Allow Nginx to use FastCGI for PHP by creating the file /etc/nginx/php.conf with the following contents:

# Correctly handle request like /test.php/foo/blah.php or /test.php/
fastcgi_split_path_info ^(.+?\.php)(/.*)$;

try_files $uri $document_root$fastcgi_script_name =404;

# Mitigate <nowiki></nowiki> vulnerabilities
fastcgi_param HTTP_PROXY "";

fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

Allow Nginx to use FastCGI by editing /etc/nginx/nginx.conf, and to every server block you want to use PHP with, add the following. Alternatively, if you are using virtual hosts, edit each host's configuration file:

location ~ \.php$ {
    root         /usr/share/nginx/html/;
    include      php.conf;

Restart Nginx:

# systemctl restart nginx

Test PHP

Within the appropriate directory, create test.php with the following contents:

<?php phpinfo(); ?>

In a web browser, visit http://YOUR-SERVER-WEB-ADDRESS-OR-IP/test.php, and you will see a webpage with your PHP version and configuration.

Remember to delete the test.php test file you just created.

Want to contribute?

You could earn up to $300 by adding new articles