Hostxpeed
Login Get Started →
Troubleshooting

Fix PHP Not Working

5 min read
29 views
Jun 10, 2026

Check if PHP is Installed

php -v
which php

Check PHP-FPM Status

sudo systemctl status php*-fpm
sudo systemctl restart php*-fpm

Test PHP Processing

Create a test file:

echo "" | sudo tee /var/www/html/test.php

If file downloads instead of executing, PHP is not configured correctly.

Nginx PHP Configuration

location ~ .php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}

Apache PHP Configuration

sudo a2enmod php8.1
sudo systemctl restart apache2

Check PHP-FPM Socket

ls -la /var/run/php/
sudo systemctl status php8.1-fpm

Fix Permissions

sudo chown -R www-data:www-data /var/www/html
sudo find /var/www/html -type f -exec chmod 644 {} ;

Check Logs

sudo tail -f /var/log/php*-fpm.log
sudo tail -f /var/log/nginx/error.log

Was this article helpful?