[web] php/Apache issues

Started by
8 comments, last by Sonnenblume 16 years, 8 months ago
Hey, I am starting to learn more about web development to broaden my knowledge, so I downloaded the latest installers for Apache web server and php. I ran the apache installer, made sure it was working, then stopped it while I ran the php installer. Installation went smoothly. Then, I placed the following file in the htdocs folder in the apache directory. phptest.html <?php phpinfo(); ?> but then when I open it, I get a blank screen and the source still shows the php code. Apaches FAQ says for some reason, the web server is not interpreting the php script. So I checked the apache error log, which aside from what looked normal, had about 15 lines where it said something like this: PHP Startup: Unable to load dynamic library 'D:\\Program Files\\PHP\\ext\\php_exif.dll' - The specified module could not be found.\r\n in Unknown on line 0 only with different dll files on each line. I checked the extensions_dir value in the php.ini file, and that is correct. The php.ini file is also in the correct location to be read by apache. The PATH environment variable also contains the path to the php directory. I have looked at several different websites and I cannot find anything which I haven't tried to get it to work. If anybody has any suggestions, they would be greatly appreciated, as would any extra tips considering I am new to apache and web programming. Thanks in advance, Svenjamin
Advertisement
Well, for a start your file has the wrong extension. PHP files aren't .html, they're usually .php (Or sometimes .php3 or whatever depending on your setup).
To add what Evil Steve said, you can have .html, .htm, etc. files be treated like PHP files so that the code embedded in it is run, but you've got to change a configuration in Apache to do this, and I don't recall what that was (it's not that difficult however).

Probably the easiest thing to do would be to have everything point to .php files and then include any HTML files from there.
As a further wee side note, make sure your not trying to run the file from its location just by double clicking it, you have to access it through your server.

I.e. enter http://localhost/yourTestScript.php into your browsers address bar
Thanks for the replies!

About the extension, I tried the same script with a .php extension, and I still get the blank page. The only difference is if I view the source, nothing is there.
I am accessing the page through the server running on my computer, just like Sonnenblume suggested.

As a side note, I thought that even if the file had an .html extension, the php script inside it would still be executed, but it sounds like this is not the case unless you alter the server settings somehow. Is this correct?

Thanks for the tips, does anyone have any insights as to why apache can't load the dll files that it needs? It seems to me that would solve the problem if it could.

Thanks,
Svenjamin
Quote:Original post by Svenjamin
As a side note, I thought that even if the file had an .html extension, the php script inside it would still be executed, but it sounds like this is not the case unless you alter the server settings somehow. Is this correct?

Thanks for the tips, does anyone have any insights as to why apache can't load the dll files that it needs? It seems to me that would solve the problem if it could.
If the file type is html, then Apache will not invoke PHP to parse the file, it'll just send it to the client as it is, along with the HTTP header (E.g. HTTP 200 OK) - as should be done with all html files. So yes, you're correct.

As for the DLL not being loaded - does that dll exist anywhere? If it doesn't exist, that would explain why it can't be loaded, and would also explain why the PHP file wasn't executed correctly.
Thanks for the explanation.
The dlls all exist and they are in the location that apache says it looked in, but it still says it can't load them. I have no idea why.

Svenjamin
If you're beginning with web development and you simply want to start with PHP and all, and you don't want to deal with manually setting up your server, I'd suggest using XAMPP. The installation and all that is pretty straightforward.
Projects:> Thacmus - CMS (PHP 5, MySQL)Paused:> dgi> MegaMan X Crossfire
Thanks for the suggestion, I'll check that out.
Anyway, I managed to stop the problem from occurring, even if I don't know how to fix it. The dlls that apache was trying to load were all for extensions, and I read on a website earlier that using the extensions requires some extra configuration in apache. Well, since I don't need the extensions, I uninstalled php, and reinstalled it without any extensions, and now everything works great.
Thanks for everybody's help and suggestions!

Svenjamin
Glad its working ok for you now.

One thing that is good about using a pre configured installer such as XAMPP is that additional librarys such as the GD library (used for image functions), exif extensions are already pre-installed.

This topic is closed to new replies.

Advertisement