Friday, January 22, 2010

Tweaking phpMyAdmin configuration

Configuring the phpMyAdmin is the most tedious part. Patience and attention to detail will take us through this arduous task.

First, we will need to add a password to the "root" user of MySql. This is always a recommended procedure. For the sake of the tutorial the password will be the string "password". Navigate to WAMP system tray icon -> MySQL -> Mysql console to open the MySql console. Change the root password and reset privileges as illustrated below :

Remember to include password() function in your query to facilitate the password hashing.

You can now open the phpMyAdmin interface from the system tray. You will notice a new error message. This is because the password has not been updated in the phpMyAdmin config file.

Open your WAMP folder installation. Navigate to wamp\apps\phpMyAdmin3.2.0.1 (or the relevant version). Open the file in a text editor.

Add the password for the root, which is "password" in our case and change the authentication type to "cookie", as illustrated below:

$cfg['Servers'][$i]['auth_type'] = 'cookie'; $cfg['Servers'][$i]['password'] = 'password';

Also, add the the following line at the top of the file as illustrated below:

$cfg['blowfish_secret'] = 'password';

Relaunch the phpMyAdmin from the system tray icon. At the launch, you will now see a login screen asking you for the username and password. Enter the credentials as "root" and "password" as shown below.

In most cases, you will notice the following warning at the bottom of the page once you have logged in:

For intermediate and advanced users, these advanced features related to linked tables are important. We will now see how to activate these features. First create a database called "phpmyadmin" as shown below.

Click on the newly created database. Navigate to the privileges tab of the newly created database. Click on "Add a new user" as shown below:

Create a new user called "pma". Choose "localhost" for host and "password" for password. We are choosing "password" for all passwords only for the sake of simple explanation.
Choose "grant all privileges on database phpmyadmin" option in the Database for User segment.
Click on the "Go" button.

Go back to the file in wamp\apps\phpMyAdmin3.2.0.1 (or the relevant version) and open the file in a text editor. Add the following lines as shown in the illustration.

$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
$cfg['Servers'][$i]['relation'] = 'pma_relation';
$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
$cfg['Servers'][$i]['history'] = 'pma_history';
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';

$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'password';

Log out of phpMyAdmin interface. Login again to the interface using the credentials, username "pma" and password "password" as shown below.

This section is important. We need to import a file that is going to add all the additional features relating to linked tables. Once you have logged in as user "pma" click on the import button and import the file "wamp\apps\phpMyAdmin3.2.0.1 (or the relevant version)\scripts\create_tables.php".

This should add ~8 tables related to linked-tables, bookmarks, table-info, pdf-pages etc.

Restart the WAMP server.

After this step you may choose to the following:
  1. change all passwords
  2. revoke all privileges to the "pma" user on "phpmyadmin" and grant only basic privileges like SELECT,INSERT, UPDATE

We are done configuring the WAMP server on port 8080.

You can also navigate to the main page. Good luck.

Please leave a comment or mail me, if there are any questions.

Tweaking the WAMP manager configuration

We need to configure the WAMP manager files in order to land on localhost:8080 every time we launch the localhost or phpMyAdmin from the system tray icon.

Generally WAMP is installed in C:\WAMP. Otherwise, please navigate to your WAMP installation folder and make sure the files wampmanager.ini and wampmanager.tpl are present.

In the wampmanager.ini file we will need to replace 3 occurrences of the string "localhost" as "localhost:8080". Please replace the them at places indicated in the illustrations below:

In the wampmanager.tpl file we will need to replace 2 occurrences of the string "localhost" as "localhost:8080". Please replace them at places indicated in the illustrations below:

In Step 4 we will configure phpMyAdmin

You can also navigate to the main page.

Tweaking the Apache Configuration

Click on the WAMP icon in the system tray. Navigate to Apache -> httpd.conf file and open the file in any text editor.

Search (ctrl+F) for the string "Listen 80" in the file and replace it with "Listen 8080"

Search (ctrl+F) for the string "ServerName localhost" in the file and replace it with the string "ServerName localhost:8080"

In Step 3 we will configure WAMP manager.

You can also navigate to the main page.

Installing WAMP and the port 80 problem

You can download WAMP server from here.

The initial setup screen looks like this

Follow the instructions to install and once you are done installing, launch the WAMP server.

Technically if you don't have any other service running on port 80 you are good to start. However, if there is a service running on port 80, WAMP will not work when launched. Following is an illustration to depict the scenario when IIS is running on port 80.

In Step 2 we will configure Apache.

You can also navigate to the main page.

Configuring WAMP on port 8080

WAMP - Windows+Apache+MySQL+PHP is a commonly used testing platform for PHP developers.

By default, the WAMP package comes configured for port 80 on the localhost. This can be a problem for users who have IIS or other applications like skype running on port 80.

This tutorial focuses on configuring WAMP on port 8080 on the localhost. Why 8080? Technically it can be any legally allowed port number. 8080 is a common choice for the developers.

I have carefully divided this tutorial into the following sections with illustrations. Please click on the following links sequentially.

  1. Installing WAMP and the port 80 problem
  2. Tweaking the Apache Configuration
  3. Tweaking the WAMP manager configuration
  4. Tweaking phpMyAdmin configuration (long but simple process)
Finally, when you login to the phpMyAdmin interface you should have a screen that resembles the following:

Good luck developing in WAMP.