SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Addict
    Join Date
    Mar 2008
    Location
    Sterling, CO
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to access non-local site while using local Wamp server to develop the same site?

    Hi,

    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?

    Understand?

    Thanks

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,079
    Mentioned
    53 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    SitePoint Enthusiast AndyGambles's Avatar
    Join Date
    Jul 2006
    Location
    Scarborough, North Yorkshire, United Kingdom
    Posts
    45
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Addict
    Join Date
    Mar 2008
    Location
    Sterling, CO
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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:

    ::1 localhost
    127.0.0.1 localhost mysite.local
    127.0.0.1 mysite
    127.0.0.1 mysite.com
    127.0.0.1 www.mysite.com
    127.0.0.1 postmaster.mysite.com
    127.0.0.1 admin.mysite.com
    127.0.0.1 mail.mysite.com
    127.0.0.1 care.mysite.com
    127.0.0.1 webmaster.mysite.com

    In my Wamp Server set up I have this:

    <VirtualHost *:80>
    ServerAdmin admin@mymysite.com
    ServerName www.mymysite.com
    ServerAlias www.mymysite.com
    DocumentRoot C:/Windows/HOST/wamp/www/www.mymysite.com
    ErrorLog "logs/error.log"
    CustomLog "logs/access.log" common
    <Directory "C:/Windows/HOST/wamp/www/www.mymysite.com/">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order Allow,Deny
    Allow from all
    </Directory>
    </VirtualHost>


    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?

    Thanks
    Last edited by TechnoBear; Aug 15, 2012 at 10:04. Reason: Example URLs delinkified

  5. #5
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,079
    Mentioned
    53 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Freejoy View Post
    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:

    ::1 localhost
    127.0.0.1 localhost mysite.local
    127.0.0.1 mysite
    127.0.0.1 mysite.com
    127.0.0.1 www.mysite.com
    127.0.0.1 postmaster.mysite.com
    127.0.0.1 admin.mysite.com
    127.0.0.1 mail.mysite.com
    127.0.0.1 care.mysite.com
    127.0.0.1 webmaster.mysite.com

    In my Wamp Server set up I have this:

    <VirtualHost *:80>
    ServerAdmin admin@mymysite.com
    ServerName www.mymysite.com
    ServerAlias www.mymysite.com
    DocumentRoot C:/Windows/HOST/wamp/www/www.mymysite.com
    ErrorLog "logs/error.log"
    CustomLog "logs/access.log" common
    <Directory "C:/Windows/HOST/wamp/www/www.mymysite.com/">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order Allow,Deny
    Allow from all
    </Directory>
    </VirtualHost>


    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?

    Thanks
    hosts file should only contain:

    ::1 localhost
    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
    Last edited by TechnoBear; Aug 15, 2012 at 10:05. Reason: URLs in quote delinkified

  6. #6
    SitePoint Addict
    Join Date
    Mar 2008
    Location
    Sterling, CO
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AndyGambles View Post
    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.
    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.

    Thanks
    Last edited by TechnoBear; Aug 15, 2012 at 11:22. Reason: Example URL delinkified

  7. #7
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,079
    Mentioned
    53 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Freejoy View Post
    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.

    Thanks
    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";

  8. #8
    Life is not a malfunction gold trophysilver trophybronze trophy
    TechnoBear's Avatar
    Join Date
    Jun 2011
    Location
    Argyll, Scotland
    Posts
    5,342
    Mentioned
    214 Post(s)
    Tagged
    5 Thread(s)
    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.
    Don't be arrogant. Be kind to a koala that thinks it's a bear.

  9. #9
    SitePoint Addict
    Join Date
    Mar 2008
    Location
    Sterling, CO
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  10. #10
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,079
    Mentioned
    53 Post(s)
    Tagged
    0 Thread(s)
    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.

  11. #11
    SitePoint Addict
    Join Date
    Mar 2008
    Location
    Sterling, CO
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by K. Wolfe View Post
    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.
    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?"

  12. #12
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,578
    Mentioned
    62 Post(s)
    Tagged
    3 Thread(s)
    @FreeJoy

    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:

    PHP Code:

    <?php 

    defined
    ('LOCALHOST') ?: define('LOCALHOST''localhost' === $_SERVER['SERVER_NAME']);

    if( 
    LOCALHOST )
    {
    // Necessary to remove DRIVE letter
      
    define('PATH_INDEX'substr(getcwd(),2)) .'/';

      
    define('PATH_ASSETS''.assets/');
      
    define('PATH_IMAGES''/xamp-lite/xampp/htdocs/afiles/images/');
      
    define('PATH_THUMBS'"/subdomain/thumb/");
    }
    else
    {
      
    define('PATH_ASSETS',   '/home/content/77/123456/html/assets/');
      
    define('PATH_IMAGES',   '/home/content/77/123456/html/xy_john/afiles/images/');
      
    define('PATH_THUMBS',  '/home/content/77/123456/html/subdomain/thumb/');
    }

    ?>


    <!-- common links can be used on same file for both localhost and online -->
    <a href='/file-with-image-123.jpg'>
      <img
          src   = '<?php echo PATH_THUMBS;?>thumb-123.jpg' 
          style = 'width:88%; max-width:123px' 
          alt='#'
      />
    </a>

  13. #13
    SitePoint Enthusiast AndyGambles's Avatar
    Join Date
    Jul 2006
    Location
    Scarborough, North Yorkshire, United Kingdom
    Posts
    45
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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

    Ipconfig /flushdns

    Personally the first option is much easier and what the rest of the planet does.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •