Welcome to WebmasterWorld Guest from 54.162.19.123

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)

New User

5+ Year Member

joined:Mar 17, 2009
posts: 27
votes: 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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 31, 2003
posts:1316
votes: 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.

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 20, 2004
posts:1477
votes: 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

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

New User

5+ Year Member

joined:Mar 17, 2009
posts:27
votes: 0


Hi

Thanks guys. Really appreciate your replies

Su

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members