Sometimes happen that we didn’t configured apache and httpd.conf properly or we didn’t change permissions and PHP doesn’t render pages and instead show in browser plain text of source code.
In most cases that happens because of :
- PHP is not properly installed or service is not started
- .php extension isn’t added in httpd.conf configuration file
- PHP must have execute permissions to execute our script or file [permissions 755]
Making sure PHP is installed
Make sure PHP service is installed and started.
Login to VPS via SSH using Putty and login with root and your password.
To install PHP use command on CentOS use:
yum install httpd
apt-get install apache2
if you are using Debian or Ubuntu Linux operating system.
It might you ask do you want to download it, just type “y” and press enter.
Then start that service and to do that write this line if you are using CentOS:
yum httpd start
or for Debian write:
Add PHP extension in httpd.conf
Navigate to /etc/httpd/conf/httpd.conf
You can do that using SSH or if you are using Webmin under Servers click Apache Webserver > Global Configuration > Edit Config Files
and find this line of code:
And change it to:
Allow execute permissions
You have to allow PHP to execute script. To do that, using FTP navigate to folder where is your index.php located, usually in public_html or if you are using Webmin location is : /var/www/html
Right click on index.php and set 755 permission or simply mark boxes (if you are using FTP manager) with Execute attribute.
Don’t forget to restart apache using control panel or using command:
yum restart httpd
Incoming search terms:
- can html be rendered but not visible in source
- php not rendering
- php not rendering for some pages
- php showing code not page
- why does code showing on web pages