So first of all, we need to download mysql, apache and mysql. Go to the following sites and grab the latest copies:
http://dev.mysql.com/downloads/mysql/5.0.html#downloads - for mysql, I have found the installer package usually works fine out of the box. Make sure to grab the correct package for your OS.
Now for apache go to http://httpd.apache.org/ and grab the 2.2x version for windows. Make sure to grab the MSI installer unless you have a C++ compiler setup and prefer to build everything for your self.
Last but not least, lets grab the latest version of php which can be found at: http://www.php.net/downloads.php. NOTICE: Do not download the installer for php as it will only cause you a massive headache, maybe even death. Download the zip package instead, as it comes with just about everything you'll ever need to work in php.
Ok, now lets install everything!
We'll start by installing apache. This is pretty straight forward but make sure to set the network and servername to localhost and set the email accordingly. You can also change the install path to c:\apache\ for easier navigation... I usually put apache, mysql and php all in the root.
Lets test apache!
If everything went accordingly to plan, you should now be able to hit http://localhost in your browser where you'll be greeted with a basic message "It works", if not, try restarted your computer and if this does not work, uninstall apache and start over, this is about the easiest thing to do.
Ok so next, lets install php. Since you downloaded the zip package, really all you need to do is extract everything to c:\php or whatever you would like.
Now to get php and apache talking to each other, we need to let apache know about php's existence. We do this by making a few changes in apache's httpd file which is located in the apache/conf/ directory.
First off, locate the LoadModule section and add the following line at the bottom:
LoadModule php5_module "c:/php/php5apache2_2.dll"
Make sure to edit the path accordingly to the directory in which you extracted php to.
Now, below this add these lines:
PHPIniDir "C:/php"
<Files "*.php">
AddHandler application/x-httpd-php .php
</Files>
Again, make sure to set the path correctly and also be sure to check that the path you set in PHPIniDir is the path in which the php.ini file can be found.
Additional changes in the httpd file:
You will also want to change these settings as well later on, so lets just to it now that we already have the httpd file open.
First, locate the following lines:
DocumentRoot "C:/Apache2.2/htdocs"
and
<Directory "C:/Apache2.2/htdocs">
You can change the paths to whatever directory you would like to keep your php files at or leave it as is. Note that you will not be able to access any any files from the web if they are not located in this directory or a child directory such as htdocs/mysite/.
One last thing, locate the following:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
And add index.php as well. For example:
DirectoryIndex index.html, index.php
This isn't required but makes our life a little easier. Now apache will automatically check for either index.html or index.php by default if we do no request an explicit file in the browser. For example, if we go to http://localhost/ apache will now know to check to see if we have an index.html or index.php file automatically.
Save the changes to the httpd file and lets test it!
Ok, so lets see if it's working. We'll do this by creating a very basic php page and placing it in our document root directory as described above. First however, restart apache to allow the changed you made to the httpd file to take effect.
In our document root, lets create a new php file. We'll call it index.php as I mentioned earlier. In this file, we'll add some simple code:
<?php>
echo phpinfo();
<?>
Save the file and lets test it. Open up your web browser and type the following: http://localhost/
You should now be show a page with all sorts of information regarding php and apache. If not, somethings wrong...
Now, we can install MySQL!
This is a pretty straight forward process. Start the mysql installer program and basically just leave everything as is. Once isntalled, make sure to run the instance configuration wizard which will get mysql ready to be used. Essentially you can simply leave everything at default. Make sure to set the root password to something you can remember later on.
Now we need to make a change to our environmental variables in windows. The quickest way to get there is by right click on 'My Computer' navigate to the advanced tab, click on the environmental variables button the locate the path settings. Double click on path and add the following at the end:
;C:\mysql-install-directory\libmySQL.dll
Warning! Make sure to add the ; at the beginning if theres not already one there or else you'll run into problems with your system!!
Now just hit apply and your ready to go to the next step.
One your done with, theres just a few more things you'll need to do in order to get everything talking to one another. First of all, go the the mysql directory and copy the libmysql.dll file over to the apache/bin directory. Next, we'll need to make a few changes to our php.ini file.
Go to the php directory and create a copy of the file named php.ini-recommended
and rename it to php.ini. Now, go ahead and open it so we can tell php about mysql. Search for the line that reads: ;extension=php_mysqli.php and remove the ";" for the extenion. Also, let's go ahead and remove the ; from ;extension=php_mcrypt.dll while were at it, as we'll need this availble in just a minute.
Once your done with this, go ahead and save the file then restart apache. If apache fails to start, there is a problem somewhere in your settings. If this happens, leave a comment and I'll give you a hand.
Note: mysql.com recommends using php_mysqli over the standard php_mysql.dll for php5 and later.
Now lets install PhpMyAdmin...
If your not sure what phpmyadmin is, don't worry because you soon will. First, lets grab the latest release from http://www.phpmyadmin.net/home_page/downloads.php. Once it's finished downloading, extract the files to your DocumentRoot directory as I mentioned earlier. I usually rename the folder to phpmyadmin for ease of use.
Now navigate through the files until you find the config.sample.inc file. Create a copy and rename it to config.inc. We need to now make just a few simple changes:
Set some random value in between ''...
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
example:
$cfg['blowfish_secret'] = 'as978a9s7234jk218kjl53'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
Next, remove the ; from the beginning of each of the following lines: (example: ;$cfg should be $cfg)
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysqli'; //make sure to add the 'i'
/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'root'; //MySQL root user
$cfg['Servers'][$i]['controlpass'] = 'somepassword'; //change this to whatever you had set the password to when configuring mysql.
Thats pretty much about it. Now go ahead and save the changes then navigate to http://localhost/phpmyadmin or whatever you named the phpmyadmin folder to. You should now be confronted with a login screen. Use the same info you used in the config.inc file such as: root/somepassword for example.
If all goes well, you'll be logged in and can start creating databases and tables in the databases. PhpMyAdmin is an invaluable tool that I personally would not want to live without and it's a good way to make sure all of our work is working correctly!
If you are given any errors on the loggin screen, such as 'can not load mysqli.dll' or 'mcrypt.dll', it's because php isn't seeing them. Post a comment and I'll try to help you out.

0 comments:
Post a Comment