Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Multiple sites on same db

Options
  • 06-04-2007 12:30pm
    #1
    Closed Accounts Posts: 975 ✭✭✭


    Hi all.

    I am developing a number of distinct websites which will provide different views on the same DB. All sites reside on the same VPS, and the only difference in the code is a header file containing a variable with a value representing the specific view of the database to present, and different graphics. The scripts read this variable and use it in the SELECT .. WHERE .. .to filter the views.

    It is inevitable that I will be changing the scripts as time goes on - this means FTPing the changed script(s) to each site each time. Log in to domain ftp, upload files, logout, repeat. Can I utilise the fact that the scripts all reside on the same server to get all the domains to use their own header file but "communal" scripts - i.e. one copy living on the server, accessed by all domains? Think I played with apache config before to allow access to docs outside the domain structure's doc root. Maybe thats the answer?


Comments

  • Registered Users Posts: 3,594 ✭✭✭forbairt


    if all your sites are running on ...

    /var/www/www.site1.com
    /var/www/www.site2.com
    ....
    ...
    and so on ...

    you should be able to just have a file within site1 include a file outside of its web root ...

    in php for example

    <?PHP include_once "/var/www/sharedScripts/bob.php"; ?>

    bob.php isn't accessabled directly from a browser .... ever because apache isn't publishing sharedScripts ..


    that any help to you or similar to what you're after ?


  • Closed Accounts Posts: 975 ✭✭✭squibs


    I just tried this - an echo statement, an include with an echo statement and an echo statement. As I feared, I see the output from the first and last echo statement only. Looks like my apache is configured to stop access outside the root, for security I assume.


  • Registered Users Posts: 3,594 ✭✭✭forbairt


    the user apache is running under has access to read from that folder ?


  • Closed Accounts Posts: 975 ✭✭✭squibs


    I chown'd the directory to 'apache' (used a ps aux | grep http to find out apache user was 'apache'). Still nothing doing.


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    did you try using the HTTP_HOST?

    [php]
    if(stristr($_SERVER, 'domain_name')) {
    echo "some header";
    }else{
    echo "the other header";
    }
    [/php]


  • Advertisement
  • Closed Accounts Posts: 975 ✭✭✭squibs


    Hi Louie

    I don't understand how that would help me access a document outside of DoumentRoot.


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    squibs wrote:
    and the only difference in the code is a header file containing a variable with a value representing the specific view of the database to present, and different graphics. The scripts read this variable and use it in the SELECT .. WHERE .. .to filter the views.
    I didn't think you are looking to access files outside root folder.

    What about using curl function?


  • Closed Accounts Posts: 975 ✭✭✭squibs


    Hi louie, curl is an option alright, but I'm guessing hugely inefficient compared to an include. Thanks for the idea, but I'm still hoping for another solution.


  • Registered Users Posts: 3,594 ✭✭✭forbairt


    Bit lost as to what the problem is to be honest ... kinda thing I'd play with and see what works .. hmm...

    can you edit you php.ini and add in the following ... ?
    include_path = ".:/var/www/sharedFolder"

    You can include files within the current folder from your scripts ?

    (just narrowing down possibilities)


  • Closed Accounts Posts: 975 ✭✭✭squibs


    Again, I'm a bit lost myself :)

    I can include files anywhere within the directory structure from the docroot down, but not above, which is the way apache is configured for security.

    I never mess with apache configs - never had to before. I will try the include_path suggestion to see if that gives me access. Another idea I have on the go is to use symbolic links as a path outside the docroot.

    Cheers for the ideas.


  • Advertisement
  • Registered Users Posts: 3,594 ✭✭✭forbairt


    Had a look online and came across this ...
    safe_mode_include_dir string

    UID/GID checks are bypassed when including files from this directory and its subdirectories (directory must also be in include_path or full path must including).

    As of PHP 4.2.0, this directive can take a colon (semi-colon on Windows) separated path in a fashion similar to the include_path directive, rather than just a single directory.

    The restriction specified is actually a prefix, not a directory name. This means that "safe_mode_include_dir = /dir/incl" also allows access to "/dir/include" and "/dir/incls" if they exist. When you want to restrict access to only the specified directory, end with a slash. For example: "safe_mode_include_dir = /dir/incl/"


  • Closed Accounts Posts: 975 ✭✭✭squibs


    Sweet. Thanks.

    One of these ideas will have to work. I'll have fun trying them all tomorrow.


  • Closed Accounts Posts: 975 ✭✭✭squibs


    So I used an Alias statment in http.conf (well actually the httpd.include file for the domain I am working on) and now I can serve html files from the shared folder but for php files I'm being asked it I want to view or open the file.

    The unix include path was commented out. I uncommented it and added my shared folder to the end

    include_path = ".:/php/includes:/var/www/vhosts/sharedscripts"

    The safe_mode_include_dir was blank - I made it
    safe_mode_include_dir = "/var/www/vhosts/sharedscripts"

    I restarted apache, but I'm still get the open/save dialog box, and my includes arent't working either. I reckon the solution is really close now.


  • Closed Accounts Posts: 975 ✭✭✭squibs


    This has to be a php.ini problem, right? The site is serving php correctly from the normal locations, and is serving html from the alias directory. I've put the alias directory in the include_path and safe_mode_include_dir as suggested, but the webserver asks me if I want to save or open php files from the alias directory. open_basedir is not set.

    Does anybody have any ideas?


Advertisement