PDA

View Full Version : [ubuntu] Firefox can't open php file from apache2 server on localhost



Makrie
March 31st, 2010, 07:33 PM
Hi.

I've just moved on to 10.04 from 9.10. The program worked fine in 9.10. I *may* have overwritteen a conf file in the upgrade... :redface:

I now get the error as below:

http://www.grassmoon.com/ubuntu/php_prob_01.png

My userdir.conf is like this:

<IfModule mod_userdir.c>
UserDir public_html
UserDir disabled root

<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
</IfModule>

and I have the PHP5 module installed. I vaguely recall that I may have had PHP4 installed - would the upgrade have removed it? Is there anywhere I can get it from to try? Anything else to do?

Thanks for your time

Makrie :D

richardjh
April 6th, 2010, 11:40 PM
What do you see when you run php -v from the command line?

Do you have libapache2-mod-php5 installed?

Have you installed everything from the repositories or do you have bits installed manually or from other sources?

Apache is not configured to server php files, which is why you are getting this error. It may be a simple error in a configuration file.

romeroc24
April 7th, 2010, 03:52 AM
Hi.

I've just moved on to 10.04 from 9.10. The program worked fine in 9.10. I *may* have overwritteen a conf file in the upgrade... :redface:

I now get the error as below:

http://www.grassmoon.com/ubuntu/php_prob_01.png

My userdir.conf is like this:

<IfModule mod_userdir.c>
UserDir public_html
UserDir disabled root

<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
</IfModule>

and I have the PHP5 module installed. I vaguely recall that I may have had PHP4 installed - would the upgrade have removed it? Is there anywhere I can get it from to try? Anything else to do?

Thanks for your time

Makrie :D

Yes, richardjh you allright!



$sudo apt-get install libapache2-mod-php5

lisati
April 7th, 2010, 03:56 AM
I had a similar problem with firefox wanting to download PHP files instead of displaying them. I found the answer here: https://help.ubuntu.com/community/ApacheMySQLPHP#Troubleshooting%20PHP%205

Makrie
April 7th, 2010, 02:15 PM
Hi all, thanks for helping me with this.


What do you see when you run php -v from the command line?

marko@mango:~$ php -v
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/imagick.ini on line 1 in Unknown on line 0
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
PHP 5.3.2-1ubuntu3 with Suhosin-Patch (cli) (built: Mar 29 2010 12:23:29)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies


Do you have libapache2-mod-php5 installed?

Yes, I believe so.


Have you installed everything from the repositories or do you have bits installed manually or from other sources?

One of the reasons I didn't clean install 10.04 was that I wanted to keep Fontlinge (http://www.gesindel.de/page_intro_english.php) working without needing to reinstall it. I had installed Fontlinge manually but everything else (Apache,PHP5,etc.) from the repositories.


Apache is not configured to server php files, which is why you are getting this error. It may be a simple error in a configuration file.

Fingers crossed for finding it! Apache2 config files are default (my bad, I overwrote my custom one, I think)!


I had a similar problem with firefox wanting to download PHP files instead of displaying them. I found the answer here: https://help.ubuntu.com/community/ApacheMySQLPHP#Troubleshooting%20PHP%205

Following their advice:

marko@mango:~$ sudo a2enmod php5
[sudo] password for marko:
Module php5 already enabled
marko@mango:~$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[ OK ]

and the problem remains. I manage the modules through Webmin, fwiw.

Thanks all!

s_
April 7th, 2010, 10:12 PM
Edit: change the file in mods-available not in enabled. Sorry for the mistake.
Try to open the php5.conf in mods-available

sudo nano /etc/apache2/mods-available/php5.confIt should look like this

<IfModule mod_php5.c>
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
</IfModule>If the .php is not there apache will not parse the files.
Force apache to reload the module.

sudo a2dismod php5
sudo service apache2 restart
sudo a2enmod php5
sudo service apache2 restart

Makrie
April 7th, 2010, 10:20 PM
Try to open the php5.conf in mods-enabled.

sudo nano /etc/apache2/mods-enabled/php5.conf
It should look like this

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

If the .php is not there apache will not parse the files.
Force apache to reload the module.

sudo a2dismod php5
sudo service apache2 restart
sudo a2enmod php5
sudo service apache2 restart

Even after reloading the module as you specified, my php5.conf still looks very different:

GNU nano 2.2.2 File: /etc/apache2/mods-enabled/php5.conf

<IfModule mod_php5.c>
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_value engine Off
</Directory>
</IfModule>
</IfModule>

Should I replace it with yours?

And thanks!

s_
April 7th, 2010, 10:30 PM
This is a pretty fancy expression for something simple

<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>I think you can safely replace it with this.

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

Edit:
The reqex should work, so its probably not that.

