Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Firefox can't open php file from apache2 server on localhost

  1. #1
    Join Date
    Nov 2005
    Beans
    31
    Distro
    Ubuntu Development Release

    Unhappy Firefox can't open php file from apache2 server on localhost

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

    I now get the error as below:



    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
    like a phoenix ignition

  2. #2
    Join Date
    Aug 2009
    Location
    West Sussex, England
    Beans
    117
    Distro
    Ubuntu

    Re: Firefox can't open php file from apache2 server on localhost

    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.

  3. #3
    Join Date
    Jan 2009
    Beans
    26

    Re: Firefox can't open php file from apache2 server on localhost

    Quote Originally Posted by Makrie View Post
    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...

    I now get the error as below:



    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
    Yes, richardjh you allright!

    Code:
    $sudo apt-get install libapache2-mod-php5

  4. #4
    Join Date
    Jun 2007
    Location
    Paraparaumu, New Zealand
    Beans
    Hidden!

    Re: Firefox can't open php file from apache2 server on localhost

    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/Ap...ting%20PHP%205
    Forum DOs and DON'Ts
    Please use CODE tags
    Including your email address in a post is not recommended
    My Blog

  5. #5
    Join Date
    Nov 2005
    Beans
    31
    Distro
    Ubuntu Development Release

    Re: Firefox can't open php file from apache2 server on localhost

    Hi all, thanks for helping me with this.

    Quote Originally Posted by richardjh View Post
    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 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)!

    Quote Originally Posted by lisati View Post
    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/Ap...ting%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!
    like a phoenix ignition

  6. #6
    Join Date
    May 2009
    Beans
    121
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Firefox can't open php file from apache2 server on localhost

    Edit: change the file in mods-available not in enabled. Sorry for the mistake.
    Try to open the php5.conf in mods-available
    Code:
    sudo nano /etc/apache2/mods-available/php5.conf
    It should look like this
    Code:
    <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.
    Code:
    sudo a2dismod php5 
    sudo service apache2 restart
    sudo a2enmod php5
    sudo service apache2 restart
    Last edited by s_ø; April 7th, 2010 at 10:22 PM. Reason: mods-available NOT mod-enabled

  7. #7
    Join Date
    Nov 2005
    Beans
    31
    Distro
    Ubuntu Development Release

    Re: Firefox can't open php file from apache2 server on localhost

    Quote Originally Posted by s_ø View Post
    Try to open the php5.conf in mods-enabled.
    Code:
    sudo nano /etc/apache2/mods-enabled/php5.conf
    It should look like this
    Code:
    <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.
    Code:
    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!
    Last edited by Makrie; April 7th, 2010 at 10:21 PM. Reason: clarify steps taken
    like a phoenix ignition

  8. #8
    Join Date
    May 2009
    Beans
    121
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Firefox can't open php file from apache2 server on localhost

    This is a pretty fancy expression for something simple
    Code:
    <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.
    Code:
    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.
    Last edited by s_ø; April 7th, 2010 at 10:40 PM.

  9. #9
    Join Date
    May 2009
    Beans
    121
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Firefox can't open php file from apache2 server on localhost

    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>

  10. #10
    Join Date
    Nov 2005
    Beans
    31
    Distro
    Ubuntu Development Release

    Re: Firefox can't open php file from apache2 server on localhost

    Quote Originally Posted by s_ø View Post
    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 :/
    like a phoenix ignition

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •