Installing Apache, MySQL and PHP for Windows 8. (XAMPP)

Here are instructions how to install XAMPP in Windows 8 computer.
What is XAMPP?
Go to

http://www.apachefriends.org/en/xampp-windows.html

Download ZIP file for Windows.
Extract ZIP to you C:\ so the XAMPP folder is in C:\xampp
Run

$ \xampp\setup_xampp.bat

Check the settings file

$ \xampp\php\php.ini

Check these three non-commented lines that they match. Date.timezone should be your timezone.

error_reporting = E_ALL | E_STRICT
magic_quotes_gpc = Off
date.timezone = "Europe/Helsinki"

Close Skype and IIS if you are using those.
Run Apache and MySQL with

$ \xampp\xampp-control.exe

1
Go to and choose your language.

http://localhost/

Go to and change your MySQL password

http://localhost/security/index.php

23
Stop and start Apache and MySQL with.

$ \xampp\xampp-control.exe

Make folder php to

$ \xampp\htdocs\

and create file there

helloworld.php

And inside the file

<?php 
 Print "Hello, World!";
 ?>  

Go to

http://localhost/php/helloworld.php

Php works.

Hello, World!

Open cmd and open MySQL with root user.

$ cd \xampp\mysql\bin
$ mysql.exe -u root -p 

Create test database and user

mysql> create database soiviPersons;
mysql> grant all on soiviPersons.* to [email protected] identified by "SECRETPASSWORD";
mysql> exit

Login with new user and use created database

$ mysql.exe -u soiviPersons -p
mysql> USE soiviPersons ; 

Create new test table with test material

mysql> CREATE TABLE person (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName VARCHAR(100), LastName VARCHAR(100));
mysql> INSERT INTO person (FirstName, LastName) VALUES ('Jaakko', 'Poskiparta');
mysql> INSERT INTO person (FirstName, LastName) VALUES ('Kalevi', 'Hurmeinen');
mysql> SELECT * FROM person;
mysql> exit

Modify helloworld.php

<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
$con=mysqli_connect("localhost","soiviPersons","SECRETPASSWORD","soiviPersons");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$result = mysqli_query($con,"SELECT * FROM person");
echo "<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>";
while($row = mysqli_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['FirstName'] . "</td>";
  echo "<td>" . $row['LastName'] . "</td>";
  echo "</tr>";
  }
echo "</table>";
mysqli_close($con);
?>
</body>
</html>

Go to

http://localhost/php/helloworld.php

4

Now you have tested Apache, PHP and MySQL and confirmed that they all are working.
Then you can remove test user and test database from MySQL.

$ mysql.exe -u root -p
mysql> DROP USER [email protected];
mysql> DROP DATABASE soiviPersons;
mysql> SHOW DATABASES;
mysql> exit;

If you want use Eclipse to coding PHP you need to download PDT plugin to your Eclipse.
Go in your Eclipse

Help -> Install new software

And work with you add url

http://download.eclipse.org/tools/pdt/updates/release

choose PDT and install it.
5