Extension PHP5 does not parse in XAMPP

◇◆丶佛笑我妖孽 提交于 2019-11-27 23:23:38

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).

  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..

Tom of Helatrobus

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:

<IfModule mod_php5.c>
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
</IfModule>

Change the text to read as follows:

<IfModule mod_php5.c>
AddType application/x-httpd-php .php .phtml .php3 .php5
AddType application/x-httpd-php-source .phps
</IfModule>

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!

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!