Local Apache server will sot serve PHP files

Ralfe Poisson ralfepoisson at gmail.com
Mon Jan 2 06:55:49 UTC 2006

Hi Jochem,

I suggest you have a look at a previous thread "Sourceforge Gallery2 and 
PHP". A simmilar problem was discussed. In case you can't find that 
thread, here was my solution :

On 12/26/05, Ralfe Poisson <ralfepoisson at gmail.com> wrote:

>> Soo-Hyun,
>> I just want to explain that your problem has nothing to do with FireFox. The
>> problem is with Apache. PHP files are parsed through the PHP preprocessor
>> when your browser makes a query from the web server. If you were to try and
>> load the files directly into firefox, you would either get the source code,
>> or firefox would try and download the php files. Thus, you must make sure
>> that you are accessing them through the Apache server, and that the
>> httpd.conf file is setup correctly to forward *.php files to the php
>> preprocessor.
>> Hope that makes it a bit clearer.
>> Regards,
>> Ralfe
So basically you PHP requires a webserver, such as Apache, to run through.

*"In the case of PHP embedded in an html file, the PHP simply does not
display. I created a file called "test.html", which contains inside the
PHP code: <? phpinfo(); ?>. I save the file to my /var/www directory,
and view it in Firefox at localhost. Nothing shows up on screen."*

There are two problems here. Firsty, in the Apache httpd.conf 
configuration file, it specifies what file extensions to regard as php 
files, and then it will send those files first to the php preprocessor 
which generates the html code that is sent to the web browser(firefox). 
The second problem is that it seems as though you are viewing the php 
files directly, instead of through the Apache server. The Apache 
webserver can be accessed via http://localhost/ . If you were to look at 
the source of a page you view on the internet which is a php page, you 
would notice that it only contains html (and perhaps some javascript) 
and no php. This is because the php code is interpreted by php 
preprocessor on the server which then generates the corresponding html 
which Apache then sends to the browser. However, by viewing the page 
directly, Firefox does not know how to handle the php source code, and 
thus is spitting out strange errors.

Hope this helps.


"Open the Doors and Smash the Windows."
           RALFE POISSON
          Systems Analyst

 email:ralfe at modernabstraction.za.org
  web: www.modernabstraction.za.org

Jochem Kossen wrote:

>On Sun, Jan 01, 2006 at 11:31:40PM +0900, Dave M G wrote:
>>Ubuntu Users,
>>	I have Ubuntu 5.10, Apache 2.0, PHP4 (?), and MySQL on my home machine,
>>a P3. It is not a web server, but I am intending to use it for testing
>>my web pages before uploading them by FTP to my hosting service.
>>	I installed PHP4 via Symantic, and so far as I knew, there was no
>>further set up needed. However, I am encountering two problems with PHP
>>scripts which indicate PHP is either not actually installed, or
>>installed incorrectly.
>You also need the Apache module, libapache2-mod-php4 (or
>libapache-mod-php4 if you use Apache 1.3.x).
>>	In the case of PHP embedded in an html file, the PHP simply does not
>>display. I created a file called "test.html", which contains inside the
>>PHP code: <? phpinfo(); ?>. I save the file to my /var/www directory,
>>and view it in Firefox at localhost. Nothing shows up on screen.
>That's because html files aren't parsed as php files in the standard
>>	In the case of .php scripts, I created a file called index.php and put
>>it in its own directory within /var/www. However, when I try to call it,
>>I get a message from Firefox which says I am trying to open a "PHTML"
>>file, and would I like to save it or open it with another application.
>>	Is there some configuration with my Apache server settings that needs
>>to be altered?
>>	While I am comfortable writing PHP code, I am a newbie when it comes to
>>installing it, and this is one of my first attempts to install my own
>>PHP testing environment at home.
>>	Any advice would be much appreciated.
>The php module is probably not enabled. Ubuntu/Debian provides a handy
>little script called a2enmod. something like a2enmod php4 should work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20060102/3fa129e1/attachment.html>

More information about the ubuntu-users mailing list