Extension PHP5 does not parse in XAMPP

前端 未结 4 2076
温柔的废话
温柔的废话 2020-12-06 08:35

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

相关标签:
4条回答
  • 2020-12-06 09:23

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

    0 讨论(0)
  • 2020-12-06 09:24

    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!

    0 讨论(0)
  • 2020-12-06 09:28

    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.

    0 讨论(0)
  • 2020-12-06 09:31
    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..

    0 讨论(0)
提交回复
热议问题