Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 206
0 Users 3 Guests Online

WAMP Server (Windows, Apache, MySQL, PHP + phpMyAdmin)

This tutorial will cover the installation and setup of Apache, PHP and MySQL though we will also cover installing an FTP Server so you can access the site from elsewhere if need be.


To start off you will want to find a place to install, I generally group all the server components in a single folder, with the htdocs folder around the same area. So, you can setup a directory structure such as the following.

./root
  • Apache
  • htdocs
  • logs
  • MySQL
  • PHP

To start off the installation you will want to go to the apache website located at http://apache.org and select Download from the menu at the top right-hand side of the page.

TutorialNinja Image


After clicking on the downloads link it will take you to a long list of mirrors where you could possibly download the latest version of Apache from. I will be using the mirror located under FTP with the address of ftp://apache.mirrors.pair.com/ for the download. If you chose to use the same, you will want to the find the directory titled "httpd"

TutorialNinja Image


Under this directory, you'll want to select the binaries folder followed by the win32 sub folder which will contain the installation files for Apache. In the folder now there will be several executables. Two for version 2.0.65 and two for 2.2.25 Both have the option of either SSL or non-SSL. For this tutorial I went ahead with the 2.2.25 SSL version.

After the executable has downloaded feel free to run the installer and continue on with the next part of this section. The first three screens are just general information and the EULA, if you wish, feel free to read the EULA otherwise just mark "I agree" and continue onwards until you reach the following screen.

TutorialNinja Image


This window will be where you enter the server information. You will want to provide your network domain and server domain such as localhost along with your E-mail. If it is only for local testing you could probably just use admin@localhost and not have to worry about it. Otherwise, you'll want to use your regular e-mail. The next screen asks which setup type you would like to use, feel free to just use "Typical" and on the next to last screen before you install, you will want to change the directory to install to the folder you have setup.

TutorialNinja Image


After changing the path feel free to move on to the actual installation window and allow it some time to finish its process before pressing "Finish" on the final screen.

In the next part of this tutorial, wewill be changing the htdocs folder to point to a more convenient location. Because we already (or, should already) have C:\WAMP, I will be changing the directory to C:\WAMP\htdocs. To do this, you will want to go to C:\WAMP\Apache\conf and open httpd.conf with your favorite text editor. In the file you will want to find DocumentRoot "C:/WAMP/Apache/htdocs" and change it to DocumentRoot "C:/WAMP/htdocs". A little further down the file you will come across <Directory "C:/WAMP/Apache/htdocs"> you will also want to change the directory here to the new one C:/WAMP/htdocs. With that set, you can save the file then restart Apache to reflect the changes.

If you plan on using ModRewrite, you will also want to uncomment it. You can find this around line 119 and just remove the # from #LodeModule rewrite_module modules/mod_rewrite.so followed by saving the file and restarting Apache once more for the change to take effect.

The third part of this tutorial will now cover the download, installation and configuration of the MySQL Database server and setup of phpMyAdmin.

You will first want to go ahead and run out to http://mysql.com then select the Downloads tab.

TutorialNinja Image


Under this section of the MySQL Website there will be three options to download. We will want to select the MySQL Community Edition downloads.

TutorialNinja Image


Selecting
Community (GPL) Downloads »


will take you to another listing of downloads. However, the download we will be wanting is the MySQL Community Server which is found at the top of the listing.

TutorialNinja Image


From the following screen you will want to select your platform, of course, this tutorial assumes you are using Windows so you will want to select the Download button for the installer. You will want to decide whether you want to install it via the internet or go for an offline install package. For this tutorial I pre-downloaded the offline installer.

TutorialNinja Image


The next screen you encounter will ask to either login or make an account. Below that however is a "No thanks" link you can select to just go to the download.

After you download the 243 MB file, go ahead and run the file. The first screen that comes up will have hte option to either Install, learn about MySQL or find resources on how to install/configure MySQL. Go ahead and just select "Install MySQL Products."

