LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Browser trys to download php files (https://www.linuxquestions.org/questions/linux-software-2/browser-trys-to-download-php-files-409293/)

Sp@rticus 01-29-2006 09:37 AM

Browser trys to download php files
 
Hi,

I am a newb to linux, but thought this post should go here...

I have SUSE 9.3, I wanted to setup a local webserver to do some test on running Mambo or something similar...

I have compiled:

MySQL - 4.0.26
Apache - 1.3.34
PHP - 4.4.2

From Source, I know that there maybe newer versions of these available but the HOWTO guide I followed used these version so I used them as well.

Everything complied and installed fine (or so it seems) but when I try and view a local php file (eg php.info) my browser tries to download the file instead of actually viewing it? It also does the same with .html files and .htm files...I don't think it is my browers settings cause I can view these same files on the internet it's just locally that I have these problems

I am sure there some thing wrong with either my php.ini file or my http.conf files...but not sure which one?

I have browsed the net and this site for hours looking for solutions to this but I can't seem to find anybody that has had similar problems on this site...and the links that google give me are mostly broken or deleted.

Is there anybody there that has had the same problem? or know of where the problem lies?

Thanks!

Sorry I should have said, I found some similar instances on the forums but none of the fixes worked for me!

KimVette 01-29-2006 11:46 AM

You need to run those files via Apache and view them via a URL (e.g., http://localhost/foo.php ) in order for the browser to receive the proper MIME type definition, and for the PHP to actually be interpreted (run).

Artanicus 01-29-2006 11:50 AM

Its probably that youre missing the httpd.conf instruction to feed the php pages thru the php parser. Check to see if your conf includes lines like these, they could also be in some other conf file that is included via the httpd.conf:
Code:

AddType application/x-httpd-php .php
DirectoryIndex index.html index.php # also nifty but not related to your problem


KimVette 01-29-2006 12:30 PM

That is not the issue (Edit: in reference to: the DirectoryIndex, I missed the AddType setting in your post, sorry about that) , because:

Quote:

It also does the same with .html files and .htm files..

egghead 01-29-2006 01:14 PM

Quote:

Sorry I should have said, I found some similar instances on the forums but none of the fixes worked for me!
Did you clear the browser's cache after changing httpd.conf? Try it and see if it works!

KimVette 01-29-2006 01:46 PM

The "correct" location to specify the php mime type in SuSE is in /etc/apache2/conf.d/php4.conf (assuming you're running php4). These lines should be present:

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

for support for .php, .php3, .php4, and .phps extensions.

Likewise, the DirectoryIndex definitions (for php files) are normally defined in here by default:

DirectoryIndex index.php
DirectoryIndex index.php3
DirectoryIndex index.php4

Sp@rticus 01-30-2006 01:32 AM

Browser trys to download php files
 
Hi Everybody,

Thanks for all the speedy replies! :)

Artanicus, I have these lines in my httpd.conf file both of them actually and no luck....

Egghead, thanks for the suggestion but unfortunately that did help either....

KimVette, i have searched my whole Pc for foo.php and don't have it anywhere, and with regard to your last post, I am not running Apache2, I have apache 1.3 from source and php 4, so there is no /etc/apache2/ directory on my machine...do you think it maybe better to install apache2 (Using yast)?

If so how do I uninstall apache 1.3 if I compiled it from source?

Once again thanks for the replys!

evil_empire 01-30-2006 01:46 AM

Sp@rticus,
foo.php was just an example KimVette gave.
As KimVette is saying you need to access the php file as URL not as filesystem files. Put the php files in the Document Root, make sure php is enabled\loaded in httpd.conf and then try accessing them as URL.
eg elinks http:\\localhost\test.php

Paste your httpd.conf here so that we can see where your webroot is and if php is enabled or not.

Sp@rticus 01-30-2006 02:07 AM

Browser trys to download php files
 
:p Little embarassed there, misunderstood what KimVette meant...sorry...lol

The thing is I am doing that in my browser (Firefox 1.5) I am typing http://localhost/info.php I have also tried http://127.0.0.1/info.php and no luck...

Here is my httpd.conf file....(I just deleted out all the commented lines to make it smaller)


Code:

ServerType standalone

ServerRoot "/usr/local/apache"


PidFile /usr/local/apache/logs/httpd.pid


ScoreBoardFile /usr/local/apache/logs/httpd.scoreboard


Timeout 300

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 15

MinSpareServers 5
MaxSpareServers 10

StartServers 5

MaxClients 150

MaxRequestsPerChild 0

LoadModule env_module        libexec/mod_env.so
LoadModule config_log_module  libexec/mod_log_config.so
LoadModule mime_module        libexec/mod_mime.so
LoadModule negotiation_module libexec/mod_negotiation.so
LoadModule status_module      libexec/mod_status.so
LoadModule includes_module    libexec/mod_include.so
LoadModule autoindex_module  libexec/mod_autoindex.so
LoadModule dir_module        libexec/mod_dir.so
LoadModule cgi_module        libexec/mod_cgi.so
LoadModule asis_module        libexec/mod_asis.so
LoadModule imap_module        libexec/mod_imap.so
LoadModule action_module      libexec/mod_actions.so
LoadModule userdir_module    libexec/mod_userdir.so
LoadModule alias_module      libexec/mod_alias.so
LoadModule rewrite_module    libexec/mod_rewrite.so
LoadModule access_module      libexec/mod_access.so
LoadModule auth_module        libexec/mod_auth.so
LoadModule setenvif_module    libexec/mod_setenvif.so

ClearModuleList
AddModule mod_env.c
AddModule mod_log_config.c
AddModule mod_mime.c
AddModule mod_negotiation.c
AddModule mod_status.c
AddModule mod_include.c
AddModule mod_autoindex.c
AddModule mod_dir.c
AddModule mod_cgi.c
AddModule mod_asis.c
AddModule mod_imap.c
AddModule mod_actions.c
AddModule mod_userdir.c
AddModule mod_alias.c
AddModule mod_rewrite.c
AddModule mod_access.c
AddModule mod_auth.c
AddModule mod_so.c
AddModule mod_setenvif.c

Port 80

User nobody
Group nobody

ServerAdmin (Removed) Do not want my mail address on the net

ServerName 127.0.0.1

DocumentRoot "/srv/www/htdocs"

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

<Directory "/srv/www/htdocs">

    Options Indexes FollowSymLinks MultiViews

    AllowOverride None

    Order allow,deny
    Allow from all
</Directory>

<IfModule mod_userdir.c>
    UserDir public_html
</IfModule>

<IfModule mod_dir.c>
    DirectoryIndex index.php index.htm index.html
</IfModule>

AccessFileName .htaccess

<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</Files>

UseCanonicalName On

<IfModule mod_mime.c>
    TypesConfig /usr/local/apache/conf/mime.types
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
</IfModule>

DefaultType text/plain
<IfModule mod_mime_magic.c>
    MIMEMagicFile /usr/local/apache/conf/magic
</IfModule>

HostnameLookups Off

ErrorLog /usr/local/apache/logs/error_log

LogLevel warn

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent


CustomLog /usr/local/apache/logs/access_log common

ServerSignature On

<IfModule mod_alias.c>
    Alias /icons/ "/usr/local/apache/icons/"

    <Directory "/usr/local/apache/icons">
        Options Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    Alias /manual/ "/usr/local/apache/htdocs/manual/"

    <Directory "/usr/local/apache/htdocs/manual">
        Options Indexes FollowSymlinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"

    <Directory "/usr/local/apache/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>

</IfModule>

<IfModule mod_autoindex.c>

    IndexOptions FancyIndexing

    AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

    AddIconByType (TXT,/icons/text.gif) text/*
    AddIconByType (IMG,/icons/image2.gif) image/*
    AddIconByType (SND,/icons/sound2.gif) audio/*
    AddIconByType (VID,/icons/movie.gif) video/*

    AddIcon /icons/binary.gif .bin .exe
    AddIcon /icons/binhex.gif .hqx
    AddIcon /icons/tar.gif .tar
    AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
    AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
    AddIcon /icons/a.gif .ps .ai .eps
    AddIcon /icons/layout.gif .html .shtml .htm .pdf
    AddIcon /icons/text.gif .txt
    AddIcon /icons/c.gif .c
    AddIcon /icons/p.gif .pl .py
    AddIcon /icons/f.gif .for
    AddIcon /icons/dvi.gif .dvi
    AddIcon /icons/uuencoded.gif .uu
    AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
    AddIcon /icons/tex.gif .tex
    AddIcon /icons/bomb.gif core

    AddIcon /icons/back.gif ..
    AddIcon /icons/hand.right.gif README
    AddIcon /icons/folder.gif ^^DIRECTORY^^
    AddIcon /icons/blank.gif ^^BLANKICON^^

    DefaultIcon /icons/unknown.gif
    ReadmeName README.html
    HeaderName HEADER.html

    IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

</IfModule>

<IfModule mod_mime.c>

    AddLanguage da .dk
    AddLanguage nl .nl
    AddLanguage en .en
    AddLanguage et .ee
    AddLanguage fr .fr
    AddLanguage de .de
    AddLanguage el .el
    AddLanguage he .he
    AddCharset ISO-8859-8 .iso8859-8
    AddLanguage it .it
    AddLanguage ja .ja
    AddCharset ISO-2022-JP .jis
    AddLanguage kr .kr
    AddCharset ISO-2022-KR .iso-kr
    AddLanguage nn .nn
    AddLanguage no .no
    AddLanguage pl .po
    AddCharset ISO-8859-2 .iso-pl
    AddLanguage pt .pt
    AddLanguage pt-br .pt-br
    AddLanguage ltz .lu
    AddLanguage ca .ca
    AddLanguage es .es
    AddLanguage sv .sv
    AddLanguage cs .cz .cs
    AddLanguage ru .ru
    AddLanguage zh-TW .zh-tw
    AddCharset Big5        .Big5    .big5
    AddCharset WINDOWS-1251 .cp-1251
    AddCharset CP866        .cp866
    AddCharset ISO-8859-5  .iso-ru
    AddCharset KOI8-R      .koi8-r
    AddCharset UCS-2        .ucs2
    AddCharset UCS-4        .ucs4
    AddCharset UTF-8        .utf8

    <IfModule mod_negotiation.c>
        LanguagePriority en da nl et fr de el it ja kr no pl pt pt-br ru ltz ca es sv tw
    </IfModule>

    AddType application/x-tar .tgz
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    AddEncoding x-compress .Z
    AddEncoding x-gzip .gz .tgz

</IfModule>

<IfModule mod_setenvif.c>

    BrowserMatch "Mozilla/2" nokeepalive
    BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0

    BrowserMatch "RealPlayer 4\.0" force-response-1.0
    BrowserMatch "Java/1\.0" force-response-1.0
    BrowserMatch "JDK/1\.0" force-response-1.0

</IfModule>

Thanks, sorry for the confusion earlier

Sp@rticus 01-30-2006 03:24 AM

Okay strange,now I have not changed anything....and now it displays .html and .htm files fine it's just .php files that can't be read

Sp@rticus 01-30-2006 04:57 AM

Browser trys to download php files
 
OK, I did some further investigations into this and according to some posts on other forums I need to add

Code:

LoadModule php4_module        modules/libphp4.so
and

Code:

AddModule mod_php4.c
To my httdp.conf file. So now a new errors arises when I try and start the apche server it comes up with this error:

Code:

Syntax error on line 223 of /usr/local/apache/conf/httpd.conf:
Cannot load /usr/local/apache/modules/libphp4.so into server: /usr/local/apache/modules/libphp4.so: cannot open shared object file: No such file or directory
/etc/init.d/apache start: httpd could not be started

:(

I assume that it is trying to find libphp4.so in that particular directory...which I need to change to the directory that it's in, but I cannot find libphp4.so anywhere on my machine?

So my question would now be how do I install it, I have tried YAST but YAST does not find it. I am sure its part of another package, but wich one. Am I even on the right track here?

Thanks

Artanicus 01-30-2006 05:04 AM

Where did you install php? Cause thats where libphp*.so will be. ITs not always called libphp4/5.php but sometimes just libphp.so a locate for it might reveal the location if your db is up2date, if not updatedb will refreshen it, or you could just do;
Code:

find /usr/ -name "libphp*.so*"
When you find it, symlink it into the place its been looked for:
Code:

ln -s /whree/it/is/libphp.so /usr/local/apache/modules/
btw, you couyld be so lucky that it actually is under the right dir but just with a different name.

Sp@rticus 01-30-2006 06:30 AM

Ok thanks, I found it in a weird place, strange that the find command from the command line found it but not from the gui,linked it anyway, althougth I did not have a modules folder I only have a libexec folder, so I linked it to there, and just edit my conf file to show that.

But now it gives me a new error: lol (Suppose now I know why its called trial and error)

Code:

Syntax error on line 223 of /usr/local/apache/conf/httpd.conf:
Cannot load /usr/local/apache/libexec/libphp4.so into server: /usr/local/apache/libexec/libphp4.so: undefined symbol: JNI_CreateJavaVM
/etc/init.d/apache start: httpd could not be started

Unless thats not the right libphp4.so file I am beginning to think that I need to maybe recompile php4?

If that is the cause this is the command I used to compile php last time:

Code:

./configure \
--with-apxs=/usr/local/apache/bin/apxs \
--disable-debug \
--enable-ftp \
--enable-inline-optimization \
--enable-magic-quotes \
--enable-mbstring \
--enable-mm=shared \
--enable-safe-mode \
--enable-track-vars \
--enable-trans-sid \
--enable-wddx=shared \
--enable-xml \
--with-dom \
--with-gd \
--with-gettext \
--with-mysql=/usr/local/mysql \
--with-regex=system \
--with-xml \
--with-zlib-dir=/usr/lib

Is this okay, do I need to change something? Or am I jumping to the M$ solution of re-installing to quickly?

Thanks for the help once again

Artanicus 01-30-2006 07:01 AM

I've compiled apache && php && mysql myself only once, as it took me a year for the first time to get running and everything compatible within the trio.. After that ive used prebuilt packages and never had a problem since.. So, you will surely get off easier if you install Apache and php from YaST. Undefined symbol errors are on of the nastiest, usually the solution is simply: "these two versions are not compatible with each other, try some other combination" .. d:

Sp@rticus 01-30-2006 07:10 AM

lol...a year..sheesh..ok maybe your suggestion is right and I need to try it from YAST...but now how do I uninstall my already installed versions...? Do I run
make clean or make uninstall as running man make does not show much help...

Thanks


All times are GMT -5. The time now is 05:40 PM.