Go Back   GotGames.com.au > GotGames Off Topic Discussion > Programming

Reply
 
LinkBack Thread Tools
Old 29-06-2007   #1 (permalink)
chX
GotGames Moderator
 
chX's Avatar
 
Join Date: Jan 2007
Location: Adelaide
Age: 17
Posts: 3,760
Rep Power: 5
Send a message via MSN to chX
Default Installing and configuring your very own Web Server - By Chaos.

Installing a Web Server on YOUR OWN PC with PHP/MySQL!

Since I'm making tutorials on PHP, I thought it would be good to teach people how to create their own server to test and use PHP scripts. It's really not that hard to configure and run if you follow a few steps.

We will be using Apache 2.0.59 web server (AFAIK it is more stable with PHP than the newest release), PHP5 and MySQL 5.

Installing Apache 2.0.59

First, go to this website and download the installer:

http://httpd.apache.org/download.cgi

You'll want to choose Apache HTTP Server 2.0.59, the Win32 Source version (assuming you are using Windows... however this guide doesn't cover installing PHP/MySQL on Unix or other Operating Systems.)

Let it download, then install it.

While installing, you will be given options such as Network Domain, Server Name and Administrator's Email. Use these:

Code:
Network Domain
localhost

Server Name
localhost

Administrator's Email Address
Doesn't really matter
Fill in the information and finish the installer. It should install and come up with a little menu called Service Monitor saying that Apache is running or something similar.

Open a browser and in the URL bar type "localhost." It should take you to a Start Screen, which says "If you can see this, it means the installation blah blah blah." If you do see that, then it did install and you're doing well. Now we need to install PHP5.

PHP5

Navigate to this page:

http://www.php.net/downloads.php

There are two options:
We can download the PHP installer, which does everything for you; or we can download the ZIP file and configure it manually.

Configuring it manually is the best bet, it allows for more flexibility and more security. Download the PHP 5.2.3 zip package which is under Windows Binaries.

After you have downloaded the file, create a folder (in an easy to reach place) called php. Extract all of the files into this folder. There will be quite a few files, but don't fret... we'll go through what you need to do slowly.

For PHP to work with Apache, we need to make some of the .dll files available to the Windows Path Environment. Basically, all you need to do is copy the files
(which are located in the folder you just created):

* php5apache2.dll
* php5ts.dll
And possibly
* php5apache.dll

You then need to navigate to drive Windows is installed on, in this case we'll say drive C.

Navigate to C:\WINDOWS\system32 and paste those three files in there. That's it for that part. Now we need to configure some files.

Go to the folder where you installed PHP... there should be a file which is called something similar to "php.ini-recommended." Rename this file to php.ini and open it up in notepad.

Push Ctrl + F to bring up the search menu in notepad, and type in "doc_root." Push enter twice and it should move to the part of the file with doc_root in it.

Basically, you want it to say:

doc_root = C:\Program Files\Apache Group\Apache2\htdocs\

(Assuming you installed the Apache server on drive C in Program Files.)

Also do a search and go to where it says "extension_dir." You want this to be set to where you installed your PHP folder and the folder "ext."
Once again assuming we unzipped the PHP files to C:\php, we would set it as:

extension_dir = "C:\php\ext\"

Make sure you have changed both of those things, then save php.ini and exit it, we shouldn't need to open it again.


Now we have both PHP and Apache working, but we need them working together.

Configuring PHP to work with Apache

Alright, we're almost done installing PHP! Navigate to the folder where you installed Apache, it would be something like
C:\Program Files\Apache Group\Apache2\. Open the conf folder, and open the file called httpd.conf in notepad.

First of all, we need the server to recognise index.php as a valid page and thus load it. Find the text "DirectoryIndex" and it should have index.html index.html.var following it. Add index.php to this list. We need to do one more thing in this file.

We have 2 ways of getting PHP running with Apache: CGI binary or a module itself. It's a lot faster to choose the second option so that's how we'll do it.

Scroll right to the bottom of the file, and push enter to go down a few lines. Then paste this:

Code:
LoadModule php5_module "C:\php\php5apache2.dll"
AddType application/x-httpd-php .php

PHPIniDir "C:\php\"
Once again that is assuming you unzipped the files to C:\php.

