Jump to content

Difference between PC development environment and hosting.


Go to solution Solved by requinix,

Recommended Posts

I have my main files in the root directory. I put my headers, css etc in a sub directory.  I'm using netbeans and all works well at home.

 

When I upload to crazydomains, any files required from the sub directory are not being loaded.

 include('\misc\mem_header.php')

I do have access to the directory because if I go to the web page XYZ.com/misc they are there and I can view them.

 

Does linux reference files differently to windows and if so, how do I fix this to work in both environments?   

 

 

  • Solution

Does linux reference files differently to windows

Ha. Ha ha. Hahahaha.

 

Yes. And that only scratches the surface of how files work differently between the two.

 

Always use forward slashes / for file paths. They work on Linux and Windows. Backslashes \ work on Windows but not on Linux. Backslashes are also special in PHP strings, and accidentally writing "path\to\folder" won't even work on Windows (though 'path\to\folder' will).

 

A leading slash has special meaning, too. Like how \misc on Windows means C:\misc (or whatever drive), /misc on Linux means the root of the filesystem. When locating files on your site, use the DOCUMENT_ROOT as a prefix. It's the path to the public root of your website.

include($_SERVER['DOCUMENT_ROOT'] . '/misc/mem_header.php');
On Windows you'll sometimes see filenames with \ and / mixed. As long as the backslashes are coming from PHP itself (like the DOCUMENT_ROOT) and not your own code that's okay and you don't need to worry about trying to fix it.
  • Like 2

This is exactly why a lot of people use vagrant/docker/vmware/virtualbox etc.

 

That way you can develop in a virtual environment that is close to if not identical to the one you're going to deploy to.

 

I wrote about how to setup a Centos server under windows back in 2009 here: http://www.gizmola.com/blog/archives/95-Run-a-Centos-Lamp-development-server-on-XP,-Vista-or-Win-7-using-VirtualBox.html

 

It touches upon a few things that are interesting, but I wouldn't do it this way today, given the advances in virtual box networking.

 

Here's a real simple prescription I found: https://github.com/saasbook/courseware/wiki/Setting-Up-Vagrant-Environment-on-Windows-Platform

 

My advice today would be to install vagrant & virtual box (vagrant uses virtual box). Microsoft also has https://www.microsoft.com/en-us/download/details.aspx?id=3702 which would be an alternative to virtual box. They are all free technologies, although I don't think that Vagrant supports Virtual PC.

 

At that point, you would remove all that WAMP crap from your workstation, and run everything self contained inside a VM, which you can start and stop when you need them.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.