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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JDS

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

    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 | jeffrey@example .invalid
    | http://www.newtnotes.com
    DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

  • J.O. Aho

    #2
    Re: Migrating to a new server: how to map one directory to another

    JDS wrote:[color=blue]
    > 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.[/color]

    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

    Comment

    • JDS

      #3
      Re: Migrating to a new server: how to map one directory to another

      On Fri, 04 Nov 2005 18:26:06 +0100, J.O. Aho wrote:
      [color=blue]
      > 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[/color]

      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 | jeffrey@example .invalid
      | http://www.newtnotes.com
      DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

      Comment

      • J.O. Aho

        #4
        Re: Migrating to a new server: how to map one directory to another

        JDS wrote:[color=blue]
        > On Fri, 04 Nov 2005 18:26:06 +0100, J.O. Aho wrote:
        >[color=green]
        >> 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[/color]
        >
        > 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.[/color]

        Could it be user john on the exported media and the user john on the importing
        machine?

        Comment

        • Jerry Stuckle

          #5
          Re: Migrating to a new server: how to map one directory to another

          JDS wrote:[color=blue]
          > 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!
          >[/color]

          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.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • JDS

            #6
            Re: Migrating to a new server: how to map one directory to another

            On Fri, 04 Nov 2005 14:40:45 -0500, Jerry Stuckle wrote:
            [color=blue]
            > 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.[/color]

            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 | jeffrey@example .invalid
            | http://www.newtnotes.com
            DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

            Comment

            • J.O. Aho

              #7
              Re: Migrating to a new server: how to map one directory to another

              JDS wrote:
              [color=blue]
              > 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.[/color]

              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

              Comment

              • JDS

                #8
                Re: Migrating to a new server: how to map one directory to another

                On Sat, 05 Nov 2005 00:07:09 +0100, J.O. Aho wrote:
                [color=blue]
                > 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.[/color]

                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_direct ory" the default
                home directory for users created with "useradd". I'll have to look into
                this...

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

                Comment

                • Gordon Burditt

                  #9
                  Re: Migrating to a new server: how to map one directory to another

                  >> If there is only a couple of local users, then maybe it had been easier to do[color=blue][color=green]
                  >> the other way around, having the local users say in /users and mount the nfs
                  >> export to /home.[/color]
                  >
                  >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_direct ory" the default
                  >home directory for users created with "useradd". I'll have to look into
                  >this...[/color]

                  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

                  Comment

                  • JDS

                    #10
                    Re: Migrating to a new server: how to map one directory to another

                    On Sat, 05 Nov 2005 17:10:47 +0000, Gordon Burditt wrote:
                    [color=blue]
                    > 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.[/color]

                    Excellent. Thanks

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

                    Comment

                    • JDS

                      #11
                      Re: Migrating to a new server: how to map one directory to another

                      On Fri, 04 Nov 2005 11:06:58 -0500, JDS wrote:
                      [color=blue]
                      > 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.[/color]


                      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 | jeffrey@example .invalid
                      | http://www.newtnotes.com
                      DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

                      Comment

                      Working...