1

I recently installed apache2 and Mysql on my RaspberryPi, I also setup FTP so I can edit my Files on my PC and upload them directly to the webserver.

If I now connect to my server vis it's IP-Address I can see the index.html, but as soon as I try to open a *.php file it shows the content of said file instead of interpreting it.

Are there any common mistakes that could make this happen?

Thanks for your help

AgRizzo
  • 5,261
  • 1
  • 13
  • 28
Lumnezia
  • 796
  • 2
  • 9
  • 32

5 Answers5

3

This kind of errors mainly happen 3 reason

  1. You may not be installed php
  2. if you have installed php, you have not configured with apache
  3. Check your php file having opening php tag <?php and closing php tag ?>
Shafeeque
  • 2,039
  • 2
  • 13
  • 28
  • The problem was that I THOUGHT I installed PHP when actually there occured an error during the installation. – Lumnezia Oct 31 '13 at 13:33
1

The same thing can happen if you have short php tags disabled. If it is disabled - all code that starts with <?..., <?=... will be printed on the screen just as simple text. Everything can be checked very easy: just create some php file and add <?php echo phpinfo() ?>. If browser will show php info - than problem is really in disabled short pho tags.

In that case you can simple enable that in php.ini with the directive short_open_tag=On (not recommended, however).

This is from php.ini file:

; This directive determines whether or not PHP will recognize code between
; <? and ?> tags as PHP source which should be processed as such. It's been
; recommended for several years that you not use the short tag "short cut" and
; instead to use the full <?php and ?> tag combination. With the wide spread use
; of XML and use of these tags by other languages, the server can become easily
; confused and end up parsing the wrong code in the wrong context. But because
; this short cut has been a feature for such a long time, it's currently still
; supported for backwards compatibility, but we recommend you don't use them.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
short_open_tag = On
kovpack
  • 4,905
  • 8
  • 38
  • 55
0

Your HTTP's response header should have "Content-Type:text/html". Have you checked that?

HILARUDEEN S ALLAUDEEN
  • 1,722
  • 1
  • 18
  • 33
0

You don't have PHP configured to interpret php files within Apache or the PHP module is not known to Apache.

apt-get install libapache2-mod-php5

or

apt-get install php5

in apache.conf (or similiar) add line like:

LoadModule php5_module modules/libphp5.so
<FilesMatch "\.ph(p[2-6]?|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>

see http://www.php.net/manual/en/install.unix.apache2.php

Daniel W.
  • 31,164
  • 13
  • 93
  • 151
0

Install php and any web server

http://www.apachefriends.org/en/xampp.html

download and install and goto C:/xampp/htdocs

make directory of your project and in browser type localhost/your_directory_name

Dinesh Patil
  • 1,042
  • 10
  • 13