Be a Supporter!

Php: Rapid Website Development

  • 2,333 Views
  • 17 Replies
New Topic Respond to this Topic
Sir-Davey
Sir-Davey
  • Member since: Jul. 9, 2001
  • Offline.
Forum Stats
Member
Level 19
Blank Slate
Php: Rapid Website Development 2005-12-05 16:39:51 Reply

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
DFox
DFox
  • Member since: Aug. 9, 2003
  • Offline.
Forum Stats
Member
Level 30
Blank Slate
Response to Php: Rapid Website Development 2005-12-05 16:55:34 Reply

Very useful tutorial.

I hope to see some more from you!


BBS Signature
IWantSomeCookies
IWantSomeCookies
  • Member since: Aug. 20, 2004
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Php: Rapid Website Development 2005-12-05 17:26:05 Reply

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

Craige
Craige
  • Member since: Jul. 17, 2004
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Php: Rapid Website Development 2005-12-05 17:48:57 Reply

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.

IWantSomeCookies
IWantSomeCookies
  • Member since: Aug. 20, 2004
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Php: Rapid Website Development 2005-12-05 17:57:55 Reply

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

Claxor
Claxor
  • Member since: Oct. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Php: Rapid Website Development 2005-12-14 09:36:56 Reply

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


BBS Signature
JimmyDallas
JimmyDallas
  • Member since: May. 17, 2003
  • Offline.
Forum Stats
Member
Level 31
Gamer
Response to Php: Rapid Website Development 2005-12-14 13:03:24 Reply

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
Ziaja
Ziaja
  • Member since: Oct. 2, 2005
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Php: Rapid Website Development 2005-12-19 15:11:22 Reply

To use this, would the computer its installed on NEED to be online or have an internet connection?

Ive got a computer now that isnt online and probably wont be, i want to install a localhost/local server and run php there.

Will it work?

sorry for the bump, i just didnt want to make a new topic.

Obnoxious2ombie.com - Online Drug Lord!

Taylor
Taylor
  • Member since: Aug. 19, 2003
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Php: Rapid Website Development 2005-12-19 16:02:53 Reply

No, it doesn't need a connection as long as you can get the server software onto the machine without the internet connection.

Ziaja
Ziaja
  • Member since: Oct. 2, 2005
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Php: Rapid Website Development 2005-12-19 16:35:36 Reply

At 12/19/05 04:02 PM, PillowBiter wrote: No, it doesn't need a connection as long as you can get the server software onto the machine without the internet connection.

Ok thanks, im one step closer to getting this to work for me.


Obnoxious2ombie.com - Online Drug Lord!

Ziaja
Ziaja
  • Member since: Oct. 2, 2005
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Php: Rapid Website Development 2005-12-19 16:50:52 Reply

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?


Obnoxious2ombie.com - Online Drug Lord!

Zendra
Zendra
  • Member since: Sep. 7, 2003
  • Offline.
Forum Stats
Moderator
Level 51
Blank Slate
Response to Php: Rapid Website Development 2005-12-20 11:22:43 Reply

Very good detailed tutorial which is helpful, because I have this crappy laptop where I code things first on, before putting them on my other computer which is connected to the Internet. Most of the times I still have some little errors - which can indeed be annoying.

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? :)

Sir-Davey
Sir-Davey
  • Member since: Jul. 9, 2001
  • Offline.
Forum Stats
Member
Level 19
Blank Slate
Response to Php: Rapid Website Development 2005-12-20 13:03:15 Reply

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
Ziaja
Ziaja
  • Member since: Oct. 2, 2005
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Php: Rapid Website Development 2005-12-20 19:23:40 Reply

Ive found something similar to easyPHP called xampp which works sweet for me.


Obnoxious2ombie.com - Online Drug Lord!

RWS
RWS
  • Member since: Mar. 11, 2005
  • Offline.
Forum Stats
Member
Level 23
Blank Slate
Response to Php: Rapid Website Development 2005-12-21 07:18:49 Reply

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

EviLDoG
EviLDoG
  • Member since: Oct. 18, 2000
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Php: Rapid Website Development 2005-12-21 07:52:15 Reply

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

RWS
RWS
  • Member since: Mar. 11, 2005
  • Offline.
Forum Stats
Member
Level 23
Blank Slate
Response to Php: Rapid Website Development 2005-12-21 10:15:04 Reply

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

WarSyndicate
WarSyndicate
  • Member since: Aug. 25, 2005
  • Offline.
Forum Stats
Member
Level 11
Animator
Response to Php: Rapid Website Development 2007-01-19 17:59:18 Reply

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.)