freejoy — 2012-08-15T10:56:39-04:00 — #1
I've been developing a website on my localhost machine using Wamp server. Now I want to move the site to a non-local hosted machine.
I have a html test page on the non-local host. I can't access the page. I've tried to exit Wamp and still can't access the site test page.
On my local machine in the etc/host file I have my site.
How can I keep developing my site on my localhost machine and at the same time access the non-localhosted site?
kylewolfe — 2012-08-15T12:21:22-04:00 — #2
It sounds like you have a dns mapping issue? Make sure you remove any overwrite in your hosts file that has to do with your site address. http//localhost should take you right to your local dev site, and yourname.com should be taking you to the remote, production website.
I guess I am a little confused on where, your confusion is.
andygambles — 2012-08-15T12:32:46-04:00 — #3
I guess you configured your site on wamp as yourdomain.com
Change this to yourdomain.local so you know which is remote and which is local.
freejoy — 2012-08-15T12:55:28-04:00 — #4
Okay, let me explain better.
I can go to my site on my localhost machine like this: http://www.mysite.com
It's set up on my machine like that, not http://localhost (I read to set it up that way to make sure all the links created for the site would be transferable when going live.) If I go to http://localhost I'll go to my Wamp administration panel.
I thought I might have to remove the code out of my local "host" file i.e. C:\Windows\System32\drivers\etc\host.conf
Here's what I have in the host.conf file:
127.0.0.1 localhost mysite.local
In my Wamp Server set up I have this:
CustomLog "logs/access.log" common
Options Indexes FollowSymLinks
Allow from all
As you can see I'm set up to host the site on my localhost machine. I changed my mind about that!
But it helps making sure the links are correct in the site thou.
Now I want to upload the site to another non-localhost.
But I want to keep my set up here because it works so well and I know the links created will work. If I put mysite name into my browser it will take me to my localhost machine (I think because of my host file).
My problem seems to be how to go to my site on this "localhost" machine (when I want to) when I want to work on my site here and go to my non-localhost to set up everything else. I would like to switch between both. That would be ideal.
It looks to me like I'm going to have to remove to code out of my host.conf file, refresh windows memory, and maybe even do something about the Wamp VirtualHost conf file too.
I thought I could least access mysite with the ip number, but that's not working either. But even if I could access mysite through the ip address when ever I click a link it would automatically bring me back to my localhost machine.
Know what I mean?
kylewolfe — 2012-08-15T13:02:23-04:00 — #5
hosts file should only contain:
127.0.0.1 localhost mysite.local
You are literally pointing mysite.com to your own machine with the rest of the lines.
I believe after you fix that, the virtual host should be fine? If not change that to localhost as well
freejoy — 2012-08-15T13:08:16-04:00 — #6
Will that mess up my links?
So I would go to http://www.mysite.local on my localhost?
I can try it but I don't see how it would work.
kylewolfe — 2012-08-15T14:05:45-04:00 — #7
After removing your custom lines from your hosts file, you'd go to http://locahost for your local dev server. Your links should be formatted as "/home" and not "mysite.com/home" though, unless you have a variable set on them all that can be changed depending wether your in production or dev ex. $siteUrl & "/home";
technobear — 2012-08-15T14:26:39-04:00 — #8
Please turn off automatic parsing of URLs (via the "Go Advanced" button) or wrap [noparse] tags round them when you're giving examples. (Especially if you're going to use mysite.com as your example, because that's a real site.) It will save me tearing out my fur in frustration. Thank you.
freejoy — 2012-08-15T15:57:45-04:00 — #9
I have to remove all the code out of the host file then reboot the router then I can go online to my site.
It works but not as convenient as I would like.
Yes, I didn't realize about the links, sorry.
kylewolfe — 2012-08-15T16:04:36-04:00 — #10
You need to reboot your machine, not your router. All that is needed to take your site live is a mysqldump of the database (if you have one), and mirror to the remote site, and a simple copy and paste of your site directory to the remote site. There's other little tricks you'll think of as you dig in deeper.
freejoy — 2012-08-15T18:41:08-04:00 — #11
I'm not sure what you mean. I don't think I can because I have a dynamic IP. I have MySql installed and even Bind DNS. But my machine would probably be to slow. I have a Magento cart I've been working on for a few months (hard cart) but I like it. It's loaded and I need at least three databases.
What I would like to find is a free hosting company with everything I need to run my cart and that I can upgrade later for speed. I would like my profits to pay for everything. Something is the matter with every hosting company so far. I think I need a dedicated IP with free hosting and more than one database. You don't know everything about the hosting companies untill you sign up. Then you find out the something is wrong. I found a place to get a free SSL for accepting CC but I think I need a dedicated IP.
What do you mean "mirror the remote site?"
john_betong — 2012-08-16T01:38:32-04:00 — #12
Most of the problems I had when developing locally and then uploading was paths and passwords, etc. To prevent having separate files with the same name for localhost and online I came across this neat solution:
defined('LOCALHOST') ?: define('LOCALHOST', 'localhost' === $_SERVER['SERVER_NAME']);
if( LOCALHOST )
// Necessary to remove DRIVE letter
define('PATH_INDEX', substr(getcwd(),2)) .'/';
<!-- common links can be used on same file for both localhost and online -->
src = '<?php echo PATH_THUMBS;?>thumb-123.jpg'
style = 'width:88%; max-width:123px'
andygambles — 2012-08-16T02:27:36-04:00 — #13
As I suspected you have your remote site name set up locally.
Your options are use a local site name and use relative links (what we and the majority of developers do).
Or have two host files. One with your sites and one without. When you want remote access switch the files over (call one hosts_local and one hosts_remote. When you want to use it rename it to hosts.) then when you have the right host file in place run the following command in the run box
Personally the first option is much easier and what the rest of the planet does.