TutorialNinja Image


The next screen that appears will be the EULA, if you're not an avid reader, just select "I agree" and press continue. The window after this will be an option to find the latest updates for the products. Though there should be none, go ahead and just click on Execute to make sure you have the most up to date version then click Next to proceed to the next step. On the Setup Type section there will be 5 options to choose from. I went with Server Only option and changed the Installation Path as well that way we don't get anything extra we don't need. The path I chose to use was pointed to the wamp directory C:\WAMP\MySQL.

TutorialNinja Image


The next screen is the check requirements screen which should have nothing extra, if there are extra requirements go ahead and install them then click Next to proceed to the installation part

On the installation step, just go ahead and click on Execute to proceed with the installation of MySQL server. When the installation completes, click on Next to proceed to configuring the server. The next window won't have many options at all, so just select Next and it will bring up some options. On this screen, I selected "Server Machine" under the configuration type since there will also be FTP and Apache on the server.

If you wish to leave the port the same, you may do so, or you can change it. I left it alone and selected the "Show Advanced Options" box as well before clicking next.

TutorialNinja Image


The next window will ask you for a MySQL root password. go ahead and set the password then click on Next.

TutorialNinja Image


Following the root password and user accounts screen will be the service details which will auto-start MySQL when windows boots up. I've gone ahead and left the options here on default before clicking next.

TutorialNinja Image


Next up, we have logging options. You can change the name of the log or leave it the same and also choose the path where to store these logs. I've gone ahead and cahnged the path to C:\WAMP\logs\mysql\[logname]. For example, the first log is stored at C:\WAMP\logs\mysql\error.log.

TutorialNinja Image


After you click next the configuration options will be applied to the server and you will then have a screen such as the following.

TutorialNinja Image


Upon clicking Next you will find that the setup has been completed and you can completely finish the installation by clicking on the Finish button.

The next part of the tutorial will cover downloading and setting up PHP to work with Apache. Now to start off we will want to visit the PHP Windows website and select the Downloads link from the menu.

TutorialNinja Image

From here, you will be presented with three version. The versions that are listed are PHP 5.5, 5.4 and 5.3. Most cPanel servers are using version 5.4 for their installs so for this tutorial I went with 5.4.29 Thread-Safe. The download is actually a zip file so to install it, simply make a folder under C:\WAMP called PHP and extract the zip file there. To make PHP work with Apache, you will once again want to alter the httpd.conf file and configure Apache to recognize PHP and use it to run the scripts. To do this, we will want to add the following lines to the file close to where all the modules are being loaded.

Code
LoadModule php5_module "C:/WAMP/PHP/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/AMP/PHP"


These two lines will make it so Apache will recognize PHP and begin using the PHP engine to process scripts with the .php file extension. However, if you were to try and add an index.php to the htdocs folder, it would not recognize it as it is not a valid index file as per the Apache configuration. To make it recognize this, you will once again want to edit the httpd.conf file and find DirectoryIndex index.html and just add index.php with a space after index.html. After you save the file and restart Apache you will be able to visit http://localhost and if you have an index.php file in the directory, it should go ahead and load it. In the root of the PHP folder you will want to either Rename php.ini-development or php.ini-production to be used as your main php.ini file which will be used by the server. I've gone ahead and chosen to rename php.ini-development to just php.ini for use in the tutorial.

To make sure PHP is properly loaded, you can create a file in the htdocs and name it info.php and add the following line of code to it.
1
2
3
<?php 
phpinfo(); 
?>


This will just print the PHP info page when you visit it. If you are missing anything you need for your scripts, you can edit the php.ini file and uncomment the extension. If the module still does not load, you may need to change the extension_dir configuration option within the php.ini from ; extension_dir = "ext" to extension_dir = "C:\WAMP\PHP\ext/" with the trailing slash which will direct the PHP engine to look there for any additional modules you wish to load.

