View previous topic :: View next topic |
Author |
Message |
veilig Apprentice
Joined: 11 May 2005 Posts: 153
|
Posted: Mon Oct 16, 2006 4:56 pm Post subject: can't open php files |
|
|
I just emerged apache and php and followed this guide to make sure that php would work with apache. but at the bottom of the wiki I don't have the phpinfo.php file they say to open and check your system with. and if I were to create one with the code and try to open it, it doesn't run in a browser window but just opens gedit. am I missing an important step or something? |
|
Back to top |
|
|
chrbecke Guru
Joined: 12 Jul 2004 Posts: 598 Location: Berlin - Germany
|
Posted: Mon Oct 16, 2006 5:02 pm Post subject: |
|
|
You have to put the php file you created somewhere below the document root of your web server (e.g. if you called the file phpinfo.php, put it in /var/www/localhost/htdocs/phpinfo.php). Then, make sure apache is started (/etc/init.d/apache start) and point your browser to http://localhost/phpinfo.php. |
|
Back to top |
|
|
veilig Apprentice
Joined: 11 May 2005 Posts: 153
|
Posted: Mon Oct 16, 2006 5:15 pm Post subject: |
|
|
hmmm....apache is started and I tried that, when i follow your link I just get a 404
Quote: | The requested URL /phpinfo.php was not found on this server. |
and when I try to open from a file browser it again just opens the script in gedit |
|
Back to top |
|
|
chrbecke Guru
Joined: 12 Jul 2004 Posts: 598 Location: Berlin - Germany
|
Posted: Mon Oct 16, 2006 5:34 pm Post subject: |
|
|
veilig wrote: | hmmm....apache is started and I tried that, when i follow your link I just get a 404
Quote: | The requested URL /phpinfo.php was not found on this server. |
|
That means that you didn't configure apache with /var/www/localhost/htdocs as document root.
Check your /etc/apache2/http.conf or /etc/apache2/vhosts.d/00_default_vhost.conf files for a line containing "DocumentRoot" followed by a path. That path is your document root. Put your php file in this directory and try again.
veilig wrote: | and when I try to open from a file browser it again just opens the script in gedit |
That's normal. You just created a small program, a php script. If this php script is served by your apache (and mod_php is configured correctly), apache will run it and show the output in your browser. If you try to open the program in nautilus, nautilus sees that it is a php script, which is just a text file, and opens it in your default text editor.
If you want to run the script without using your webserver, you have to make sure you emerged php with USE="cli", open a terminal and run That will run your php script and print the output it generates to your console. |
|
Back to top |
|
|
veilig Apprentice
Joined: 11 May 2005 Posts: 153
|
Posted: Mon Oct 16, 2006 6:02 pm Post subject: |
|
|
okay, I checked out the file for the DocumentRoot and found it was pointing to where it was supposed to. So I tried it again and poof it worked....not sure what happened to make it work, but hey at least it does now. now I have a really dumb question, since I'm totally new to apache and running it off my computer. how or what do I have to do to set it up so I can make it work with my files in my home directory? is there a tuturial out there somewhere? thanks for all your help! |
|
Back to top |
|
|
chrbecke Guru
Joined: 12 Jul 2004 Posts: 598 Location: Berlin - Germany
|
Posted: Mon Oct 16, 2006 6:15 pm Post subject: |
|
|
veilig wrote: | now I have a really dumb question, since I'm totally new to apache and running it off my computer. how or what do I have to do to set it up so I can make it work with my files in my home directory? |
You are probably looking for mod_userdir. It let's you access files located in /home/<username>/public_html/ under the URL http://localhost/~<username>/.
veilig wrote: | is there a tuturial out there somewhere? thanks for all your help! |
A good resource is the documentation available on apache.org. Or search google for apache tutorials, there are millions out there. |
|
Back to top |
|
|
|