00:00
00:00
Newgrounds Background Image Theme

YoungInfamous just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Php: Rapid Website Development

3,711 Views | 11 Replies
New Topic Respond to this Topic

Php: Rapid Website Development 2005-12-05 16:39:51


PHP:Main

Before you read on, note that this is not an actual PHP tutorial, but more of a "useful for PHP coding" tutorial.

I see a lot of people coding their site by saving the PHP page on their computer, then uploading it to their web space, and only then testing the page. This is a huge waste of time, and it requires people to either shut down their site, or make it all in a folder that if found will destroy all the project's secrecy. It also sometimes adds errors to pages while they're actually being used by other people.

If you are in this situation, and you're thinking that there must be an easier way to work on your site, rest assured! I've been developing my site for a while now, and I could never imagine going back to horribly slow save n upload.

This guide will teach you how to develop your website, just like if you were developing it online, except you'll be doing all that locally! Heck, you can even work on your website when you have lost Internet access! Using this technique, you can develop an entire system, and only once you're finished, upload it, and launch it in minutes! All you need to do is run a server on your computer, and there are a lot of tools that make this easier.

First, you should get easyPHP. It's the easiest way to get you started with an offline server. Once you've installed it, you need to go to Start>All Programs>EasyPHP>EasyPHP. Normally, the servers (both MySQL and Apache) will start automatically. If they don't, start Apache, then start MySQL. Once both servers are online, just minimize easyPHP, and go to http://localhost/ using any web browser. Ta-da! You should see the default easyPHP page. The files are in Program Files/EasyPHP1-8/www/

NOTE: The default mySQL username on easyPHP is 'root' and the password is just blank. Nothing. You can access phpMyAdmin by going on http://localhost/mysql/

Now, you might have some problems with the fact that you'll have to access your site with this ugly localhost address. This is the trick I'm most proud of, and it WILL be useful! What we want to do is assign a bogus domain to your localhost. For example, my domain name is www.locklegion.com, we want the domain www.locklegion.loc (.loc stands for local) to go directly to your PC. Don't worry, you don't have to purchase any other domain name! All operating systems have a great thing called a HOSTS file. It's a file that determines different IPs for certain domain names.

The HOSTS file, in Windows, is located in C:/Windows/system32/drivers/etc/HOSTS. Yes, the file is just called HOSTS, there is no extension to it. Open that file using Notepad. You'll see localhost is actually already "fake" domain name itself. All you have to do now to make your fake domain name to work, is add the two following lines at the end (replace yourdomain by your actual domain. For me it would be locklegion, for NG it'd be newgrounds, etc)
127.0.0.1 yourdomain.loc
127.0.0.1 www.yourdomain.loc
You have to add both www-prefixed and non-prefixed domains because HOSTS files don't support wildcards (it would be way too easy for malware to redirect any site to their own).

There you go! You can now access the local version of your site by going on www.yourdomain.loc!

NOTE: You and only on YOUR COMPUTER will be able to access the .loc domain name, don't think that it will magically create you a domain for free!

TIP: When you're developing your site, or upgrading things, I suggest you use an editor that can have multiple files open. Once you edit a file, keep it open, and keep all the files you edited open until you're done. Then you won't even have to remember which pages you edited, seeing as you have a list of all the opened files in your editor. This works well with people like me that have a bad memory.

I hope you enjoyed this tutorial, and I hope you'll be able to develop your site much faster, and more securely than before!


BBS Signature

Response to Php: Rapid Website Development 2005-12-05 16:55:34


Very useful tutorial.

I hope to see some more from you!

Response to Php: Rapid Website Development 2005-12-05 17:26:05


Wow, thats a really nice tute! And I agree, I hate the Save and upload way.

But.. i'm using a sub-domain, would it apply to this and still work?


"Actually, the server timed out trying to remove all your posts..."

-TomFulp

Response to Php: Rapid Website Development 2005-12-05 17:48:57


At 12/5/05 05:26 PM, IWantSomeCookies wrote: Wow, thats a really nice tute! And I agree, I hate the Save and upload way.

But.. i'm using a sub-domain, would it apply to this and still work?

I think you misunderstood davey's post. The .loc domain local comouter. it cannot be accessed from the web. The domain name you change in the HOST file, is just creating a mask for the 127.0.0.1 ip, which is the ip for your local computer. so if you created a domain mysite.loc, it would not be accessable from the internet. So why would you want a subdomain? Just make it your site name.loc.

Nice tutorial though. But I don't overly agree that it specificly goes with PHP main. It was more directed to local server stuff instead of php or using it.

Response to Php: Rapid Website Development 2005-12-05 17:57:55


At 12/5/05 05:48 PM, Dezmerkt wrote: So why would you want a subdomain? Just make it your site name.loc.

No, i'm saying i'm using a sub-domain, and you'll be using localhost, so i'm asking if I can get this for a sub-domain. :-/

*3,400th post. Yay for me*


"Actually, the server timed out trying to remove all your posts..."

-TomFulp

Response to Php: Rapid Website Development 2005-12-14 09:36:56


I'm using FoxServ for doing this, but still, nice tutorial =D


BBS Signature

Response to Php: Rapid Website Development 2005-12-14 13:03:24


you, my good man, are a PC God.
see, i didn't even know that info.

thumbs up!


[PHP: Main]-[AVGN Club]

"You know a dame is classy when she got some jiggle in her assy." - Unknown

BBS Signature

Response to Php: Rapid Website Development 2005-12-20 13:03:15


At 12/5/05 05:57 PM, IWantSomeCookies wrote: No, i'm saying i'm using a sub-domain, and you'll be using localhost, so i'm asking if I can get this for a sub-domain. :-/

Sorry for the late reply, but here's your answer: for each subdomain, you need to add a new entry to the HOSTS file. Saddly, as I said, there are no wild cards, so you won't be able to have dynamic subdomains (like ytmnd.com). It's still good enough for testing purposes. Here's what an entry would look like in your hosts file
127.0.0.1 sudomain.yourdomain.loc

At 12/19/05 04:50 PM, Ziaja wrote: Im having a problem (as usual) my EasyPHP servers are starting, but they stop because of an "unexpected and of MySql!"
Anyone with the same problem or knows the answer?

What version of Windows are you using? Did you check out the FAQ on www.easyphp.org ?

At 12/20/05 11:22 AM, Zendra wrote: Although I do have trouble setting up Apache on the laptop, maybe a good idea for your next tutorial? Or am I something missing now? :)

easyPHP comes with Apache, MySQL and PHP bundled.


BBS Signature

Response to Php: Rapid Website Development 2005-12-21 07:18:49


I cant find a "HOSTS" file you specified. I can go as far as C:\WINDOWS\SYSTEM32\DRIVERS\ but no further....do i just go ahead and create the folder 'ETC' and the 'HOST' file? Or is it somewhere else?
FYI, im using Win98

Response to Php: Rapid Website Development 2005-12-21 07:52:15


Search for the file HOSTS, either that or it will be C:\WINDOWS\HOSTS i thinkk (HOSTS located in C:\WINDOWS)

Response to Php: Rapid Website Development 2005-12-21 10:15:04


Ah yes, thank you, i found it:
C:\WINDOWS\HOSTS.SAM

Response to Php: Rapid Website Development 2007-01-19 17:59:18


I was messing with the changing domain part. I'm pretty sure many of you know that you can put domains like newgrounds.com, myspace.com, when you're offline. I made gag NG, and gag myspace, and it really fools my friends. I have to thank you for giving me new prank ideas (as I have a very low amount.)