We are now basically finished installing PHP and configuring it with Apache. Now to test that it all works.

In the Apache folder, go to the folder called htdocs. Create a new text file and open it. In this text file, paste this:

PHP Code:
<?PHP
phpinfo
();
?>
Save it as phpinfo.php and remember to choose "all files." Then load up a browser and go to localhost/phpinfo.php.

If you see a page with a lot of blue, grey and purple boxes... then congrats... you installed PHP and got it working! If not, go back and try again or PM me.

All that we have left to do is install MySQL, but since most of you have headaches by now... we can leave that till another day.


I hope you enjoyed the tutorial, and as always... feel free to post comments etc.

- Chaos
chX is offline   Reply With Quote
Old 29-06-2007   #2 (permalink)
Senior Member
 
Join Date: Mar 2007
Location: Batemans Bay
Posts: 777
Rep Power: 0
Default

Nice tutorial Choas , maybe oneday i will try and figure this out.

+rep
dreaMz is offline   Reply With Quote
Old 30-06-2007   #3 (permalink)
chX
GotGames Moderator
 
chX's Avatar
 
Join Date: Jan 2007
Location: Adelaide
Age: 17
Posts: 3,760
Rep Power: 5
Send a message via MSN to chX
Default

Haha. I wrote the tutorial as I installed it all for myself (reformatted the other day, so I did it tonight.) I just wonder if it actually works for anyone else who tries it.

It'd be awesome if people could actually try it out and see if works... then I can move on to MySQL which to be honest is quite annoying.
chX is offline   Reply With Quote
Old 30-06-2007   #4 (permalink)
Contributing Member
 
Join Date: Apr 2007
Location: Central Coast, NSW
Age: 20
Posts: 501
Rep Power: 2
Send a message via MSN to banzai
Default

I've installed apache/mysql/php on my windows home computer many times, for web dev purposes.
It's not that hard, the only pain is getting php to work with mysql, which was abit unsupported last time i installed it.
__________________
banzai is offline   Reply With Quote
Old 30-06-2007   #5 (permalink)
chX
GotGames Moderator
 
chX's Avatar
 
Join Date: Jan 2007
Location: Adelaide
Age: 17
Posts: 3,760
Rep Power: 5
Send a message via MSN to chX
Default

Quote:
Originally Posted by banzai View Post
I've installed apache/mysql/php on my windows home computer many times, for web dev purposes.
It's not that hard, the only pain is getting php to work with mysql, which was abit unsupported last time i installed it.
Yeah PHP5 no longer automatically supports MySQL, so you have to manually move the files and edit the config file for it all. Other than that it's pretty damn easy.
chX is offline   Reply With Quote
Old 30-06-2007   #6 (permalink)
Junior Member
 
Join Date: Jan 2007
Posts: 97
Rep Power: 2
Default

nice tute i haven't tested yet but will in the next week or so +1
adz45 is offline   Reply With Quote
Old 30-06-2007   #7 (permalink)
chX
GotGames Moderator
 
chX's Avatar
 
Join Date: Jan 2007
Location: Adelaide
Age: 17
Posts: 3,760
Rep Power: 5
Send a message via MSN to chX
Default

Quote:
Originally Posted by adz45 View Post
nice tute i haven't tested yet but will in the next week or so +1
Thanks. I'll probably add the section on MySQL pretty soon too.
chX is offline   Reply With Quote
Old 30-06-2007   #8 (permalink)
Contributing Member
 
philipjfry's Avatar
 
Join Date: Jan 2007
Posts: 585
Rep Power: 2
Default

....
__________________
philipjfry is offline   Reply With Quote
Old 01-07-2007   #9 (permalink)
chX
GotGames Moderator
 
chX's Avatar
 
Join Date: Jan 2007
Location: Adelaide
Age: 17
Posts: 3,760
Rep Power: 5
Send a message via MSN to chX
Default

.... indeed.
chX is offline   Reply With Quote
Old 01-07-2007   #10 (permalink)
Contributing Member
 
Join Date: Jun 2006
Posts: 607
Rep Power: 3
Default

Installing PHP5/Apache2 on Ubuntu is even easier.

Somthing along the lines of

apt-get install apache2
apt-get install libapache2-mod-php5

and hey, you wanted some extensions with that?