s_
April 7th, 2010, 10:49 PM
try to comment out the bold lines. (I think the syntax has changed to the semicolon ; for comments.

# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_value engine Off
</Directory>
</IfModule>

Makrie
April 8th, 2010, 08:57 PM
try to comment out the bold lines. (I think the syntax has changed to the semicolon ; for comments.

# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_value engine Off
</Directory>
</IfModule>

I've commented out the lines (attempted twice, using semicolons and hashes) and still no joy. I have been clearing my internet cache before and after every restart of Apache2.

Darn! Any further ideas? Am I approaching clean install time? Could it be that the program wants PHP4 not PHP5 (although I don't think the error message suggests this?

Thanks :/

s_
April 9th, 2010, 11:55 AM
Dont think you should reinstall yet.
When you upgraded to lucid, you also upgraded php to version 5.3.
Look at this page about migrating from 5.2 to 5.3 http://www.php.net/manual/en/migration53.php
One of the changes is to the php.ini files. http://www.php.net/manual/en/migration53.ini.php

I am runnning 5.2 in Karmic, so I cant help you with specifics of the php.ini files.
but look around in /etc/php5/apache2/ for the php.ini files
In the .ini files kook for this or similar

; Enable the PHP scripting language engine under Apache.
engine = On
engine needs to be On to work.
This directive can be set from 'anywhere' so look in httpd.conf, .htaccess files for this php_flag engine off

Fenix-TX
April 9th, 2010, 08:34 PM
NOW WORKS: deleting cache, history solved the issue
I have the same problem and only happens on Firefox, I've tried with Konqueror and works fine, why?

EDITED: FIXED

iduppe
April 18th, 2010, 05:42 AM
I do have this exact same issue.. I installed lamp using tasksel.. and apache doesnt parse php files on my public_html dir..

BUT if I place the files on /var/www it works..

and phpmyadmin woks too.... any ideas?


NOW WORKS: deleting cache, history solved the issue
I have the same problem and only happens on Firefox, I've tried with Konqueror and works fine, why?

EDITED: FIXED

Are you the OP?

cleaning the cache did not solve the issue for me. I tried with a clean profile, same issue.

iduppe
April 18th, 2010, 05:49 AM
try to comment out the bold lines. (I think the syntax has changed to the semicolon ; for comments.

# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_value engine Off
</Directory>
</IfModule>

this solved the issue

madtom1999
May 5th, 2010, 08:39 PM
I've had a similar problem - try replacing localhost with 127.0.0.1
it seems everytime you upgrade the localhost mapping gets lost....

FRuso
May 7th, 2010, 04:51 AM
Hi Makrie (http://ubuntuforums.org/member.php?u=50048), comment all lines with # or replace these lines in mods-available/php5.conf, and adds these last two lines:

sudo nano /etc/apache2/mods-available/php5.conf

<IfModule mod_php5.c>
# <FilesMatch "\.ph(p3?|tml)$">
# SetHandler application/x-httpd-php
# </FilesMatch>
# <FilesMatch "\.phps$">
# SetHandler application/x-httpd-php-source
# </FilesMatch>
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
# <IfModule mod_userdir.c>
# <Directory /home/ruso/public_html>
# php_admin_value engine OFF
# </Directory>
# </IfModule>
AddType application/x-httpd-php .php .phtml .php3 .html .xhtml
AddType application/x-httpd-php-source .phps
</IfModule>

sudo /etc/init.d/apache2 restart

It worked for me!

Gaweph
May 10th, 2010, 09:44 PM
This worked perfectly for me!
Much obliged.


Hi Makrie (http://ubuntuforums.org/member.php?u=50048), comment all lines with # or replace these lines in mods-available/php5.conf, and adds these last two lines:

sudo nano /etc/apache2/mods-available/php5.conf

<IfModule mod_php5.c>
# <FilesMatch "\.ph(p3?|tml)$">
# SetHandler application/x-httpd-php
# </FilesMatch>
# <FilesMatch "\.phps$">
# SetHandler application/x-httpd-php-source
# </FilesMatch>
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
# <IfModule mod_userdir.c>
# <Directory /home/ruso/public_html>
# php_admin_value engine OFF
# </Directory>
# </IfModule>
AddType application/x-httpd-php .php .phtml .php3 .html .xhtml
AddType application/x-httpd-php-source .phps
</IfModule>

sudo /etc/init.d/apache2 restart

It worked for me!

dadinugroho
October 29th, 2010, 02:49 PM
Hi,

It's funny. I have spent many days to figure out why I can't used localhost while using 127.0.0.1 and hostname can work nicely.....

Anyone can have an explanation on this?

Thanks a lot.

bobnw
November 19th, 2010, 05:28 PM
I also had this problem. I reloaded Apache2 and it was still there. Tried clearing the Firefox Cache as suggested in another post. This did not work for the tools menu. My profile was on an NT file system. After I emptied the Cache directory in my profile using normal file system access the problem was gone.