views:

2608

answers:

5

Hello,

I've installed XAMPP Apache server and put my website into htdocs. I've started Apache server. On my website I've got files with extension PHP and with extension PHP5.The difference is that when I type in into browser localhost/file.php - I see a parsed website.

But when I type localhost/file.php5 (i have this file on server), than browser asks me if I want to download or open this file. And if I choose open than I see PHP code of file.php5!

I've looked into configuration, so:

  1. I dont have htaccess file
  2. PHPINFO() shows PHP 5
  3. c:\xampp\apache\conf\extra\httpd-xampp is included into configuration and has this on the beginning:

    AddType application/x-httpd-php-source .phps

    AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml .phpt

I've tried also to put:

AddHandler php5-script .php5
AddType text/html .php5

Into httpd.conf, but it does not work for me (no changes).

Could you please help me fixing it? I would like to have php5 and php extension files to be opened with php5 parser.

A: 

did you make sure to restart apache after adding the handler types?

mkoga
yes, i'am sure of it
tomaszs
A: 

Adding:

AddType application/x-httpd-php .php .php5

worked for me under OS X and Apache 2.2.10, I cannot imagine it being different on XAMPP. I would undo all of your other changes/modifications to httpd.conf and then only have:

LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .php5

Then restart apache. Get rid of the AddHandler, the AddType, etc.

Cody Caughlan
+3  A: 

XAMPP passes by default files with the following extensions to PHP: .php .php5 .php4 .php3 .phtml .phpt (this was tested with XAMPP Lite 1.6.8).

My suggestion would be to remove the "AddType text/html .php5" line from the XAMPP configuration. Alternatively, use a clean install of XAMPP and look at the differences (with something like WinMerge).

Cd-MaN
+1  A: 
  1. Follow the path c:/xampp/apache/conf/extra/httpd-xammp

    Open httpd-xammp

  2. Find the area of the text that resembles this:

    <FilesMatch "\.php$"> 
       SetHandler application/x-httpd-php   
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
    
  3. replace the top line of the code with the following:

    <FilesMatch "\.php$|\.php5$|\.php4$|\.php3$|\.phtml$|\.phpt$">
    
  4. so the text resembles the following:

    <FilesMatch "\.php$|\.php5$|\.php4$|\.php3$|\.phtml$|\.phpt$"> 
        SetHandler application/x-httpd-php  
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
    

That worked for me.

Good luck..

A: 

I had to figure out how to do this again when I switched to an Ubuntu OS. The file that needs to be modified is called php5.conf.

I installed apache 2, php5, phpmyadmin, mysql-server and rapache with the synaptic package manager (system> administration> synaptic package manager) and did not use XAMPP. If you have already installed XAMPP then the paths to php5.conf will be different, likely somewhere in the /opt/lampp file.

With my install, the path to it is /etc/apache2/mods-avaible/php5.conf. Before it can be modified you must use the terminal to change the permissions to allow you to write to it. To get to it, open the terminal and type :

cd /etc/apache2/mods-available

and then line that changes the permissions:

sudo chmod a+w php5.conf

You can type the following to make sure the permissions have been changed:

ls -l

You should see a long list of files with the permission notions. The line for php5.conf should look like this (with the exception of the date and time):

-rw-rw-rw- 1 root root 139 2009-12-06 22:35 php5.conf

This means everyone has read and write permissions. You can change the permissions back when you get done if you want. For now proceed to make the changes you need by typing:

nano php5.conf

This opens the file in a kind of text editor. What you should see is this:

AddType application/x-httpd-php .php .phtml .php3 AddType application/x-httpd-php-source .phps

Change the text to read as follows:

AddType application/x-httpd-php .php .phtml .php3 .php5 AddType application/x-httpd-php-source .phps

Adding the .php5 to after the first "AddType" command.

Press ctrl x to exit and y to save changes. Then restart the computer. And then your files with the .php5 extensions should work!

I can't believe that took me hours to figure out! Good luck!

Tom of Helatrobus