LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Where do I put my PHP files and folders? (https://www.linuxquestions.org/questions/linux-software-2/where-do-i-put-my-php-files-and-folders-155580/)

mosdef 03-09-2004 05:40 PM

Where do I put my PHP files and folders?
 
I'm kind of new to this. I am setting up a RedHat 9.0 server to run 2 seperate intranets. Here is my Problem: I don't know where to put the files and folders for my sites. I want to keep them seperate, but I'm not sure of how to do that. There will be two webmasters for each intranet, so they have their own ftp logins. Am I being clear? Help me please, and if I need to clarify more then just ask. THANKS!!!!!!!

bogart 03-09-2004 06:37 PM

Where do I put my PHP files and folders?
 
If you did a stock standard install then your document root is likely to be /var/www/html. Thus, if you want to access a php file (or any other file for that matter, via a browser, then you need to put the files into a directory under this path. For example, if you have a file:
Code:

<? phpinfo(); ?>
then save it as info.php in the /var/www/html/ directory and then in your broswer type the URL http://localhost/info.php This will tell you if you have Apache loaded with PHP. It will also return you a lot of information including all of the environment variables.

mosdef 03-09-2004 07:07 PM

So, all my PHP files go in /var/www/html ? Can I create sub folders in that directory and put my PHP files for the two seperate intranets in those? I mean can I do:
mkdir /var/www/html/intranet01
mkdir /var/www/html/intranet02

and store my seperate PHP files in those?

secho 03-09-2004 08:56 PM

you should be able to create those subdirectories without a problem, but apache may still be setting /var/www/html/ as the document root (so the site would be http://localhost/intranet01 and http://localhost/intranet02). You may want to look at the configuration file for apache. Look for the document root information (this is where all your documents should be). My configuration files for apache2 are in:
/etc/apache2/config/
so its probably something close with redhat 9.


hope this helps.

mosdef 03-10-2004 09:49 AM

When I created the new directories my .php and even my .html files wouldn't work. All I got was a page not found error. I thought it would be as simple as visiting the url http://ip-address/intranet01/page01.php. Am I wrong on this one? Thanks for all the help I appreciate it lots.

secho 03-10-2004 12:25 PM

"I thought it would be as simple as visiting the url http://ip-address/intranet01/page01.php. Am I wrong on this one?"

No it is that eays once you get it setup.
Did the .html or .php files work in the root directory? (i.e. http://ip-address/?) If so, check the permissions of the files and the directory.

Also, what error does your browser give you when you try to go to the page? does it say page not found?

mosdef 03-21-2004 12:35 PM

They worked fine when they were in the root directory. All the permissions are set correctly. I get a Cannot Find Server, This Page Cannot be Displayed Error.

Darkside06 08-07-2012 06:51 AM

Check weather do you have a permission to create a file or folder in /var/www
 
Hi,
Most of the time New to php in linux face a problem , that they are not able to create any folder or file in var/www ,in that case you have to enable the permission to create a file or folder in /var/www

Step to do that
1.Open you terminal by pressing ctrl+alt+T
2.Then type sudo su
3.Then enter admin password
4.Then you would see like this root@administrator:/home/administrator#
5.In front of that type chmod -Rf 777 /var/www/
6.Check your var/www folder you would be able to create a file or folder there.

cheers!!

Darkside.

Wim Sturkenboom 08-07-2012 07:14 AM

Great, 8 year old thread.

Quote:

Originally Posted by Darkside06 (Post 4748022)
...
5.In front of that type chmod -Rf 777 /var/www/

And allow the whole world to modify anything. Bad advice.

Darkside06 08-07-2012 07:20 AM

Hi Wim

I m Newbie to Php just started few days back and i was stuck in this,but this works for me.
I applogize if there is a mistake by my side, but i m sure people like you will guide me always.

Thank you

Wim Sturkenboom 08-07-2012 11:16 AM

My approach is to let Apache read from somewhere in the user's home directory. Only problem can be if one has a need for apache to write there, but that can solved with permissions.

sundialsvcs 08-07-2012 07:52 PM

Honestly, I believe that you simply must take some time with the Apache docs (and with perusal of the existing Apache configs provided with your distro), and actually learn how Apache takes the URL-string that it has been given and interprets it. There are (of course) a myriad of options, but, "if you keep your eye on the ball, at all times," the task ultimately always begins-and-ends with that URL string.

And ... there are lots of excellent tutorials, both on the Apache web-server site and many places elsewhere.

"You only have to learn this once," but you really do need to take the time to gain understanding of what is really going on, and of the various alternatives that Apache gives you.


All times are GMT -5. The time now is 11:56 AM.