Tutorials  /  Linux Basics

Install PHP 7.3 on Arch Linux with Apache or Nginx

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

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
VM

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

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.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren