Installing PHP on a Linux system is usually straightforward, but sometimes users may encounter issues that can hinder the completion of the installation process. Before we start, please ensure that you’ve followed the instructions outlined in this article.
Permissions issue
Change permissions for the document root (var/www/html
).
sudo chmod -R 777 /var/www/html
Enable short open tags
Find out php.ini location.
php --ini
Edit php.ini
Syntax
sudo nano /etc/php/<version>/cli/php.ini
Example
sudo nano /etc/php/8.1/cli/php.ini
Setting short_open_tag
to On
in the PHP configuration allows PHP code to be written with short tags (<? ?>
) instead of the standard <?php ?>
tags.
short_open_tag = On
To apply the changes, you need to restart the Apache web server.
sudo service apache2 restart
Possible issue
If the previous steps don’t work, try this.
Change permissions to full access to everyone.
sudo chmod -R 777 /etc/php/8.1/apache2
or use a safer approach to limit permissions to access the files within the apache2 directory. Then verify if the change has taken effect.
sudo chmod -R 644 /etc/php/8.1/apache2/php.ini
Edit php.ini file.
sudo nano /etc/php//apache2/php.ini
Set short_open_tag
to On
short_open_tag = On
Restart Apache service
sudo service apache2 restart
Conclusion
This article discusses common problems related to PHP installation and the execution of the first script.