Question regarding website on local server

Brendans

Member
Joined
Nov 25, 2009
Messages
15
Hi guys

Im pretty new to web development, and need help with something.
I need to change some things on a site that is currently online. Its a company that i need to do something for.
So i want to save that site onto my pc and put it on my local host using xampp, so i can make the changes before sending the new code off.
The problem is I have no idea how to do this, could someone please tell me!
Oh, and there is a google map on the site aswell that i need to still work once ive put it on my local host, is this possible?

Thank you
 

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Yes it's possible.

Listen to uncle Acid ;)

1) Fire up FileZilla FTP and download all the site files
2) Make a backup of the MySQL database and restore it to your MySQL instance on your local PC (I usually use the same username/password they're using for the database, you'll find this in some config file if you don't know what it is). I also keep the name the same
2.5) Copy the files to the directory where your web server will host them, setup the vhosts file to react on www.whateverdomainthisis.co.za
3) Open up your hosts file: c:\windows\system32\drivers\etc\hosts (it's a file without an extension and you have to tell your PC to open it up with notepad)
4) It's a tab delimited file, so what you're going to do is type in an IP addres (which would be 127.0.0.1) press tab and type in www.whatevertheirdomainis.co.za

What the hosts file does on your PC is to override any DNS request your PC will make to find the IP address, because for every website you visit, it needs to find the corresponding IP, and it does so through DNS lookups (to the DNS Servers). By specificing a specific IP address/url combination in the hosts file, you override that and return your own version of the IP address, which would be your localhost (127.0.0.1 = home, your local PC)

This would then be picked up by your own XAMPP installation. So to you, for all intensive purposes, www.whateverthedomainis.co.za is "live", but it's opened as a local copy on your own machine that you could use and change before actually making the changes live to the real live server. Because of THAT, Google Maps would also work fine as the GUID for the API is usually setup for a specific domain name.

That way, whatever you develop is specific to the website and you'll know whatever you did will work because it's "AS IF" it's on the server. This is how I make sure many of the mistakes I tend to make is ironed out before going live, and in the end I only have to solve a couple of problems (if at all) in case the server config is wildly different to that of a default installation.

Good luck
 

modenworldweb.com

New Member
Joined
Apr 5, 2010
Messages
5
Here are simple steps:

1. Download the original files via FTP - you will need the hosting login details.
2. Work on the site.
3. To get a google map embeded you will have to create a local business listing with google and once you entre the address and details, google will create a map for you and when you are vewing it there will be an 'embed link' somewhere on the map and you can copy the code and paste in into your html file. For more information on this google: 'google local business listing'
4. To host the website with your new host you will first need to get the nameservers and hosting IP address of your hosting company and send them to the domain registrar for changing. This change can take up to 48hours.
5. Once all that is done (or you can do this point before 4.) login to your new hosting acc via FTP or whatever program you're using and upload the new files.

All the best :)
 

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Here are simple steps:

1. Download the original files via FTP - you will need the hosting login details.
2. Work on the site.
3. To get a google map embeded you will have to create a local business listing with google and once you entre the address and details, google will create a map for you and when you are vewing it there will be an 'embed link' somewhere on the map and you can copy the code and paste in into your html file. For more information on this google: 'google local business listing'
4. To host the website with your new host you will first need to get the nameservers and hosting IP address of your hosting company and send them to the domain registrar for changing. This change can take up to 48hours.
5. Once all that is done (or you can do this point before 4.) login to your new hosting acc via FTP or whatever program you're using and upload the new files.

All the best :)

How would he work & test on the site when it's Server-Side PHP code? (which was his initial question)
The site is currently live, which means current hosting won't change; Even if it did, a simple change to the DNS server will point it to the new hosting immediately while you wait for the DNS server move to take place (if you're dumb enough to actually go with the DNS server which your host supplies, I'd recommend a 3rd party)

Other than that, the Google Map might be a valid point I might have overlooked, I only know that you need to sign up with Google to get a developer API code to be able to use Google Maps on your website, might have changed since I last did it a few months ago though.

I'll re-iterate, listen to Uncle Acid
 

Drake2007

Expert Member
Joined
Oct 23, 2008
Messages
4,413
what they^ said +

