Ok ... first of all as root use the command: locate to find files example: locate error <CR>
Right ..
Lets assume that all three applications are on your Linux box .. thats Apache, MySQL and PHP.
We can test that each work in the following manner:
To see that Apache is running and serving a page we can first do from a telnet (or ssh) terminal, ps -ef | grep httpd ... you should see something like this as the output ....
ps -ef | grep httpd
root 7975 1 0 May19 ? 00:00:00 /usr/sbin/httpd -DHAVE_PROXY -DH
apache 21150 7975 0 04:02 ? 00:00:00 /usr/sbin/httpd -DHAVE_PROXY -DH
apache 21151 7975 0 04:02 ? 00:00:00 /usr/sbin/httpd -DHAVE_PROXY -DH
apache 21152 7975 0 04:02 ? 00:00:00 /usr/sbin/httpd -DHAVE_PROXY -DH
apache 21153 7975 0 04:02 ? 00:00:00 /usr/sbin/httpd -DHAVE_PROXY -DH
apache 21154 7975 0 04:02 ? 00:00:00 /usr/sbin/httpd -DHAVE_PROXY -DH
apache 21155 7975 0 04:02 ? 00:00:00 /usr/sbin/httpd -DHAVE_PROXY -DH
apache 21156 7975 0 04:02 ? 00:00:00 /usr/sbin/httpd -DHAVE_PROXY -DH
apache 21165 7975 0 04:02 ? 00:00:00 /usr/sbin/httpd -DHAVE_PROXY -DH
Therefore we can see that apache has one initital process started by root (who then passes control to apache) and eight child process running by apache. ..... thats good
If you only see your grep and no httpd processes then Apache is not running.
Ok so we have a running apache server .. now from that same terminal window do the following: telnet localhost 80 <CR> (where <CR> is pressing the enter key) ... you should be presented with something like the following:
[admin@esl2000 admin]$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Now just type:
GET <CR>
you should get the contents (in html code) of index.htm spooled out to your terminal ?
That would indicate that Apache is serving a page ok.
Now for PHP ... ok there are a number of things we can do to check and then prove php is working under Apache ....
First: check that /etc/httpd/conf/httpd.conf (apache's config file) is aware that we want to use something
.php as a valid file suffix (I think you have got to this point anyway but bear with me) .... so in httpd.conf we need to be sure that somewhere the following lines are included (by that I mean allready there):
DirectoryIndex index.html index.htm index.shtml
index.php index.php4 index.php3 index.cgi
AND
# AddType: allows you to tweak mime.types without actually editing it, or to
# make certain files to be certain types.
#
# The following is for PHP4 (conficts with PHP/FI, below):
<IfModule mod_php4.c>
AddType application/x-httpd-php .php4 .php3 .phtml .php
AddType application/x-httpd-php-source .phps
</IfModule>
Now lets assume that they are there (if not we need to look at why your install failed to configure correctly).
So on to testing php inside Apache:
now we write a file in the DocumentRoot of our webserver and call it test.php place just the following in that file:
<? echo phpinfo(); ?>
save and close the file now we can test php works go to your browser (on your Linux machine if you like ) and do
(or from another machines browser)
And you should see something like this:
Ok php works.
Now to the difficult bit MySQL:
Ok now cut and paste the following (from just after <CUT> down to above the next <CUT>) into a file called test.sql and place it in /tmp on your linux server:
<CUT>
# MySQL dump 8.14
# Table structure for table 'entries'
CREATE TABLE mytest (
id int(11) NOT NULL auto_increment,
title varchar(60) default NULL,
text blob,
date datetime default NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
# Dumping data for table 'entries'
INSERT INTO mytest VALUES (1,'paper','Cuts stone','2002-04-01 10:23:31');
INSERT INTO mytest VALUES (2,'Linux and Apache','I have discovered that Linux and Apache are shining examples of Open Source projects.','2002-04-03 11:03:52');
INSERT INTO mytest VALUES (3,'Perl','Perl is great','2002-04-05 16:13:22');
INSERT INTO mytest VALUES (4,'CGI and mod_perl','Way to go!.','2002-04-08 12:43:26');
INSERT INTO mytest VALUES (5,'PHP is cool!','Learning PHP is the best thing that I did today.','2002-04-16 08:19:28');
<CUT>
Ok now on your linux server do the following: cd /tmp; mysql
you should now have the mysql> prompt ?
So now at that prompt do: mysql>use test <CR> .. this will say database changed .... now do: source /tmp/test.sql <CR>
this should create a table in test called mytest and populate it for you .... now check this with mysql>show tables;
if its there do: mysql>SELECT * FROM mytest; .... see teh contents?
I hope so ....
Ok lets speed things up now ... create an fred.php file and add this as its contents:
Again after and before <CUT> ....
<CUT>
<?
// connect to the mysql server on localhost
$mysql = mysql_connect("localhost", "apache", ""

or die("could not connect to mysql"

;
// execute the MySQL query, grab the result in $result
$result = mysql_db_query("test", "SELECT * FROM mytest"

or die("query failed - " . mysql_errno() . ": " . mysql_error());
?>
<html>
<head>
<title>PHP and MySQL TEST</title>
</head>
<body bgcolor="#ffffff">
We executed: <b>SELECT * FROM mytest</b>
<hr>
We found <b><? echo mysql_num_rows($result); ?></b> rows.
<h3>Query result</h3>
<?
//loop through each row
while ($array = mysql_fetch_row($result)) {
// foreach column in the row
foreach ($array as $f) {
print "$f :: ";
}
print "<hr>";
}
?>
</body>
</html>
<?
// we are all done, so close the MySQL connection
mysql_close($mysql);
?>
Now try it from your browser http:// your ip address/fred.php you should get the following:
Good Luck,
21:12 time for shower
Laurie.