The next portion of the MySQL section will cover the setup and configuration of phpMyAdmin which is a web-based database administration tool. To start off, you will want to go to http://phpmyadmin.net/ and select Download from the menu which will take you to the download without any extra fuss.

TutorialNinja Image


In your htdocs folder go ahead and make the folder called phpMyAdmin and drop the ZIP file you downloaded in there and extract it. By default, when you visit http://localhost/phpMyAdmin/ it will ask for a MySQL username and password which is fine and dandy, but it will contain all default options.

TutorialNinja Image


Ideally, you wouldn't want this accessible to the internet and thus you should take steps to secure it further. To do this, you can move it out of the HTDocs folder into the main folder and just setup and alias in the httpd.conf file, or add HTTP Authentication to the phpMyAdmin folder. Though, using both is not a bad idea. To setup and alias, just move the folder to the root folder before the htdocs folder and open up your httpd configuration file.

After opening the file run a CTRL+F and look for <IfModule alias_module> then add the following line somewhere within that section.
Code
Alias /MySQLAdmin "C:/WAMP/phpMyAdmin/"
<Directory "C:/WAMP/phpMyAdmin/">
AllowOverride all
Order allow,deny
Allow from all
</Directory>

You can change MySQLAdmin to whatever you want before saving and restarting Apache for this to take effect. The current configuration will still allow anyone to access it, so if you only want your IP able to access it simple change Allow from all to Deny from all and add Allow from your.ip.address.here and then save the configuration and restart apache.
The above block will be required to access the folder, otherwise you will receive a 403 error. You can use the IP filtering as well to make it so only you can access or you could also go the route of using an htpasswd file which contains a list of usernames and passwords of those allowed to access the folder. To use this, simply make the file .htaccess in the phpMyAdmin folder and add the following to it.

Code
AuthType Basic
AuthName "Web Based MySQL"
AuthUserFile "C:/WAMP/passwd/mysql.htpasswd"
Require valid-user

After completing this, you will want to generate a list of usernames and passwords. Luckily, Apache comes with a tool to generate the file needed. To access it, simply open command prompt and run cd C:\WAMP\Apache\bin to go to the binaries folder for apache. Under here we will want to use the htpasswd file to make the authentication file. To do so, run the following command htpasswd C:\WAMP\passwd\mysql.htpasswd YourUsername.

Obviously, you can change the username to whatever you want then just press enter and it will request a password. Give it any password you so choose to use, enter once more after pressing enter for verification and then enter again and it will make the file for you. Now when you visit the link for phpMyAdmin you will be prompted for a username and password.

TutorialNinja Image

The final part of the giant puzzle is an FTP server. For this tutorial I have chosen to use the Xlight FTP Server. To get started you will want to visit http://xlightftpd.com/ and select Download from the top menu.

TutorialNinja Image


From here you will want to select which you would like to use. I myself went with the 64-bit install package.

TutorialNinja Image


After you've downloaded the installer, go ahead and run it to begin the installation of the FTP server. The first two screens as almost always are the welcome and the EULA. Select I agree, and then proceed to the installation path screen. This is where you want to change it to the FTP folder of your WAMP directory, so go ahead and change that. For this tutorial I've used C:\WAMP\FTPd for installation. The next two windows are just to add things to start menu and whether or not you want a desktop icon. After going through those screens select Install and then wait for it to finish.

Once it has installed, go ahead and launch the application and you shall be presented with a new window. To start off, you will want to click the computer monitor with a plus sign icon which will create a new virtual FTP Server. On this screen, you can select which IP, Port and Protocol you want to use for the server. I left it all the default and just selected OK.

TutorialNinja Image


When you click OK, the server will be added to the list with a stopped status. To start the server, just Right-click and go to Virtual Server Operations. Under here, select Start Server and it will start the server. Next you will want a user account. To add one, select the person icon just above the Status label which should now say Running. On this window, select the blue plus sign icon where you can select to add a username and password, or make an anonymous account. I've gone ahead and setup an actual account to use since we likely allowing anonymous users access to the files.

