newbee Posted February 24, 2007 Share Posted February 24, 2007 Hello, I am new to this so pardon the basic question. I installed Apache 2.2 on my home computer and it works. I then installed MySQL 5.0.27 and then installed php 5.2.1. This is a software development effort so everything is on my local computer drive. I am using localhost to run a php test. I keep getting error 404. I am using a test file called test.php. I've also made all the recommmended modifications to the httpd.conf and php.ini files. Can you please help? Thanks a bunch. Quote Link to comment Share on other sites More sharing options...
Tiff Posted February 24, 2007 Share Posted February 24, 2007 You could use a program that installs it onto your computer for you and then use this programs to test it as well by running it on your localhost, i did The program i used was Xampp http://www.apachefriends.org/en/xampp.html Hope this is what you were wondering Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted February 24, 2007 Share Posted February 24, 2007 Hello, I am new to this so pardon the basic question. I installed Apache 2.2 on my home computer and it works. I then installed MySQL 5.0.27 and then installed php 5.2.1. This is a software development effort so everything is on my local computer drive. I am using localhost to run a php test. I keep getting error 404. I am using a test file called test.php. I've also made all the recommmended modifications to the httpd.conf and php.ini files. Can you please help? Thanks a bunch. If you are getting 404 error then the php file cant be found by the server. Where are you putting the php file to? It should be placed in the document root (this is defined in the the httpd.conf) By default it will be something like this C:/Program Files/Apache Group/Apache2/htdocs). Quote Link to comment Share on other sites More sharing options...
newbee Posted February 24, 2007 Author Share Posted February 24, 2007 Thank you to both of you for the help. 1. I installed XAMPP but still have the same problem. How do you test whether the installation was successful from XAMPP. 2. There are two files in the root directory C:\Program Files\Apache Software Foundation\Apache2.2\htdocs Index test.php The Index file is the Apache test file with the message "It works!" and when I type in http://localhost/ it indeed works and I get the "It works!" message on the screen. When I type http://localhost/test.php I get error 404. Does this explain it to you so you can provide further assistance? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted February 24, 2007 Share Posted February 24, 2007 Remove index from the htdocs folder. Then go to http://localhost/ do you see your PHP file listed in the directory index? Quote Link to comment Share on other sites More sharing options...
newbee Posted February 24, 2007 Author Share Posted February 24, 2007 I did and it stll shows "It works!" on the screen. Does this mean that the root directory is somewhere other than C:\Program Files\Apache Software Foundation\Apache2.2\htdocs? What do I do next? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted February 24, 2007 Share Posted February 24, 2007 Clear your browser cache or do a hard refresh (Ctrl + F5). If it still displays it works then opone up your httpd.conf and scroll to line 150 which should be this: DocumentRoot "path/to/document/root/here" Change path/to/document/root/here with what DocumentRoot is currently set to. What is it set to? Quote Link to comment Share on other sites More sharing options...
newbee Posted February 24, 2007 Author Share Posted February 24, 2007 O.k. I pushed Ctrl+F5 and now it does not appear in the list. test.php does show in the list and when I click on test.php, it only displays: This is an html line. The contents of test.php is: <html> <head> <title>PHP Test</title> </head> <body> <p>This is an HTML line <p> <?php echo "This is a PHP line"; phpinfo(); ?> </body></html> So now it appears that it soes not execute the php code. BTW, the root directory is: DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs" Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted February 24, 2007 Share Posted February 24, 2007 Ok Apache is misconfigured, how have you configured Apache? Adding the following to the httpd.conf should be sufficient: LoadModule php5_module "C:/PHP/php5apache2_2.dll"; PHPIniDir "C:/WINDOWS" AddType application/x-httpd-php .php Note -- change C:/PHP to to the correct path to PHPs folder. Save the httpd.conf and restart Apache. Quote Link to comment Share on other sites More sharing options...
newbee Posted February 24, 2007 Author Share Posted February 24, 2007 LoadModule php5_module "C:/PHP/php5apache2_2.dll"; was alredy done. I changed PHPIniDir "C:/php" to PHPIniDir "C:/WINDOWS". AddType application/x-httpd-php .php was already done. Saved the file and restarted Apache but same problem. Anything else I can try? Thanks again for your time. Quote Link to comment Share on other sites More sharing options...
bbxrider Posted February 26, 2007 Share Posted February 26, 2007 did you add your php directory location (c:\php if thats it) to your path environment variable? if you do that, its what i did, you don't need to add any php files to other places like windows nice explanation -->http://vlaurie.com/computers2/Articles/environment.htm also it won't matter until you actuallly get php being invoked, but it can be helpful to change the error displaying to 'on' in php.ini, (display_errors = on), this is good for development and installation and prob want to turn off after things running ok. you need to restart apache after changes to php.ini Quote Link to comment Share on other sites More sharing options...
newbee Posted February 26, 2007 Author Share Posted February 26, 2007 Yes I already added the php directory location to my path environment variable. And the display_errors is on also. Still have the same problem. Error 404 when I type localhost/test.php in the IE URL. If I type localhost, it comes up with the Apache screen "It works!". The test.php file is in the exact same location as the Apache index file (that has the "It works!" message). Quote Link to comment Share on other sites More sharing options...
bbxrider Posted February 26, 2007 Share Posted February 26, 2007 create a simple .htm(l) file and see if that gets sent ok, that should establish if its really a php prob or something peculiar in apache that just it just can't deal with anything but displaying its own index.html i was having prob where the contents of my test.php was being displayed but not executed, then i tried to follow this: http://www.apachelounge.com/forum/viewtopic.php?t=570 but had trouble understanding some of it, so what i did was, -install the vc++ redistributable, not really sure what that is or what it does -uninstall and reinstall apache but i used the .msi file, it was so easy -put the php LoadModule, etc directives immediately after all the other LoadModule stmts in http.conf -restart xp to be sure path variable set and it worked after that Quote Link to comment Share on other sites More sharing options...
newbee Posted February 26, 2007 Author Share Posted February 26, 2007 Well I did exacly like stated and still get the same 404 error. No idea what I am doing wrong. Quote Link to comment Share on other sites More sharing options...
kerberus01 Posted March 1, 2007 Share Posted March 1, 2007 ei... if you're using apache 2.x in windows and change something in httpd.conf and restart the service it has problems.... try restarting windows. Mysite:http://www.wolfpac.net Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.