apt-get install php5-mysql php5-curl php5-gd ... etc

Ofc you could compile your own, thats not hard either.
__________________
92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature.
Khaless is offline   Reply With Quote
Old 04-07-2007   #11 (permalink)
chX
GotGames Moderator
 
chX's Avatar
 
Join Date: Jan 2007
Location: Adelaide
Age: 17
Posts: 3,760
Rep Power: 5
Send a message via MSN to chX
Default

Quote:
Originally Posted by Khaless View Post
Installing PHP5/Apache2 on Ubuntu is even easier.

Somthing along the lines of

apt-get install apache2
apt-get install libapache2-mod-php5

and hey, you wanted some extensions with that?

apt-get install php5-mysql php5-curl php5-gd ... etc

Ofc you could compile your own, thats not hard either.
Yeah. I wanted to do a guide for windows, because anyone who is already using
an operating system other than windows would most likely know how to do it on their own.
chX is offline   Reply With Quote
Old 04-07-2007   #12 (permalink)
Contributing Member
 
Join Date: Jun 2006
Posts: 607
Rep Power: 3
Default

Quote:
Originally Posted by ChaosX View Post
Yeah. I wanted to do a guide for windows, because anyone who is already using
an operating system other than windows would most likely know how to do it on their own.

You would really really be surprised... Unfortunately.
__________________
92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature.
Khaless is offline   Reply With Quote
Old 04-07-2007   #13 (permalink)
Honorary Member
 
doublethink's Avatar
 
Join Date: Jun 2006
Location: Sydney NSW
Posts: 1,784
Rep Power: 4
Default

Quote:
Originally Posted by Khaless View Post
Installing PHP5/Apache2 on Ubuntu is even easier.

Somthing along the lines of

apt-get install apache2
apt-get install libapache2-mod-php5

and hey, you wanted some extensions with that?

apt-get install php5-mysql php5-curl php5-gd ... etc

Ofc you could compile your own, thats not hard either.
Yeah I love how you can set up a php+mysql server environment in one line on ubuntu

ChaosX, you should also dedicate a tutorial on using the PEAR repository. Many handy packages in there for the average developer to take advantage of (MDB2, QuickForm come to mind).

Beats the pants off anything windows offers. Ubuntu has so many packages available - I even installed a guitar tuner when browsing the repository (Lingot).
doublethink is offline   Reply With Quote
Old 06-07-2007   #14 (permalink)
Monster Member
 
jamiec's Avatar
 
Join Date: Sep 2006
Location: irc.gamesurge.net
Posts: 4,922
Rep Power: 7
Send a message via MSN to jamiec
Default

Looking good ^^
__________________
Man donates blood to save his Mrs. A year later they break up. He says "give me my blood back b**ch". She throws him a tampon and says "f**k you, I'll pay you back monthly".
- lividscott.
jamiec is offline   Reply With Quote
Old 07-07-2007   #15 (permalink)
Member
 
Depodra's Avatar
 
Join Date: Jun 2006
Location: Toowoomba, QLD, AU.
Posts: 116
Rep Power: 3
Send a message via MSN to Depodra
Default

And for those of you who are just plain lazy (I thought I'd hit the wider audience thar,) just download XAMPP.

http://www.apachefriends.org/en/xampp.html
__________________
"I still say a church steeple with a lightning rod on top shows a lack of confidence" ~ Doug McLeod
Depodra is offline   Reply With Quote
Old 27-10-2008   #16 (permalink)
ivo
GotGames Moderator
 
ivo's Avatar
 
Join Date: Jun 2006
Location: Vic
Posts: 2,060
Rep Power: 5
Default

I like Install PHP 5 Apache MySQL on Windows : WampServer
Works great
Has a great little menu to quickly get to localhost, phpMyAdmin, www directory, change server versions.

Should try xxamp sometime as well, but I can't be bothered figuring out whether having two http servers on my computer would **** **** up.

EDIT: Why does XAMPP call themselves XAMPP when they don't include Perl in the default installation? Baffles me.
__________________


"If you wanna get it through their head, talk to them ragely" - fakeh

Last edited by ivo; 27-10-2008 at 11:48 AM..
ivo is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +10. The time now is 08:31 AM.


Powered by vBulletin® Version 3.7.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0