Welcome to WebmasterWorld Guest from

Forum Moderators: bakedjake

Message Too Old, No Replies

Repost: Linux and PHP class location

Where do you store your PHP classes on Linux?



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

5+ Year Member

Reposting my message here, as noone replied to it on PHP forum.....
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?



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

WebmasterWorld Senior Member 10+ Year Member

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.


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

WebmasterWorld Senior Member 10+ Year Member

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.


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

in browser:
- test.php = hello, there


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

5+ Year Member


Thanks guys. Really appreciate your replies



Featured Threads

Hot Threads This Week

Hot Threads This Month