If the domain name of the website stays the same then there's no need to change any javascript code to use Google maps.
The only registration you may need is to develope that code locally as it would be localhost or the IP address whatever your setup is. (this may have changed)

Best bet is don't mess with the code if it was javascripted and if it's working, it's quite difficult to debug.
Your site/page that uses Google maps needs to be:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Check out the maps api tutorials and docs.

You may also need to export the database from the website or things will just look ugly when you're developing.

Your first port of call I suggest you install Total Commander, best piece of software out there for FTP.
 
Last edited:

DarkStreet

Expert Member
Joined
Jan 18, 2007
Messages
1,284
I only know that you need to sign up with Google to get a developer API code to be able to use Google Maps on your website, might have changed since I last did it a few months ago though.

Nope, still the same. There is absolutely no need to register a business. Get the API key and implement the map. If you are using the same domain to test (as Acid pointed out) or you use localhost/127.0.0.1 then there is no need to temporarily change the API key.

Also - no need to go through the whole hosts file thing either unless it's really necessary. If the website was developed by somebody who has any kind of intelligence, it should work just as well on localhost with minimal configuration.
 

server-admins.net

Server-Admins representative
Company Rep
Joined
Oct 2, 2008
Messages
349
@ AcidRazor - this thread needs a "thanks" button for your excellent post here. Nice to see people willing to help without being cocky for already knowing something.

Well done mate. One virtual thank you for you.
 

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Also - no need to go through the whole hosts file thing either unless it's really necessary. If the website was developed by somebody who has any kind of intelligence, it should work just as well on localhost with minimal configuration.

I tend to agree, but taking over another project usually requires you to emulate the environment 100% (aka, having the host name as is, which requires the hosts file to be edited)

Any programmer worth his/her salt WOULD know not to "hardcode" for localhost etc, but many don't and it's usually those you have to take over from. It literally took me a few days just to get **** up and running to make a 5 min change on a dev machine & then make live. So this method is out of experience. And I have adopted it when I start any project from scratch as well (especially for .NET) which leads to less headaches when deploying than you might think :)

@ AcidRazor - this thread needs a "thanks" button for your excellent post here. Nice to see people willing to help without being cocky for already knowing something.

Well done mate. One virtual thank you for you.

Thanks man, if you'd like to donate I'll pm you my paypal addy :D
 

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Schweet, will pm you in the morning going to bed now can't keep my eyes open. Don't really need the hosting but would love to have a different environment I can run **** on to experiment with :)
 

server-admins.net

Server-Admins representative
Company Rep
Joined
Oct 2, 2008
Messages
349
Schweet, will pm you in the morning going to bed now can't keep my eyes open. Don't really need the hosting but would love to have a different environment I can run **** on to experiment with :)

PM received and responded, enjoy the hosting bud
 

murraybiscuit

Executive Member
Joined
Oct 10, 2008
Messages
6,483
Nope, still the same. There is absolutely no need to register a business. Get the API key and implement the map. If you are using the same domain to test (as Acid pointed out) or you use localhost/127.0.0.1 then there is no need to temporarily change the API key.

Also - no need to go through the whole hosts file thing either unless it's really necessary. If the website was developed by somebody who has any kind of intelligence, it should work just as well on localhost with minimal configuration.

the problem is that in some cases you may need to use absolute links (especially if it's not your own code)
url aliases don't help when you're working off /localhost/mysite/images and it's looking for the files on /images

i normally just make my hosts and vhosts hardlink to dev.domain.tld
that way there's no confusion as to which site i'm previewing in my browser and i can preview live and dev simultaneously.
i also have a config file which detects if the system is live, test or local depending on the url.
this changes the db host address, disables analytics, and sets up the global admin, no-reply and webmaster email addresses.

this means that i can move all of the files between servers without having to recode any server-specific variables.
this setup should give you no problems with the google api, because if you register with the root domain, any subdomain will work, as per the maps api signup page:
Tip: Signing up a key for http://yourdomain.com is usually the best practice, as it will work for all subdomains and directories

the only issue with the above is if there's a hardlink with the domain name in it.
all i can say is that if you've got that problem, it's probably not your biggest issue :)
 
Top