PHP not working
(running apache 2.2.8-1ubuntu0.3, ubuntu 8.04, firefox 3.01)
I installed apache, go to localhost and see my test page fine. Then I add a single line of php and it does not display (after Ctrl-r). Any help is appreciated. thx Pat Here is the html file: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Hello</title> </head> <body> <h1>It almost WORKS! file is at /var/www/index.html</h1> <?php print "This text does not print"; ?> more text (this prints fine) </body></html> |
Sounds to me like PHP either isn't installed or isn't enabled. Make sure you have the php5 package installed and that the php5.load file is properly linked to in your /etc/apache2/mods-enabled directory.
|
I can link to php file but php code in html page not working
Doing more debugging, if I link to a file phpinfo.php that contains only the line <?php phpinfo(); ?>
this works and I get a nice (long) page of info. But my php code on html pages does not display anything. Any ideas? thx Pat |
What's the file extension on that file? If it's .html, then in the default configuration, Apache won't pass it to PHP at all. Use a .php extension instead. Or you can modify your Apache configuration to treat all .html files as PHP.
|
Doh!!
I was putting the php code in a file named index.html and the html worked fine but php was ignored. I renamed the file to index.php and it works great! I guess any file with php needs to have the .php extension.
thx Pat |
All times are GMT -5. The time now is 03:00 AM. |