Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
can't open php files
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
veilig
Apprentice
Apprentice


Joined: 11 May 2005
Posts: 153

PostPosted: Mon Oct 16, 2006 4:56 pm    Post subject: can't open php files Reply with quote

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
View user's profile Send private message
chrbecke
Guru
Guru


Joined: 12 Jul 2004
Posts: 598
Location: Berlin - Germany

PostPosted: Mon Oct 16, 2006 5:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
veilig
Apprentice
Apprentice


Joined: 11 May 2005
Posts: 153

PostPosted: Mon Oct 16, 2006 5:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
chrbecke
Guru
Guru


Joined: 12 Jul 2004
Posts: 598
Location: Berlin - Germany

PostPosted: Mon Oct 16, 2006 5:34 pm    Post subject: Reply with quote

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
Code:
php -f phpinfo.php
That will run your php script and print the output it generates to your console.
Back to top
View user's profile Send private message
veilig
Apprentice
Apprentice


Joined: 11 May 2005
Posts: 153

PostPosted: Mon Oct 16, 2006 6:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
chrbecke
Guru
Guru


Joined: 12 Jul 2004
Posts: 598
Location: Berlin - Germany

PostPosted: Mon Oct 16, 2006 6:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum