Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Setting Up A WAMP,phpMyAdmin, Wordpress development environment

DZone's Guide to

Setting Up A WAMP,phpMyAdmin, Wordpress development environment

· Web Dev Zone
Free Resource

Learn how to build modern digital experience apps with Crafter CMS. Download this eBook now. Brought to you in partnership with Crafter Software

In this article I will cover getting PHP set-up on Windows, with Apache and MySQL (WAMP). At the end I will also cover how to get phpMyAdmin and Wordpress going on your new PHP development/deployment environment. So without further due, let’s get started. You will need the following:


So once you have downloaded all of the above we can get started. You can either follow the article from start to finish or jump to the section that interests you.

Setting Up Apache

I personally always choose the MSI installer if on Windows as this makes it very simple to get Apache up and running. So, go to the location to where you downloaded the MSI installer and double click the file. On the first screen click next and on the following screen accept the License Agreement and click next. You can then read over the ‘What is…’ document or skip it by clicking next.

The next screen asks you for a couple of items. If you are going to install this on your local machine for testing purposes this information is not going to effect you installation to much however, I usually use my blog domain info here so I would enter:

Network Domain: volume4.com
Server Name: www.volume4.com (on some production servers this can actually also be volume4.com)
Administrators Email: webmaster@volume4.com (It is best to use a valid email address here).
Leave the default to install Apache for all users on port 80.

Unless you have very specific needs you can go ahead and just choose the typical installation. Choose you installation directory, click next and then install. On Windows XP service pack 2 there might be a security window that opens asking you whether to keep blocking Apache or Unblock. Choose unblock and everything should be up and running. Click Finish.

To test your installation, open your browser and go to http://127.0.0.1. This should produce a page saying: It Works! Right that is it for Apache.

Bacl To Top

Setting Up MySQL

Next let’s get MySQL going. Go to the location where you downloaded the .zip file and extract it. Here again I usually go for the ‘Setup’ installer if on Windows. Double click ‘Setup’. On the first screen click next, on the following screen select ‘Custom’ and click next.

On the next screen choose all of the items you would like installed. I usually install everything except the Developer Components as I have never had a need to use them before. If you do find any of these tools to be useful this is where you can select them. When you are ready, click next. Click Install.

On the next screen you can choose to either create a new MySQL account, log-in with your current account or skip sign-up. After you completed the above process you will see the screen that the Wizard is complete and you will have the option to configure the MySQL instance or skip the step and leave it for later.

Personally I like to get everything done the first time. So I tick ‘Configure the MySQL server now’ and click ‘Finish’.

The next screen that opens is the ‘MySQL Server Instance Configuration Wizard’. Click next and then you should select between either, ‘Detailed Configuration’ or ‘Standard Configuration’. If you only need a standard installation the second option will be more then good enough.

Here I will work through the ‘Detailed Configuration’. After selecting this option, click next. Now select the type of machine you want to set-up. I am going to select the ‘Developer Machine’ option.

Next you have the option of what type of database engine you wish to configure. You have the option of a ‘Multifunctional Database’, ‘Transactional Database Only’ or a ‘Non-Transactional Database only’. Under each of these are basic descriptions of what each feature offers and does not. For my purposes I am going to select the last option and click next.

Next you will have the option of selecting the number of concurrent connection that should be available. There are three options here which are, ‘Decision Support’, Online Transaction Processing’ and ‘Manual Setting’. Again, under each of these are descriptions of there configuration details. As this is only going to be a development machine and not a QA or production machine I choose ‘Manual Setting’, leave it at 15 connections and click next.

On the next screen you set your networking options. I leave at the default with both ‘Enable TCP/IP Networking’ and ‘Enable Strict Mode’ ticked and click next.

On the next screen you set your default character set. The selection here will depend on the type of human languages you plan on using with the database. As I do not expect to use any languages other then English and the other Western European languages I select the ‘Standard Character Set’ and click next.

On the next screen you set your Windows options. If this is a development machine you may want to leave ‘Install As Windows Service’ and ‘Launch the MySQL Server automatically’ ticked. If this is also the machine you will be working on you may want to un-tick the ‘Launch the MySQL Server automatically’ so that you can stop and start MySQL as you need it. Next you have the option of activating ‘Include Bin Directory in Windows PATH’, I personally always tick this one as I do a lot of work from the command line. Click next.

On the next screen you set up your security setting so go ahead and choose a password. I leave ‘Enable root access from remote machines’ un-ticked and then click next. Execute. If everything completes successfully, click ‘Finish’. Your MySQL server is up and running.

If something goes wrong during the execution process, I have found the best is to cancel the current configuration, open up Control Panel > Administrative Tools > Services, check for a configured MySQL service and ensure the service is stopped. If there is already more then one service installed, open up Start > All Programs > MySQL > MySQL Server 5.0 > MySQL Server Config Wizard. To remove the one service click next, select the service and select remove instance. After this or if you only had one service installed, select reconfigure instance and go through the process again.

Bacl To Top

Setting Up PHP

So next, let’s get PHP integrated with Apache so we start seeing all of these individual items work together when we install the two apps mentioned before. Go to the location where you downloaded the PHP .zip file and unzip the file. Copy all of the content and create a directory into which you will copy all of these files. I usually place all mine in c:\php

Next right click on My Computer and select Properties. Then click on Advanced > Environmental Variables. Under ‘System Variables’ select Path and click edit. Add the directory location of your PHP installation to the end of the line ex. c:\php; this will ensure that the server modules can get to the php5ts.dll file. Adding your PHP directory to you Path will also aid future upgrades and maintenance. Restart your computer.

Next we need to set-up a valid configuration file for PHP, php.ini. There are two .ini files distributed in the zip file, php.ini-dist and php.ini-recommended. It is advised to use php.ini-recommended, because it has been optimized for performance, and security. Read this well documented file carefully because it has changes from php.ini-dist that will drastically affect your setup. Rename php.ini-recommended to php.ini, open the file and make the required changes. These settings here are specific to your environment and your requirements so please read through the file attentively. If you want, you can set your doc_root in your php.ini to point to you Apache installation.
Ex. doc_root = c:\apache\htdocs

Next it is time to edit the Apache httpd.conf file and enable PHP. Go to {apache-install}/conf/ and open the httpd.conf file. Using you text editor’s search function to find the appropriate place, add the following lines to the file.
For the different Apache server version there are separate DLL files as follows:

  • Apache 1.3.x = php5apache.dll
  • Apache 2.0.x = php5apache2.dll
  • Apache 2.2.x = php5apache2_2.dll

Substitute below as required.

LoadModule php5_module “c:/php/php5apache2.dll”
AddType application/x-httpd-php .php
PHPIniDir “C:/php”

You can add the last line right after you entry of AddType. Also ensure to enable the php_mysqli.dll extension. Without this you will not be able to connect to the MySQL database. To do this, first copy the file php_mysqli.dll from the c:\php\ext directory to the c:\php directory. Next, inside php.ini search for ‘mysql’ and ensure the following is set:
extension=php_mysqli.dll

To test your PHP installation, create a simple HTML file saving it as index.php. Place this file in your {apache-install}/htdocs directory and in this file ad:

< ?php
echo phpinfo();
?>

Go to http://127.0.0.1/index.php

If all the above steps has been followed you should be presented by a PHP page that list a huge amount of info about your current system. Cool!

So we have Apache running, MySQL running and have integrated PHP with Apache. Next we will install phpMyAdmin to further test our PHP and Apache integration and ensure that MySQL is running and that we can connect to it.

Bacl To Top

Setting Up phpMyAdmin

Go to the location where you downloaded your installation files for phpMyAdmin and unzip the file. Copy all of the files from the unzipped folder and paste them in a new directory located at {apache-install}/htdocs Ex. C:\apache\htdocs\myadmin

