PDA

View Full Version : PHP help



truNWA
July 10th, 2006, 01:33 AM
I think I have installed MYSQL and PHP and Apache. When i run this MYSQL test:


<html>
<head><title>MySQL Connection Test</title></head>

<body>
<h2>
<?php
$connection = mysql_connect( "localhost", "root", "" ) or die( "Sorry - unable to connect to MySQL");
echo( "Congratulations!!!! - you connected to MySQL");

?>
</h2>
</body></html>


firefox asks me to downlaod the file. any suggestions?

Engnome
July 10th, 2006, 02:15 AM
Is it in /var/www ? Do access it with http://127.0.0.1 ? file:// won't work.

noob_Lance
July 10th, 2006, 03:35 AM
also ... make sure mysql is running and you have it set up correctly

gruepig
July 10th, 2006, 07:14 AM
firefox asks me to downlaod the file. any suggestions?

You've actually set up three things: apache, php, and mysql. It seems that apache (and all things network-related) is working, as you got asked to download the file. Can you access any .php pages? My guess, based on the error, is no.

Make sure the php module is enabled and configured. For apache2 and php4, you should have something like:



$ cat /etc/apache2/mods-enabled/php4.load
LoadModule php4_module /usr/lib/apache2/modules/libphp4.so

$ cat /etc/apache2/mods-enabled/php4.conf
<IfModule mod_php4.c>
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
</IfModule>

$ grep php /etc/mime.types
application/x-httpd-php phtml pht php
application/x-httpd-php-source phps
application/x-httpd-php3 php3
application/x-httpd-php3-preprocessed php3p
application/x-httpd-php4 php4


Then, once you have php pages serving, you can make sure that mysql (and the php-mysql interaction) is working.

Also a bit about security if your site is exposed to the Internet: By default, the mysql root password is null; you'll want to change this ('mysqladmin -u root password'). Similarly, php doesn't have the most secure defaults; you can change these in /etc/php4/apache2/php.ini. And make sure to keep your software up-to-date; this is easy to do and makes a huge difference.

truNWA
July 10th, 2006, 02:28 PM
Is it in /var/www ? Do access it with http://127.0.0.1 ? file:// won't work.

yes


also ... make sure mysql is running and you have it set up correctly

please tell me how to do that


Make sure the php module is enabled and configured. For apache2 and php4, you should have something like:



$ cat /etc/apache2/mods-enabled/php4.load
LoadModule php4_module /usr/lib/apache2/modules/libphp4.so

$ cat /etc/apache2/mods-enabled/php4.conf
<IfModule mod_php4.c>
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
</IfModule>

$ grep php /etc/mime.types
application/x-httpd-php phtml pht php
application/x-httpd-php-source phps
application/x-httpd-php3 php3
application/x-httpd-php3-preprocessed php3p
application/x-httpd-php4 php4




I get a "No such Directory error for all of those"

l.tambiah
July 10th, 2006, 02:40 PM
I would remove everthing, and start from scratch. Use the wiki page at https://help.ubuntu.com/community/ApacheMySQLPHP. I know this method of installing works...

ifokkema
July 10th, 2006, 07:57 PM
I get a "No such Directory error for all of those"
You've probably got apache 1.3 installed. I would carefully follow the link mentioned above.