• WordPress
  • cPanel
  • Softaculous
  • KVM Virtualization
  • Vmware Virtualization
  • Proxmox
Sunday, June 15, 2025
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
No Result
View All Result
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux

How to Install PHP on Arch Linux

in Arch Linux, Linux OS
How to Install PHP on Arch Linux

PHP is a widely-used, open-source scripting language that is especially suited for web development. With its flexibility, developers can create dynamic and interactive websites with ease. In this tutorial, we will guide you through the process of how to install PHP on your Arch Linux system. By the end of this article, you will have a fully functional PHP environment ready for your next web project.

Prerequisites

Before proceeding with the PHP installation, ensure that you have Arch Linux up and running. If you have not installed Arch Linux yet, follow the official installation guide to get started.

How to Install PHP on Arch Linux

Update Arch Linux System

First, update your system to ensure you are using the latest packages and security patches:

sudo pacman -Syu

Install PHP on Arch Linux

To install PHP, run the following command:

sudo pacman -S php

This will install the latest PHP version available in the Arch Linux repositories.

Test PHP Installation on Arch Linux

After the installation is complete, you can test your PHP installation by running the following command:

php -v

This will display the installed PHP version, similar to the output below:

PHP 8.0.11 (cli) (built: Sep 23 2021 21:15:43) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.11, Copyright (c) Zend Technologies

Configuring PHP

To configure PHP, you need to edit the php.ini file. This file is located in the /etc/php directory. You can use your favorite text editor to make changes to this file, such as nano or vim. For example:

sudo nano /etc/php/php.ini

In this file, you can configure various PHP settings, such as:

  • max_execution_time: This setting determines the maximum time in seconds that a script is allowed to run before it is terminated. You can increase this value if your scripts require more time to execute.
  • memory_limit: This setting specifies the maximum amount of memory that a script can consume. You may need to increase this value if your scripts require more memory.
  • upload_max_filesize: This setting determines the maximum file size that can be uploaded via PHP. You can increase this value if you need to upload larger files.

Make the necessary changes, then save and close the file.

Install a Web Server on Arch Linux

To serve PHP files, you need a web server such as Apache or Nginx. In this tutorial, we will use Apache as our web server. You can follow our guides on how to set up Apache web server on Arch Linux or how to install Nginx on Arch Linux if you prefer Nginx.

Install Apache with the following command:

sudo pacman -S apache

Configure Apache to Use PHP

To configure Apache to use PHP, you need to edit the httpd.conf file. This file is located in the /etc/httpd/conf directory. Open the file with your preferred text editor:

sudo nano /etc/httpd/conf/httpd.conf

Search for the following line:

#LoadModule mpm_event_module modules/mod_mpm_event.so

Uncomment this line by removing the # at the beginning and then comment out the LoadModule mpm_prefork_module modules/mod_mpm_prefork.so line by adding a # at the beginning, like this:

LoadModule mpm_event_module modules/mod_mpm_event.so
#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

Next, find and uncomment the following lines:

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

Add the following lines at the end of the httpd.conf file to enable PHP processing for .php files:

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

Save and close the file.

Install and Configure PHP-FPM

To use PHP with Apache, you need to install PHP-FPM (FastCGI Process Manager). Install PHP-FPM with the following command:

sudo pacman -S php-fpm

Now, enable and start the PHP-FPM service:

sudo systemctl enable php-fpm
sudo systemctl start php-fpm

Start and Test Apache with PHP

Enable and start the Apache service:

sudo systemctl enable httpd
sudo systemctl start httpd

Create a test PHP file in the Apache document root /srv/http:

echo "<?php phpinfo(); ?>" | sudo tee /srv/http/info.php

Open your web browser and navigate to http://your_server_IP_or_domain/info.php. You should see a PHP information page displaying the current PHP configuration.

Conclusion

Congratulations! You have successfully installed PHP on Arch Linux and configured it to work with the Apache web server. You can now start building your PHP applications and websites.

For further configuration and optimization, you may want to check out our guides on how to install MySQL on Arch Linux or how to install MariaDB on Arch Linux to set up a database server for your PHP applications.

Additionally, consider exploring other useful tools and libraries for web development, such as how to install Python on Arch Linux or how to install TensorFlow on Arch Linux.

ShareTweet
Previous Post

How to Install MySQL on Arch Linux

Next Post

How to Install phpMyAdmin on Arch Linux

Related Posts

How to Install Tomcat on Rocky Linux

How to Install Apache Tomcat on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Golden Host VPS
  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.

  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.