Now, inside your directory create an empty directory called /Config and ensure that it has read write access. To do this, right click the folder and select properties. If under ‘Attributes’ the ‘Read Only’ box is ticked, un-tick it and click ‘Apply’. Now open:
http://127.0.0.1/myadmin/scripts/setup.php

Here you will be presented with a graphical set-up interface you can use to set the needed configuration properties for phpMyAdmin.

The first thing to do is to add a server so, click on the ‘Server’ button.

Server hostname: localhost
Server port: (you can leave this empty for the default)
Server socket: (you can leave this empty for the default)
Connection type: tcp
PHP extension to use: mysqli
The ‘Compress Connection’ is an experimental feature, so enable at own risk.
Authentication Type: cookie
User for config auth: (Only used if above is set to config)
Password for config auth: (Only used if above is set to config)
Only database to show: (You can use a , separated string of database names to show or leave empty to show all)
Verbose name of this server: (Only useful when using phpMyAdmin with multiple server entries.)
phpMyAdmin control user: root
phpMyAdmin control user password: (password entered during MySQL installation)
phpMyAdmin database for advanced features: phpMyAdmin

For the last entry you actually have to create the database I entered. To do this, open your command prompt. Start > Run: cmd

At the prompt type mysql –u root –p. When prompted for your password, enter the password you entered during MySQL set-up. Next type:

CREATE DATABASE phpMyAdmin;
USE phpMyAdmin;
GRANT ALL PRIVILEGES ON phpMyAdmin.* TO root@localhost IDENTIFIED BY ‘password’;
Exit
exit

Now you can click ‘Add’. Your server is successfully added. There is a bunch of other options you can set here but for now under Configuration, click save and follow the instructions.

Before moving on to the next step, one small step is needed to tell Apache to serve either a .html or .php file if the directory is called. To do this open your httpd.conf again and find this line:
Now add the line: DirectoryIndex index.php
Your are all set!

Next, go to:
http://127.0.0.1/myadmin/
Log into using your control username and password and voila! You have a working phpMyAdmin installation. This means you now have Apache running, MySQL running, Apache and PHP integrated and you can successfully connect and manage you MySQL server via the web.

Now let’s finish with phpMyAdmin by adding the tables to the phpMyAdmin table so the advanced features will work successfully. On the left select the phpMyAdmin database. Next click on ‘Import’, then under ‘File to import’ click on ‘Browse’. From the /scripts directory under the /myadmin directory select the create_tables_mysql_4_1_2+.sql file. Before clicking ‘Go’ open the .sql file and change the username from pma to root. Now click ‘Go’.

After the query ran you are set-up!

Bacl To Top

Setting Up Wordpress

Now, to finish up all of this, let’s set-up the very popular blogging tool, Wordpress. Go to the location where you downloaded the zip file and unzip it. Copy all of the files from the unzipped folder to a new folder under at {apache-install}/htdocs Ex. at {apache-install}/htdocs/myblog

Now open phpMyAdmin and create a new database that Wordpress can use. Click on SQL and enter:

GRANT ALL PRIVILEGES ON dbname.* TO username@localhost IDENTIFIED BY ‘password’

Go to your Wordpress installation directory on Apache and rename the file wp-config-sample.php to wp-config.php. Open the file and add your database details. One more thing to note here, previously we installed the php-mysqli.dll extension however, Wordpress does not work with this extension and we will also have to enable the normal php-mysql.dll extension.

So again, open you php.ini file and go to the line where you previously activated the mysqli extension. Now also add:
extension=php_mysql.dll

Remember to also copy the php-mysql.dll file from the c:\php\ext directory to the c:\php directory and restart Apache.

Now, go to http://127.0.0.1/myblog/wp-admin/install.php
Follow the simple steps to get your blog up and running.

That’s it! You now have a working PHP development end testing environment with two useful apps installed.

I hope this helps someone out that is starting their journey into PHP, Apache and MySQL.

Crafter is a modern CMS platform for building modern websites and content-rich digital experiences. Download this eBook now. Brought to you in partnership with Crafter Software.

Topics:

Published at DZone with permission of Schalk Neethling. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}