Hi all:

I recently completed rewriting my site from ASP to PHP. I am now starting the process of migrating to Linux from Windows. I am a total newbie with Linux! Urghhh!

OK, on windows I was fine using $SERVER['DOCUMENT_ROOT'] for my requires. But now on the Linus server $SERVER['DOCUMENT_ROOT'] = /usr/local/apache/htdocs. When I asked my host about moving my files under this path they said you can but I would need to use an IP address and no my domain name to bring up the website. So that isn't a solution.

The path to my files is /home/signings/public_html/.

Something just doesn't seem right. $_SERVER['DOCUMENT_ROOT'] is the accepted way to preface a require (worked for me on Windows) but now on Linus this is a different path.

BTW, I am using cPanel as well. I am totally new to that too.

Any help appreciated.

    For one, "Linus" is a 42-year-old man, so I doubt you're using him as a server. However, you might be using an operating system named after him, namely Linux. 😉

    For another, the difference has nothing to do with the way Linux works as opposed to Windows. Instead, this is a matter of how the webserver was configured. As such, I would take the matter up with your host again - either they fix their config (even the crappiest of cheap or even free shared hosts know how to properly configure a web daemon and PHP - why can't yours?) or you should search for a competent host.

      Agree about Linus, but he's got to be older than 42!

      So should my web files be under /usr/local/apache/htdocs as that is currently my document root?

      Or should they be under /home/signings/public_html as they are now?

      If the former, my host said only my IP address would work to get to my site.

      BTW, this is using a well respected Linux host.

        Square1;10994596 wrote:

        So should my web files be under /usr/local/apache/htdocs as that is currently my document root?

        Do you have root access to the server?

        Square1;10994596 wrote:

        If the former, my host said only my IP address would work to get to my site.

        Nonsense; as long as Apache is configured to use the above directory as the default website, you have no VirtualHost configurations that tell it to look elsewhere for your domain, and your domain name resolves to the server's IP address, then there's no difference in the two locations (or any other location on the file system for that matter).

          Yes I do have root access.

          I am passing this thread to my host. This is a fully managed server.

            Square1;10994596 wrote:

            BTW, this is using a well respected Linux host.

            not sure what to make of that, if they can't even properly configure their server environment vars or change your site root location...

            whatever path they decide to make your site root is fine - doesn't really matter. They should then be able to configure the server so both DOCUMENT_ROOT and your domain name point to that location. it's a very basic task.

              traq;10994607 wrote:

              it's a very basic task.

              Agreed; so simple, in fact, that I personally wouldn't bother waiting for the host to get back to me and instead simply do it myself. It's probably just a matter of setting the DocumentRoot directive properly in Apache's configuration.

                This is why I don't bother relying on server settings for document paths. Instead the top of my index.php (landing page) looks like:

                <?php define('DOC_ROOT',dirname(__FILE__) . DIRECTORY_SEPARATOR);

                And my controllers, models, whateva start like:

                <?php if( !defined('DOC_ROOT') ) die('NO DIRECT ACCESS ALLOWED');

                Then instead of using $_SERVER['DOCUMENT_ROOT'] I just use DOC_ROOT (much less typing then too!)

                  exactly what I do (except I use even shorter constant names, [font=monospace]R[/font] in this case). However, I would still expect $SERVER['DOCUMENT_ROOT'] to work correctly (or at least, be corrected); regardless of what host I had.

                  I once told a client to get a new host or I wouldn't finish the project - the admins wouldn't allow PHP's filesystem functions because their email server was on the same machine, and they "wouldn't be able to keep it secure that way."

                    That is definitely an Apache configuration issue!

                      The problem was happening before I set the nameserver to the domain. After I set the nameserver the problem disappeared.

                        Write a Reply...