0

I have just hosted a website wherein files including html, php, css are from raspberry pi. My deployment of the website was successful. When I go to webpages that are in html format, it displays them. However, when I try to open the webpages in php format, it automatically formats them. I tried it all in my web browser and it does the same. I knew in myself that I did not change any code in it and this scenario suddenly happened.

I have read something about apache? But those still did not work.

Is the problem about my web browsers?

Or is the problem about my raspberry pi? Since I'm sure of my codes. Thank you so much for responding in advance.

  • `"However, when I try to open the webpages in php format, it automatically formats them."` - What does that even *mean*? – David Feb 15 '17 at 17:12
  • _I assume that means that the PHP + HTML is printed to the client, and the client does it best to process the known HTML, leaving invlid areas of PHP_. – Matt Clark Feb 15 '17 at 17:13
  • Oh I am sorry. I did not proofread my post. What I meant was that when I try to open the webpages in php format, it automatically downloads them instead of displaying them. – Allen Dela Cruz Feb 16 '17 at 20:59

1 Answers1

4

Seems like you do not have a PHP interpreter running on the server.

sudo apt-get install php5 libapache2-mod-php5 -y
sudo service apache2 restart
Matt Clark
  • 27,671
  • 19
  • 68
  • 123
  • Hi! The first line worked. But I always encounter problem with the 2nd line. It said 'Warning: Unit file of apache2.service changed on disk, 'systemctl daemon-reload' recommended. ' – Allen Dela Cruz Feb 16 '17 at 21:02
  • Then do what it says.. Reload the daemon to clear the cache and reload the file from disk - then rerun restart. – Matt Clark Feb 16 '17 at 21:03
  • I'm a newbie to raspberry pi. How do I do that? And also, every time I disable raspberry pi, it always displays messages: 'insserv: fopen(.depend.stop): Permission denied Failed to execute operation: Access denied – Allen Dela Cruz Feb 16 '17 at 22:05
  • Do what the message says.. `sudo systemctl daemon-reload` - If you get _permission denied_ it means the user executing the action does not have the required privileges. Running with `sudo` will elevate to root level privileges. – Matt Clark Feb 16 '17 at 22:06
  • The second line worked but the php files aren't still working. – Allen Dela Cruz Feb 16 '17 at 22:10
  • The php module is properly installed? There may be an additional apache configuration to be made. What happens if you try executing a php file that you have on the server, does this work? `php /var/www/test.php` – Matt Clark Feb 16 '17 at 22:12
  • The php file is still not working. I also tried the . From the youtube video I saw, it should display the information about my php? But it displayed 404 not found – Allen Dela Cruz Feb 16 '17 at 22:18