Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starting PHP 2

Status
Not open for further replies.

neilmurray

Technical User
Jan 18, 2005
32
GB
HI

I have started apache, mysql and loaded PHP. I have made a trial page and the php code is not being read. When I configured PHP I linked it with mysql and apxs2. What is happening?

Thanks,

Neil.
 
Have you set the handler for the .php extension in your httpd.conf file?

AddType application/x-httpd-php .php

This is assuming that by saying 'loaded PHP' you mean that you've added the 'LoadModule ...' part into the httpd.conf already. If not, then you'll need to do that as well.
 
Already included both in the conf file. did ps -aux and mysql and apache are both running. Can't think what else!

Neil.
 
What are you getting when you try to access a .php page?
Are you seeing the raw code?
Are you able to get a raw dump of the server response? (looking for the X-Powered-by line in the headers)
Are you able to access the /server-status or /server-info page? (again, looking for signs of PHP within Apache itself)
PHP doesn't "run" like MySQL or Apache, it simply acts as a parser, much like Perl does for cgi, it only runs as needed and thus won't show up in your process list.

Hopefully I'll have a better idea what is going on when I review your findings.
 
I am using Mozilla to view the page. Here is the test code I am using...

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>This is an HTML line
<p>Help
<?php
echo "This is a PHP line";
phpinfo();
?>
</body>
</html>

and it is saved as test.php

I have loaded all these myself and I am just learning, Does the position of these files or executables matter or once their loaded do they know where each other is. When i configed PHP I linked it to mysql and apxs.

I don't know how to get these raw dumps or status'

Thanks,

Neil.
 
P.S
The browser ouputs what you would expect from an html code. It ignores the php stuff
 
To get a raw dump of the page goto the command prompt (assuming you are on a windows computer) and type the following:
telnet IP_OF_SERVER PORT_OF_SERVER
(this will connect you to the webserver, the screen may clear and move your cursor to the top of the screen, then type the next part, don't worry if you can't see what you're typing, that is normal)
GET HTTP/1.0

(after typing this line, hit enter twice, and the server should spit out some information to you.)

**Example**
telnet 80
GET
The response should start something like this:
---------
HTTP/1.1 200 OK
Date: Wed, 19 Jan 2005 19:47:39 GMT
Content-Type: text/html;charset=ISO-8859-1
Server: Apache/1.3.26 (Unix) mod_gzip/1.3.26.1a PHP/4.3.3-dev
X-Powered-By: PHP/4.3.3-dev
---------
What we're looking for is the stuff with 'PHP/4.3.3-dev' although this will be different depending on your PHP version.
 
I am in Linux. The test.php file is just saved locally on my computer. when I access it as you said with a get command i.e

GET file:///home/neil/test.php

It just throws the file code back at me.

Should I just go to windows and start from scratch, would it be easier?

Neil.
 
Nope, glad to hear you're under linux, but seeing now your syntax gives me an idea of the problem. You're accessing the file directly (file://*) as opposed to accessing it through the server ( assuming you've got the server paths mapped properly you should try and find where that page is on your server.
If you simply want to treat the .php file like a batch file or a script, you may be able to use the php-cli to run it. In this case, try:
php-cli /home/neil/test.php

As for finding the page on your server, RTFM and put things where they need to be.
 
I am just trying to get started using PHP for Dummies. If the problem is that I have to get the file into teh write place, I can get another book to explain.

Thanks,

Neil.
 
The file must be in somewhere in the document space of your web server's document root. Then you can attempt to communicate via telnet with the web server to see if it's configured right and executing PHP scripts.

Actually, your test page can consist entirely of:

<?php
phpinfo();
?>

because that command, when run through a web server, returns well-formed HTML

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top