So I was buzzing around the web because I wanted to install PHP. Yes yes, I’ve stated that PHP is kife, however, I am all about full configuration conveniences. Not for any other reason than allowing all viable options, to actually be viable options.
I initially just installed Apache2.2.11 (herein known as Apache2) then ColdFusion 8 with JRun 4 because that is the point for me – J2EE and ColdFusion 8. That worked on the first try, without issue, so I figured, meh why not right? Let’s install all the languages… incidentally… I’m going to install Classic ASP and dot.NET for PHP as well, just as I’m going to install Perl and Python and blah blah blah…
Partially though it’s ego. I like when my installations go without incident on the first try.
However, as I was saying, I was buzzing around the InterWeb looking for anyone else who might have tried it and what did I find? I slew of folks who were going ‘wahhhhh php5 and apache2 doesn’t work wahhhh and i have this issue and i have that issue…’ and etc etc so I thought screw it, I’m going to do it, have it work on my first try and then just write a tutorial on it, because my stuff always works on the first try. (Arrogant isn’t it? heh)
Ok, for the sake of simplicity, I did this for WindowsXP. If you want to do this on Vista, you can follow the same method, though I’m not going to do it for you, or write a tutorial for it… oh and btw? If you have Vista, you have to realize that the Built-In Administrator Account is disabled by default, so you should enable it, create a password for it, log out, and then log in with it, so that you can avoid those really annoying “warning will robinson! warning will robinson! Danger! Danger!” things that come with Windows Vista.
Right, so, first things first. We have to install Apache2. I downloaded the following packages:
1: Apache 2.2.11
2: PHP 5.2.6
3: PECL 5.2.6 Win23
4: MySQL 5.1
1: Apache2: Just run the installer for Apache2. It’s straightforward and takes no skill, the defaults are fine, though for me, I used C:/Apache2.2 for the installation directory.
2: PHP5: Extract the directory to where you want it, I put it in C:/PHP because I like things simple.
3: Extract the PECL 5.2.6 Win32 Modules into the C:/PHP/EXT directory.
4: copy the file C:\PHP\php.ini-recommended to the C:\Apache2.2 directory. Rename it to C:\Apache2.2\php.ini.
5: Open php.ini in your favourite text editor. Do a search for “extension_dir =” and change it to ‘ extension_dir = “C:\PHP\ext” ‘ Scroll down to the ;extension= and uncheck the following:
extension=php_mssql.dll
extension=php_msql.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_java.dll
extension=php_ldap.dll
extension=php_iisfunc.dll
extension=php_imap.dll
extension=php_filepro.dll
extension=php_gd2.dll
extension=php_gettext.dll
extension=php_dba.dll
extension=php_dbase.dll
extension=php_dbx.dll
extension=php_mbstring.dll
extension=php_pdf.dll
extension=php_pgsql.dll
extension=php_sockets.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll
extension=php_zip.dll
(I have an added extension of : extension=php_imagick.dll which i added at the bottom of those extensions. If you have anything yourself, then add them but make sure the appropriate dll files are sitting in the c:\php\ext directory.)
(You don’t have to do this next step, but i find it improves performance on a Windows machine, so I would suggest it, but it’s your installation, so do what you want.)
6: Now copy/paste the php.ini file into your C:\WINDOWS directory.
7: Right Click on “My Computer” select “Properties” select “Advanced Tab” and select “Environment Variables.” You’ll see something that is called “System Variables” with a Variable/Value pairing. Scroll till you find the variable called “Path” and click the “Edit” button.
I tend to copy/paste it into a new page in my text editor so i don’t screw it up, and add the following line to the front: “C:\PHP;” don’t forget the “;” because that is how you separate the path variable values. Save, Save, End Exit.
Now the fun stuff! Registry Editing
8: Start > Run: Type in “regedit” > click OK.
9: Go to : HKEY_LOCAL_MACHINE – expand it.
10: Go to : SOFTWARE – expand it.
11: Scroll till you find PHP, if you don’t find PHP then right click “SOFTWARE” and click “NEW” then “Key” Call it PHP.
12: Right click the newly created key of PHP and select “New” then “String Value” you’ll see a “New Value #1” appear in the right hand column. right click that key and “Modify” it, with “C:\php” click ok.
13: Then right click “New Value #1” and rename it to: “IniFilePath” Close the Registry Editor.
14: Navigate to the C:\Apache2\conf directory, and open up the httpd.conf file in your favourite text editor. Scroll to the bottom of the page and add the following:
# php
LoadModule php5_module “C:/php/php5apache2_2.dll”
<IfModule php5_module>
AddType application/x-httpd-php .php
</IfModule>
15: Now, do a search for <IfModule dir_module> and you’ll see the following:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
Modify it to the following
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
and any other index.extension files you want (I have index.cfm, index.jsp, index.asp because I’m running those on Apache2 as well). If you want php to be the default, then you should make sure it resembles the following:
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
16: Save and close it.
17: Open a new page in your favorite text editor and call it “index.php.” Save it to the following directory: C:\Apache2.2\htdocs.
18: Now, add the following to “index.php“:
<?php
phpinfo();
?>
This will make sure that you can see all the kewl PHP server stuff when you test your server.
19: reboot your computer.
20: When you reboot you should be able to go to the following file: http://localhost/index.php and you’ll see the full server variables. Now you know PHP and Apache2 are functioning properly. If you only type in http://localhost/ and it pops up “It Works!” then you know that Apache2 is running but index.php is not the default index page.
—————————————————————————————————-
I know this works because this is exactly how I’ve done it and how I’ve shown and taught it for the last 2 years, or at least as long as PHP 5.2.6 has been out.
It’s late now and I don’t feel like dealing with the MySQL 5.1 installation but it’s pretty basic, so you can just run the installer and there are loads of tutorials online. If you really really really need to know and can’t figure out how to use Google, please leave a comment and I’ll send you a few links.
I am making the assumption that you’ve done all of this verbatim. If you haven’t and you have errors, bummer, you should have read the tutorial first, and not dealt with any fiddling here and there yourself.
I realize this was kind of a lazy toot, but well… I’m watching “Snake Eyes” and it’s distracting me
hello tnx for de tutorial.
answer me plz why install pecl? why u use that?
By: Thiago on May 27, 2009
at 10:50 pm