|
|
#1 (permalink) |
|
GotGames Moderator
|
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 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\" 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:
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 |
|
|
|
|
|
|
|
#3 (permalink) |
|
GotGames Moderator
|
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. |
|
|
|
|
|
#10 (permalink) |
|
Contributing Member
Join Date: Jun 2006
Posts: 607
Rep Power: 3
|
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. |
|
|
|
|
|
#11 (permalink) | |
|
GotGames Moderator
|
Quote:
an operating system other than windows would most likely know how to do it on their own.
|
|
|
|
|
|
|
#12 (permalink) | |
|
Contributing Member
Join Date: Jun 2006
Posts: 607
Rep Power: 3
|
Quote:
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. |
|
|
|
|
|
|
#13 (permalink) | |
|
Honorary Member
Join Date: Jun 2006
Location: Sydney NSW
Posts: 1,784
Rep Power: 4
|
Quote:
![]() 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). |
|
|
|
|
|
|
#15 (permalink) |
|
Member
|
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 |
|
|
|
|
|
#16 (permalink) |
|
GotGames Moderator
Join Date: Jun 2006
Location: Vic
Posts: 2,060
Rep Power: 5
|
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.. |
|
|
|







