homepage Welcome to WebmasterWorld Guest from 54.161.175.231
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
Repost: Linux and PHP class location
Where do you store your PHP classes on Linux?
stivare




msg:3988163
 8:11 pm on Sep 11, 2009 (gmt 0)

Reposting my message here, as noone replied to it on PHP forum.....
-----------------------------------------------------
Hi,
I have so far used windows to practice my web development skills. I got a Linux server yesterday and have installed Ubuntu on it. Now I am trying to migrate my local site to this server. I have a few PHP classes that need to go to that machine. Where do I put them? I can not put them in my home directory. Should I just create a /var/www/classes directory and put them there, so that any other website on the same server can use them?

Thanks
Su

 

mcavic




msg:3988588
 11:57 pm on Sep 12, 2009 (gmt 0)

Yes, if they're called with an include or require statement, you can put them anywhere. /var/www/classes or /var/www/lib sounds fine if you want them to be accessible system-wide.

Personally, I would then install each site somewhere outside /var/www, like /home/sitename. I create a separate user account for each site, so that it has a directory under home. But it's just a preference, I can't say that's mandatory.

StupidScript




msg:3989956
 10:34 pm on Sep 15, 2009 (gmt 0)

As mcavic notes, as long as PHP and your web server can get at them, anywhere is fine. On my servers, I enable open_basedir restrictions, so I need to make sure that any PHP file (or directory that PHP might use) is included in the open_basedir list of directories. But otherwise, they are just files that any file that references them can incorporate into its code by use of the include or require set of instructions, after which they become essentially part of the document that referenced them.

i.e.

on server:
- classes.php = <?echo "hello"?>
- test.php = <?include "classes.php"?>, there

in browser:
- test.php = hello, there

stivare




msg:3998875
 9:21 pm on Sep 30, 2009 (gmt 0)

Hi

Thanks guys. Really appreciate your replies

Su

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved