468,525 Members | 2,200 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,525 developers. It's quick & easy.

Migrating to a new server: how to map one directory to another

JDS
Hi all. I don't know if this is possible, and if it is, whether it needs
to be done within Apache configuration or PHP configuration, but here goes:

I am migrating my web server to another machine. In fact, it is two
machines -- one for the web server itself, and one as a data server for
user home directories and MySQL.

The users' home dirs will be mounted on the web server as NFS mounts.

Now, the original, current, configuration has user home directories in
/home/*. There are a number of PHP scripts that refer to this directory
by an absolute path, for example, with lines like:

<? include("/home/webmaster/public_html/include/thing.inc"); ?>

However, the NFS mounted home directories are mounted on /webusers. This
is because I was reserving /home for actual local user directories.

Is there a way I can map calls to "/home" to "/webusers" without actually
changing all of the places that such absolute-path calls exist?

Note that a symbolic link from /home->/webusers wil not work because /home
is a real, existing, local directory.

System details:
old server: Red Hat Linux 9, Apache 1.3.x, PHP 4.3.x, MySQL 3.23.x

new server(s):
web: RHEL 4, Apache 2.0.x, PHP 4.3.x
data: RHEL 4, MySQL 4.1.x

I can post any more details as requested, of course.

Thanks!

--
JDS | je*****@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

Nov 4 '05 #1
10 1970
JDS wrote:
Hi all. I don't know if this is possible, and if it is, whether it needs
to be done within Apache configuration or PHP configuration, but here goes:

I am migrating my web server to another machine. In fact, it is two
machines -- one for the web server itself, and one as a data server for
user home directories and MySQL.

The users' home dirs will be mounted on the web server as NFS mounts.

Now, the original, current, configuration has user home directories in
/home/*. There are a number of PHP scripts that refer to this directory
by an absolute path, for example, with lines like:

<? include("/home/webmaster/public_html/include/thing.inc"); ?>

However, the NFS mounted home directories are mounted on /webusers. This
is because I was reserving /home for actual local user directories.

Is there a way I can map calls to "/home" to "/webusers" without actually
changing all of the places that such absolute-path calls exist?

Note that a symbolic link from /home->/webusers wil not work because /home
is a real, existing, local directory.


The fastest solution I can think of would be to make symlinks for all users
located in /webusers to /home, this way you would get around the problem of
all absolute paths without modifying anything.

eg: ln -s /webusers/webmaster /home

of course this will lead to problems if there are two users with the same
directory name.
Best solution would of course to fix those hard coded paths, you could run
something like:
perl -npe 's/\/home\//\/webusers\//g' -i *

on each public_html and the subdirectories (sure there are people good at
writing a small script that you could use).
//Aho
Nov 4 '05 #2
JDS
On Fri, 04 Nov 2005 18:26:06 +0100, J.O. Aho wrote:
The fastest solution I can think of would be to make symlinks for all users
located in /webusers to /home, this way you would get around the problem of
all absolute paths without modifying anything.

eg: ln -s /webusers/webmaster /home


Ah, of course. I'll try this for now.

something about this is not sitting quite right with me, though. Can;t
put my finger on it yet.

Thanks!

--
JDS | je*****@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

Nov 4 '05 #3
JDS wrote:
On Fri, 04 Nov 2005 18:26:06 +0100, J.O. Aho wrote:
The fastest solution I can think of would be to make symlinks for all users
located in /webusers to /home, this way you would get around the problem of
all absolute paths without modifying anything.

eg: ln -s /webusers/webmaster /home


Ah, of course. I'll try this for now.

something about this is not sitting quite right with me, though. Can;t
put my finger on it yet.


Could it be user john on the exported media and the user john on the importing
machine?
Nov 4 '05 #4
JDS wrote:
Hi all. I don't know if this is possible, and if it is, whether it needs
to be done within Apache configuration or PHP configuration, but here goes:

I am migrating my web server to another machine. In fact, it is two
machines -- one for the web server itself, and one as a data server for
user home directories and MySQL.

The users' home dirs will be mounted on the web server as NFS mounts.

Now, the original, current, configuration has user home directories in
/home/*. There are a number of PHP scripts that refer to this directory
by an absolute path, for example, with lines like:

<? include("/home/webmaster/public_html/include/thing.inc"); ?>

However, the NFS mounted home directories are mounted on /webusers. This
is because I was reserving /home for actual local user directories.

Is there a way I can map calls to "/home" to "/webusers" without actually
changing all of the places that such absolute-path calls exist?

Note that a symbolic link from /home->/webusers wil not work because /home
is a real, existing, local directory.

System details:
old server: Red Hat Linux 9, Apache 1.3.x, PHP 4.3.x, MySQL 3.23.x

new server(s):
web: RHEL 4, Apache 2.0.x, PHP 4.3.x
data: RHEL 4, MySQL 4.1.x

I can post any more details as requested, of course.

Thanks!


First of all, you should be using:

include ($_SERVER['DOCUMENT_ROOT']) . '/include/thing.inc');

Then if you change to another server or otherwise move your Apache
document_root you don't need to change all of your include statements.

As for the rest of the question, there's no way I can think of. And
Apache alias for the directory would not affect PHP include statements.

Since you can't create the symlink I think you're stuck with changing
all of your include statements.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 4 '05 #5
JDS
On Fri, 04 Nov 2005 14:40:45 -0500, Jerry Stuckle wrote:
First of all, you should be using:

include ($_SERVER['DOCUMENT_ROOT']) . '/include/thing.inc');

Then if you change to another server or otherwise move your Apache
document_root you don't need to change all of your include statements.

As for the rest of the question, there's no way I can think of. And
Apache alias for the directory would not affect PHP include statements.

Since you can't create the symlink I think you're stuck with changing
all of your include statements.


Thanks. "Should be" is not really possible because this machine has
scripts written over the past five years, by several different
individuals, with extremely loose enforcement of coding style. Too late
to change that.

Here is what I did:
* symlinks to each user in /webusers to /home (as suggested by Aho)
* am enforcing a policy whereby local users home directories are called
"/home/username-local" so that there is no name squashing going on by
mistake

shouldn't matter too much -- there are not going to be more than one or
two local user on the apache box anyways. user data is all on the data box.

Thanks for any and al help, o' Usenet denizens.

--
JDS | je*****@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

Nov 4 '05 #6
JDS wrote:
shouldn't matter too much -- there are not going to be more than one or
two local user on the apache box anyways. user data is all on the data box.


If there is only a couple of local users, then maybe it had been easier to do
the other way around, having the local users say in /users and mount the nfs
export to /home.

//Aho
Nov 4 '05 #7
JDS
On Sat, 05 Nov 2005 00:07:09 +0100, J.O. Aho wrote:
If there is only a couple of local users, then maybe it had been easier to do
the other way around, having the local users say in /users and mount the nfs
export to /home.


Yes, I had considered this.

Well, the thing ain't fully configured and certainly isn't live yet, so I
just may do this.

I wonder if there is a way to make "/whatever_directory" the default
home directory for users created with "useradd". I'll have to look into
this...

--
JDS | je*****@go.away.com
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

Nov 5 '05 #8
>> If there is only a couple of local users, then maybe it had been easier to do
the other way around, having the local users say in /users and mount the nfs
export to /home.


Yes, I had considered this.

Well, the thing ain't fully configured and certainly isn't live yet, so I
just may do this.

I wonder if there is a way to make "/whatever_directory" the default
home directory for users created with "useradd". I'll have to look into
this...


On at least some flavor of Linux, the -D option can be used to
change the defaults (permanently) for various things like home
directory, shell, and group. This information seems to be kept in
/etc/login.defs.

Gordon L. Burditt
Nov 5 '05 #9
JDS
On Sat, 05 Nov 2005 17:10:47 +0000, Gordon Burditt wrote:
On at least some flavor of Linux, the -D option can be used to
change the defaults (permanently) for various things like home
directory, shell, and group. This information seems to be kept in
/etc/login.defs.


Excellent. Thanks

--
JDS | je*****@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

Nov 7 '05 #10
JDS
On Fri, 04 Nov 2005 11:06:58 -0500, JDS wrote:
I am migrating my web server to another machine. In fact, it is two
machines -- one for the web server itself, and one as a data server for
user home directories and MySQL.

The users' home dirs will be mounted on the web server as NFS mounts.

In the interest of closure, I have done/am doing the following (tersely
stated):

mv /home /home-local

useradd -Db /home-local

results of `grep home /etc/fstab`:
data.server.edu:/home /home nfs defaults 1 2
later...

--
JDS | je*****@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

Nov 7 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Mike Towers | last post: by
3 posts views Thread by BobRoyAce | last post: by
2 posts views Thread by bh | last post: by
2 posts views Thread by Alex | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.