The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 18, 2019, 10:47:04 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Remote Sourcing Configs / Scripts  (Read 2831 times)
DangerMouse
Expert
****
Offline Offline

Posts: 244



View Profile
« on: November 24, 2011, 09:55:16 AM »

Hi guys,

I'm certain that this is well within the realms of experience of those here -I currently have a dedicated server with a couple of hundred domains hosted, managed via a Plesk control panel.

Security policy on the server means that each domain / site cannot access files outside of its own vhost, but I'd like to create a shared location for certain PHP scripts. Any ideas?

I guess its possible over a HTTP request if I can't do it any other way, but I'm ashamed to say I'm not sure how to execute a script thats come from file_get_contents() or similar.

Tips appreciated! As I said I'm certain plenty of distributed apps have been written here Smiley

DM
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: November 24, 2011, 10:47:40 AM »

Shared scripts or shared variables?

Shared scripts: ssh into the box. Make a directory that you will put shared stuff into. I use /www/sites/lib. Then in the directories where the site specific scripts are, symbolically link to them. (hard links are fine as well, but they are less obvious). So in /www/sites/lib you'd have a script called shareMe.php. In /www/sites/targetSite/scripts you'd type

ln -s /www/sites/lib/shareMe.php .

and you're good to go. Probably 70% of my scripts are used this way.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: November 24, 2011, 10:49:01 AM »

Btw don't use dynamic code with an eval and file_get_contents unless there is absolutely no other way to do it.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
DangerMouse
Expert
****
Offline Offline

Posts: 244



View Profile
« Reply #3 on: November 25, 2011, 06:53:55 AM »

Fair point on the dynamic code - I would prefer the sym link route too.

Just tested it out and it seems to be failing - but its failing silently so I can't figure out the problem - if permissions prevented a symlink from working would the server throw an error on creation via the CLI?

DM
Logged
DangerMouse
Expert
****
Offline Offline

Posts: 244



View Profile
« Reply #4 on: November 25, 2011, 07:04:21 AM »

Quick update - I've verified that the sym link works just by hitting vi at command line, but it still doesnt work through Apache?

This is looking like an Apache conf thing to me now?

DM
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #5 on: November 25, 2011, 05:22:35 PM »

You MAY need to add FollowSymLinks to your apache config, but more likely the underlying files don't have the right permissions for the Apache user (often www or nobody). Try setting the permissions to 777 and see how it goes. There's not reason why Apache can't read it really.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!