I am trying to create an php file with extension .php5. I am using apache 2.2 and php 5.5.3 in my system , tried editing the configuration file by adding
Action application/x-httpd-php .php5 but still no use
Straight from my php conf file:
<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
And I can run myfile.php5 as php as long as that is what the file is named. Put it in your php conf or if your lazy your .htaccess file
Related
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:
I dont have htaccess file
PHPINFO() shows PHP 5
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.
Follow the path c:/xampp/apache/conf/extra/httpd-xammp
Open httpd-xammp
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>
replace the top line of the code with the following:
<FilesMatch "\.php$|\.php5$|\.php4$|\.php3$|\.phtml$|\.phpt$">
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..
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).
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.
I am a noob in reference to apache. I am trying to set it on El Capitan.
1. I have enabled "LoadModule php5_module" and placed the helloWorld.php in my document root. (/Library/Webroot/Documents) (I don't need user based document root.)
2. If I run the php from the terminal then it works.
3. But it does not work when I run through the browser. It complains that I need to enable ExecCGI.
4. If I enable ExecCGI for my documentRoot then I get the error about malformed header.
5.My understanding was, I don't need to treat php scripts as CGI, if I enable php5_module and that's why I don't need ExecCGI.
(I do have some other cgi directory which has some python scripts and they work fine.)
I also have following lines in my httpd.conf
<IfModule php5_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddHandler php5-script .php
</IfModule>
Could some one suggest where I must be doing something wrong.
Thanks
I don't use the built-in apache, and I think httpd.conf is at risk of being overwritten on updates. However, in my apache install I have AddType and AddHandler reversed from the way you have it:
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps
AddType text/html .php
In addition, if you plan to use index.php automatically:
DirectoryIndex index.html index.php
Hope that helps.
I've been trying to install both Apache and PHP from source so they work together, as a "to see if I can" project.
However, when I try to load a "localhost" file, firefox just starts downloading the .php page instead of opening it.
I'm pretty sure I've added the correct handlers in ./conf/httpd.conf, they are shown below
#configure for php
AddHandler php-script .php
AddType text/html .php
AddType application/x-httpd-php-source phps
AddType application/x-httpd-php5 .php
I've also tried replacing
AddType application/x-httpd-php5 .php
with
AddType application/x-httpd-php5 php
and
AddType application/x-httpd-php .php
and
AddType application/x-httpd-php php
Have you configured apache to load php module?
have a look here:
http://www.petefreitag.com/item/516.cfm
Update:
My problem was with httpd.conf after all, not php.ini. I was missing the following:
<FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch>
http://wiki.apache.org/httpd/PHPDownload
(check other answers below too)
Original Question
I'd like a way to test my php.ini file, because my server currently cannot parse .php files. I'm having problems with my MimeTypes for PHP and I don't see any errors when I restart HTTPD.
If apache (or what web server you use) does not pass the control to the php - then you forgot to add AddType application/x-httpd-php .php into your httpd.conf
when i point my browser to http://localhost/phpmyadmin, instead of showing me its front page, it comes up with save as dialog.
I'm running:
Apache/2.2.3 (Debian) PHP/5.2.0-8+etch13 Server
I've reinstalled both apache2 and php5.
After re-install i don't have httpd.conf file, how can i get it back? Is there a standard file which i can just copy into /etc/apache2?
I did a locate httpd.conf and the only file i got was the empty file i have under /etc/apache2/ which i made.
Did you configure the php extension to send an http header?
In httpd.conf:
AddType application/x-httpd-php .php
EDIT
The file is not necessarily named httpd.conf, that's just the default name. Try searching for other configuration files in the Apache directory -- the extension probably is .conf but it might be something else...
If you used apt-get on debian to install apache2, try /etc/apache2/apche2.conf
/EDIT
I also get this problem when I install ISPconfig. I solved the problem by this tutorial:
http://www.howtoforge.com/perfect-server-debian-wheezy-apache2-bind-dovecot-ispconfig-3-p4
I think the main code is change suphp.conf config.
sudo nano /etc/apache2/mods-available/suphp.conf
comment out the <FilesMatch "\.ph(p3?|tml)$"> section and add the line AddType application/x-httpd-suphp .php .php3 .php4 .php5 .phtml - otherwise all PHP files will be run by SuPHP
<IfModule mod_suphp.c>
#<FilesMatch "\.ph(p3?|tml)$">
# SetHandler application/x-httpd-suphp
#</FilesMatch>
AddType application/x-httpd-suphp .php .php3 .php4 .php5 .phtml
suPHP_AddHandler application/x-httpd-suphp
<Directory />
suPHP_Engine on
</Directory>
# By default, disable suPHP for debian packaged web applications as files
# are owned by root and cannot be executed by suPHP because of min_uid.
<Directory /usr/share>
suPHP_Engine off
</Directory>
# # Use a specific php config file (a dir which contains a php.ini file)
# suPHP_ConfigPath /etc/php5/cgi/suphp/
# # Tells mod_suphp NOT to handle requests with the type <mime-type>.
# suPHP_RemoveHandler <mime-type>
</IfModule>
Hope I can help someone :)
I think you just do not know where that config file is. I don't think apache can run without httpd.conf. Here is how you can find your config:
$>locate httpd.conf
/etc/httpd/conf/httpd.conf
$>vim /etc/httpd/conf/httpd.conf
Once you located it, find where other AddType reside and add
AddType application/x-httpd-php .php
Last thing you need to do is restart your httpd, it depends on install, but doing apachectl restart does the trick. You might have to locate it just like you did with httpd.conf file and type in the entire path to the file.
Afterwords, your phpmyadmin should come up.
I dont know anything about this but... does someone knows a way in javascript to download selected files, for example I select through checkboxes 2 files, and then I click on a button in order to download these 2 files choosing the route where i will save the archives