For the home directory, you can either set it to the htdocs folder, or just add the user, leave it blank then add the user to a group where the directories have been set for the group and that user will be able to access them. As this is a tutorial I've gone ahead and set the Home Directory to the HTDocs folder, but I will show how to

TutorialNinja Image


Suppose you want to have many users with a single home directory, but don't want to manually set all their home directories to the same, albeit quite easy with copy paste. To do this, you can select the icon to the right of user management which will be group management instead and again click on the blue plus sign icon. Go ahead and give it a name then make sure it is selected and then click the Edit icon below the add. Here you can apply permissions to the user and control when exactly the group can log into the server. For this part of the tutorial we're interested in the "Group Path" section. Here you can specify all the directories the group can access. For the root directory simply click Add and leave the Virtual Path as / before selecting the real path and apply some permissions to the folder.

TutorialNinja Image


You can repeat the process for all the other folder the group will need access to. After making your changes click OK to exit out of that window. Next you will want to add the user(s) to that group. To do so you want to go back into the user management and edit the user you want in the group. As soon as you click Edit for the account you will want to click the first Setup button which will be for username, password and group name.

TutorialNinja Image
TutorialNinja Image


To add the user to the group, simply select the group from the groupname dropdown or type in the name of the group and press OK. When you get back to the User List, you should now see the user in the group.

TutorialNinja Image


As a final step, you may want to install the FTP Server as a service to start with Windows. To do this, on the main window, right click in the whitespace and select "Global Options." From the new menu, just select "Install Service" and the FTP Service will be installed on the server thus auto-starting FTP when the computer boots into windows.

TutorialNinja Image

Port Forwarding will be required if you wish to access the server from outside your home. Luckily, there are plenty of tools and guides to do this. The website http://portforward.com/ will have a detailed guide for your router on how to forward all the ports you need. The ports you want to forward are 80 and port 21.

If you wish to use SSL connections over HTTPS you will want to also forward port 443. If you also want to be able to remotely connect to MySQL you may also want to forward port 3306. If you wish to check whether or not the ports have all been forwarded correctly, you can use a tool from http://t1shopper.com/tools/ to scan the open ports on your machine. Simply select the FTP and HTTP options next to Port Scan and then click Go. If you used different ports, or changed the ports, you will want to select "More ports" to the right-hand side of the check boxes and then "scan this list of port numbers" box input the port numbers in a comma separated list.
ShadowMage
Author:
Views:
16892
Rating:
Posted on Wednesday 12th November 2008 at 09:40 PM
peza
peza
i hate vista lol xp all the way, but unfortunatly i have vista lol 64 bit. They better improve it lol.
Posted on Wednesday 12th November 2008 at 09:33 PM
ShadowMage
ShadowMage
Aww
Posted on Wednesday 12th November 2008 at 08:51 PM
peza
peza
unfortuantly the mysql site says vista x64 wont work with it atm
Posted on Monday 10th November 2008 at 09:20 PM
DanielXP
DanielXP
It does work with vista :)
Posted on Monday 10th November 2008 at 08:58 PM
ShadowMage
ShadowMage
You would have to run them all as administrator probably. But try and let us know :D
Posted on Monday 10th November 2008 at 04:31 PM
peza
peza
does this work on vista? nice tut anyways
Posted on Sunday 9th November 2008 at 02:33 PM
ShadowMage
ShadowMage
Setup something like XAMPP, WAMP, or VertrigoServ.
Posted on Sunday 9th November 2008 at 10:19 AM
jambomb
jambomb
what does this actualy do ? :)
Posted on Sunday 9th November 2008 at 02:27 AM
ShadowMage
ShadowMage
I made a booboo. I picked and said Typical instead of custom ._.;