Tutorials  /  Linux Basics

Install PHP 7.3 on Arch Linux with Apache or Nginx

Ccentron Redaktion · June 2025 ·4 min read ·Linux Basics, Tutorial

Contents

  1. System Requirements
  2. Installing PHP and FastCGI
  3. Setting the Time Zone for PHP
  4. Starting and Enabling PHP FastCGI
  5. PHP Configuration for Apache
  6. PHP Configuration for Nginx
  7. Testing PHP Setup
  8. Conclusion

System Requirements

  • A server with an updated Arch Linux installation
  • An active web server (Apache or Nginx)
  • Sudo privileges
  • Commands that must be executed with root access are marked with #. It is advised to use sudo before each command when operating as a normal user
  • An installed text editor (e.g., vi, vim, nano, emacs) and basic familiarity with its usage
OPS

Rather have your server managed?

centron takes care of updates, monitoring and troubleshooting: managed servers from €54.04 per month, run in our own data center in Germany. View managed servers →

Prefer to manage it yourself? Cloud servers from €4.04 per month →

Installing PHP and FastCGI

To set up PHP along with its FastCGI process manager, run the following:

Console
# pacman -S php-fpm

Setting the Time Zone for PHP

Visit PHP’s official timezone list. Once you’ve chosen your timezone, such as "America/New_York", modify the /etc/php/php.ini file accordingly:

Code
date.timezone = America/New_York

Starting and Enabling PHP FastCGI

Enable and launch the PHP FastCGI service to ensure it starts automatically upon boot:

Console
# systemctl enable --now php-fpm

PHP Configuration for Apache

Creating a Dedicated Apache PHP-FPM Configuration File

Generate a file at /etc/httpd/conf/extra/php-fpm.conf and insert the following content. Ensure there are no spaces around the pipe character to avoid misconfigurations:

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

Allowing Apache to Use FastCGI

Modify /etc/httpd/conf/httpd.conf and append the following lines at the end of the LoadModule section:

Code
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

Allowing PHP Files in Hosted Sites

If you want PHP support enabled for all websites hosted on Apache, edit /etc/httpd/conf/httpd.conf and include this line at the end:

Code
Include conf/extra/php-fpm.conf

For more granular control, if you use virtual hosts or separate directories for HTTP and HTTPS, insert the line above within the appropriate <VirtualHost> block.

Restart Apache

Apply all changes by restarting the Apache server:

Console
# systemctl restart httpd

PHP Configuration for Nginx

Creating a FastCGI Configuration File

Create the file /etc/nginx/php.conf and insert the following configuration:

Console
# 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 https://httpoxy.org/ 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;

Editing Nginx Server Blocks

In the /etc/nginx/nginx.conf file, or within individual virtual host files, add the following inside each server block that should process PHP files:

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

Restarting Nginx

Apply the new configuration by restarting the Nginx service:

Console
# systemctl restart nginx

Testing PHP Setup

Navigate to your web server’s root directory and create a test file named test.php containing the following:

PHP
<?php phpinfo(); ?>

Then open your browser and visit http://YOUR-SERVER-WEB-ADDRESS-OR-IP/test.php to confirm that PHP is functioning correctly. You should see a detailed PHP configuration page.

Don’t forget to remove the test.php file afterward to avoid exposing server information.

Conclusion

By completing the above steps, you have successfully installed and configured PHP 7.3 with FastCGI on an Arch Linux server running Apache or Nginx. You also ensured your setup is secure and verified through a test script. Always remember to clean up test files and regularly check for software updates to maintain a secure and optimized environment.

Claim €200 credit

Test your setup on ccloud³

Sign up for ccloud³ and receive €200 starting credit for your project.

centron Redaktion Technical editorial team

The centron editorial team writes guides from day-to-day operations: tested on our own platform, run in our data centre in Hallstadt near Bamberg.

Category Linux Basics
Share
Still have questions?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

Was this tutorial helpful?

Your answer is stored anonymously and helps us improve our tutorials.

Comments

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Get started for free

Sign up and receive €200 credit at centron within your first 60 days.

This promotional offer applies to new accounts only. Available exclusively to businesses.