-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux PHP Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to PHP on Linux, covering Arch Linux, CachyOS, and other distributions including installation, configuration, and web development.
Arch/CachyOS:
# Install PHP
sudo pacman -S php php-apache
# Or with FPM
sudo pacman -S php php-fpm
# Install extensions
sudo pacman -S php-gd php-mysql php-sqliteDebian/Ubuntu:
sudo apt install php php-fpm php-mysqlFedora:
sudo dnf install php php-fpm php-mysqlndCheck PHP:
# Check version
php --version
# Check modules
php -mEdit config:
# Edit PHP config
sudo vim /etc/php/php.ini
# Common settings
upload_max_filesize = 20M
post_max_size = 20M
memory_limit = 128MTest PHP:
# Command line
php -r "echo 'Hello, World!';"
# Or create test file
echo "<?php phpinfo(); ?>" | phpEnable PHP:
# Edit Apache config
sudo vim /etc/httpd/conf/httpd.confAdd:
LoadModule php_module modules/libphp.so
AddHandler php-script .php
Restart Apache:
sudo systemctl restart httpdNginx with PHP-FPM:
# Edit Nginx config
sudo vim /etc/nginx/nginx.confAdd:
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
Check configuration:
# Check PHP
php -v
# Check Apache/Nginx config
sudo apachectl configtest
sudo nginx -tThis guide covered PHP installation, configuration, and web server integration for Arch Linux, CachyOS, and other distributions.
- Web Servers - Web server setup
- Apache Guide - Apache setup
- Nginx Guide - Nginx setup
- PHP: https://www.php.net/
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.