LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   apache2 not parsing .php file? (https://www.linuxquestions.org/questions/linux-software-2/apache2-not-parsing-php-file-542939/)

rlee923 04-03-2007 07:36 AM

apache2 not parsing .php file?
 
Hello~

I've installed php5, apache2, and mysql from the lastest tarballs.

I think everything is installed fine(sigh*).

I tried phpinfo() on index.php and it shows me all the configuration properly, but when I tried to actually do some sample pages, mozilla wouldn't parse the php file as usual and just comes up with popup saying that what do you want to open this file with?

When I saw that i was screaming... F******K.

Somebody help me please~.

P.S
I am running FC6 with SELinux and I did modify httpd.conf file
for parsing php part by including these two lines,

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

P.S II-

I actually wrote something to check the interoperability between mysql and php - checking whether php can connect to mysql db and stuff- and it actually works. Php file with the code is called test.php, so.. I am not sure why it wouldn't work for other files named such as abc_de.php.

acid_kewpie 04-03-2007 07:46 AM

well it sounds like it is working, but the mimetype being sent to the browser is not being recognised, what does firefox or wireshark or whatever say the content-type of the file being sent actually is? should be text/html and if it is a normal webpage being sent. in that case then it'd be displayed. what would normally happen under fedora / redhat is that you'd use rpm's from yum or other official resources and that will automatically include all relevant configuration, e.g. php is configured under apache by the file /etc/httpd/conf.d/php.conf being dropped in by the php rpm.

btw...

Code:

WORD FINDER RESULTS
Your query f******k turned up these results:

    * feedback
    * firework
    * fishhook
    * flapjack
    * flyspeck
    * footwork
    * forelock
    * fretwork
    * fullback

which one was it?

rlee923 04-03-2007 08:01 AM

wow thanks for the speedy reply.

It says it's a php script.

Also, I didn't do lampsetup through rpm, I just installed from getting tarballs and configuring myself.

And I don't think I need to answer the other question. :D

Oh, and I did search forum before posting this, and the only thing that looked hopeful was removing cache, but it didn't work.

acid_kewpie 04-03-2007 08:15 AM

weell what actually is the content-type header you receive? there are plenty of FF extensions, but i just use wireshark and capture the raw traffic. it's up to the browser to recieve a correct mime type and do something with it. if it's not told it's got html outpout (remember that php itself is just serverside code to output html or other data to a client) then it'll take other actions like sacing it to disk if it's "application/data" or something.

rlee923 04-03-2007 08:23 AM

How do you check the content-header type?
And what are FF extensions?

it really does only say it's php script

it firstly gives me the file name

and one the next line it says it's a php script
and then it gives me the location of the file.

After that it just says what should firefox do with this file?

:S

I am just going crazy~!

acid_kewpie 04-03-2007 08:50 AM

FF = firefox. search for an extension for firefox which will show you http headers

benjithegreat98 04-03-2007 09:46 AM

If you have lynx installed you can type:
lynx -head http://<webserver>/test.php

If you don't have it then "yum install lynx" will get it on there for you.

Also I have
AddType text/html .php
in my config files for apache...

rlee923 04-04-2007 03:54 AM

LOL

I downloaded lynx and tried what you've suggested me, thank you, apparently at the end of the header

for the file I was trying open through Firefox, it gives me x-pad-avoid-browser bug.

Man..... D/L new version of FF and try again I guess.

Btw both of them have text/html as the content-type so I don't think it's apache2's problem.

Any suggestion on the browsers other than Firefox?

Cheers

benjithegreat98 04-04-2007 06:49 AM

Something tells me it is the specific file you are trying to serve.

Read through this thread:
http://lists.evolt.org/archive/Week-...29/149294.html

rlee923 04-05-2007 09:41 PM

Ok.. I just tried opening a dummy php file, without any other code other than

<?php
?>

and even this file gives me the pop up screen asking me what I want to do with it.

But the other php file has far more code than this and it works.

error.. I might try and see the mime setup .

Btw this is the code of the other file that I wrote to check whether mysql works properly or not.

Cheers.
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass =

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'test';
mysql_select_db($dbname);

print "test successful\n"

?>

aznluvsmc 04-05-2007 11:20 PM

I ran into this problem too installing Apache 2.0, PHP 5 on FC6. I fixed it by adding the following line to my httpd.conf file:

AddHandler php5-script .php

I think this line tells Apache that all files ending .php should be parsed using the php interpreter.

benjithegreat98 04-05-2007 11:28 PM

Here is what I get when I view my headers.

HTTP/1.1 200 OK
Date: Fri, 06 Apr 2007 04:22:10 GMT
Server: Apache/2.2.0 (Fedora)
X-Powered-By: PHP/5.1.6
Connection: close
Content-Type: text/html; charset=UTF-8

Can you post what you get?

Is there a reason you chose to manually install as opposed to just using the Fedora 6 official RPMs? It would've been much easier that way.....

aznluvsmc 04-05-2007 11:31 PM

That is my header when testing my phpinfo script. I chose to manually install because I needed SSL and statically linked mod_Perl support.

HTTP/1.1 200 OK
Date: Fri, 06 Apr 2007 04:30:03 GMT
Server: Apache/2.2.4 (Unix) mod_ssl/2.2.4 OpenSSL/0.9.8e PHP/5.2.1 mod_perl/2.0.3 Perl/v5.8.8
X-Powered-By: PHP/5.2.1
Content-Type: text/html

rlee923 04-06-2007 12:03 AM

HTTP/1.1 200 OK
Date: Fri, 06 Apr 2007 04:59:10 GMT
Server: Apache/2.2.4 (Unix) PHP/5.2.1
X-Powered-By: PHP/5.2.1
Connection: close
Content-Type: text/html

Now it doesn't come with browser error message..

The reason I am installing manually is because I have to know how to lamp setup on other disro for one of the machines at the company and they have not decided which distro goes on it.

I'll try few things more and post again.

Btw I've tried Addhandler thing, but it didn't work work :( Thanks for the reply though :)

aznluvsmc 04-06-2007 12:10 AM

That's odd that the AddHandler didn't work. Where did you place it and what exactly did you type in? I double checked on the Apache documentation and it says that AddHandler is required to pass off specific extensions to different modules to handle them.

rlee923 04-06-2007 12:23 AM

Ok, I figured this out.

Maybe I was being very stupid.

When I try open php file I just typed

firefox abc.php

but when I do firefox http://localhost/abc.php

it points.

This raises another question, when I write php with method post or other, I can't put relative path for action= ?

Regards,

rlee923 04-06-2007 12:26 AM

ok now I figured out what is wrong.

When I tried to open the file with the command

firefox abc.php

it wouldn't open

but when I do

firefox http;//localhost/abc.php

it works

This raises another question. When I write some html with post method or something else with action=path, does path have to be absolute and cannot be relative?

Cheers

acid_kewpie 04-06-2007 02:58 AM

so "firefox abc.php" would look to open the file locally, not via the web server... is it unfair to call you a muppet? :D

and yeah you can use relative paths in a document, as if they are served via a url then links are done relative to the current location / protocol.

rlee923 04-08-2007 04:27 AM

No not at all, I was stupid.

Btw how do you do relative path and make the browser recognise it as it's through webserver?

I guess this is the problem I had in the first place.

I tried just normally by putting the other php file in the same directory for action=path
and it wouldn't work. :(

acid_kewpie 04-08-2007 04:40 AM

well it's that changes are made relative to the referring url. so clicking <a href"nextpage.php"> when your furrent page is http://example.com/index.php will go to http://example.com/nextpage.php but from file://home/user/index.php goes to file://home/user/nextpage.php yeah?

rlee923 04-08-2007 08:52 PM

Ok,

This has been fully resolved. (maybe not)

When I load the page with using full path of localhost url, the relative path for the next pages, and action=path works.

But what I was doing is going into the specific directory where the start page file exists and just opening the page by typing

firefox firstpage.html or firefox firstpage.php

Thanks for taking the time to read posts and writing replies. Now I finally figured out how to do stuff properly.

Have a good day everyone!!!.

Special thanks to : acid_kewpie :D


All times are GMT -5. The time now is 04:33 AM.