[TriLUG] Strange PHP problem

Matt Nash mattnash at intrex.net
Tue May 16 12:15:34 EDT 2006


If I save the file it contains PHP source.

I checked the contents of /etc/mime.types and it seems OK.  Just for 
fun, I changed the name of the type for .php files to 
application/x-httpd-php5 but that had no effect on the MIME type 
reported by Firefox, even after a restart of Firefox.

I tested your theory on Firefox caching the mime-type:  I stopped 
Apache, then tried to load the /sugar directory, which resulted in the 
usual error.  I was then able to save that file as PHP source.

Josh Vickery wrote:
> If you choose to save the file in firefox what does it contain?  HTML
> or PHP source?  If the files contain HTML then PHP is working, but
> Apache and Firefox are fighting over mime-types.  If the file contains
> PHP source, then PHP is not working.
>
> There is no way to be sure without looking at what Apache serves up,
> but I'm betting that it is a mime-type issue, and not a PHP config
> issue.  I had a similar problem recently when I installed Sun's JDK
> and it created a /etc/mime.types file containing the single
> uncommented line:
> type=application/x-java-jnlp-file desc="Java Web Start" exts="jnlp"
>
> /etc/mime.types.dpkg-dist was later created by the Debian package
> "mime-support", and so copying that file over /etc/mime.types fixed my
> Apache problems.
>
> I've also noticed that Firefox has a habit of caching mime-type
> information about a URL until the entire browser has been restarted,
> which might explain why you get the same error, even when Apache isn't
> running.
>
> Josh
>
> On 5/16/06, Matt Nash <mattnash at intrex.net> wrote:
>> I'm pretty sure that all of those directives were already being
>> executed, but I created the file anyway.  All I got was the same error
>> about the module already being loaded, and no change in my symptoms.
>>
>> Dave Sorenson wrote:
>> > ACK!! my bad.. httpd/conf.d/ should have a php.conf file, not a copy
>> > of php.ini... here's what mine has in it:
>> >
>> >
>> > <BOP>
>> > # PHP is an HTML-embedded scripting language which attempts to make it
>> > # easy for developers to write dynamically generated webpages.
>> > #
>> >
>> > LoadModule php4_module modules/libphp4.so
>> >
>> > #
>> > # Cause the PHP interpreter to handle files with a .php extension.
>> > #
>> > AddType application/x-httpd-php .php
>> > # AddType application/x-httpd-php-source .phps
>> >
>> > #
>> > # Add index.php to the list of files that will be served as directory
>> > # indexes.
>> > #
>> > DirectoryIndex index.php
>> >
>> > <EOP>
>> > you'll need to make the changes for PHP5
>> >
>> > Sorry for the mislead... dang it I hate the start of a new semester..
>> >
>> > Dave
>> >
>> > Matt Nash wrote:
>> >> Thanks for your quick response, Dave.
>> >>
>> >> '/usr/sbin/apache2 -l' does not list php or php5.  However,
>> >> '/usr/sbin/a2enmod php5' returns 'This module is already enabled!'.
>> >> When I look at the / directory listing on my browser, the bottom line
>> >> reads "Apache/2.0.55 (Ubuntu) PHP/5.1.2-1ubuntu2 Server at stewbuntu
>> >> Port 80"
>> >>
>> >> Adding a LoadModule directive to apache2.conf for libphp5.so results
>> >> in a warning that the module is already loaded.
>> >>
>> >> I tried copying php.ini to /etc/apache2/conf.d but restarting apache
>> >> resulted in an error indicating it couldn't parse the file.
>> >>
>> >> There is an AddType line already in apache2.conf for php.  Adjusting
>> >> the defined name of this type has no effect on the error message.
>> >>
>> >> Dave Sorenson wrote:
>> >>> OK I realize it's bad form to respond to your own message, but make
>> >>> sure your httpd/conf.d/ has a php..ini file as well as that is where
>> >>> the libs are loaded and the addtype is defined.
>> >>>
>> >>> Dave Sorenson wrote:
>> >>>> Sounds like php is not being loaded with apache. Did the upgrade
>> >>>> move the location of PHP? Check your httpd.conf file and make sure
>> >>>> the PHP module is being loaded, then check the php.ini and make
>> >>>> sure all the paths to the PHP libs are correct.
>> >>>>
>> >>>> Matt Nash wrote:
>> >>>>> Hi folks,
>> >>>>>
>> >>>>> I am having a problem with my Apache2/PHP5 installation on a
>> >>>>> relatively new Ubuntu Dapper installation.  I regularly perform a
>> >>>>> dist-upgrade and I believe it was after one of these that my
>> >>>>> problems began.
>> >>>>>
>> >>>>> I have been testing out SugarCRM as well as using phpmyadmin to
>> >>>>> manage MySQL, and these apps have been working just fine.
>> >>>>> Suddenly, the web server has started treating PHP scripts as files
>> >>>>> to download rather than scripts to execute.  The browser says "You
>> >>>>> have chosen to open (...) which is a: application/x-httpd-php.
>> >>>>> What should Firefox do with this file?"  There is empty space in
>> >>>>> place of the (...), not a file name.
>> >>>>>
>> >>>>> I have been through the Apache config file and added a ScriptAlias
>> >>>>> and Action directive to try to solve this, but nothing I do seems
>> >>>>> to have any effect.  In fact, I can't seem to change the name of
>> >>>>> the MIME type in the error message-- if I change the line in
>> >>>>> apache2.conf to read "AddType application/x-httpd-phpBLAH .php"
>> >>>>> then the message that Firefox pops up still includes
>> >>>>> "application/x-httpd-php".
>> >>>>>
>> >>>>> To add to the confusion, if I type the full path to an actual PHP
>> >>>>> script into the address bar, I get a slightly different message:
>> >>>>> "You have chosen to open index.php which is a: PHP file"
>> >>>>>
>> >>>>> Even stranger, I still get the "What should Firefox do with this
>> >>>>> file?" message after I have stopped Apache.
>> >>>>>
>> >>>>> Thanks for any help you can offer.
>> >>>>>
>> >>>>> Matt
>> >>
>>
>> -- 
>> TriLUG mailing list        : 
>> http://www.trilug.org/mailman/listinfo/trilug
>> TriLUG Organizational FAQ  : http://trilug.org/faq/
>> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
>>




More information about the TriLUG mailing list