Support Contact:
Phone: +40 (21) 310.63.42; Forums: extendstudio.com/support

Setup a local testing server for Dreamweaver dynamic applications

How to set up a PHP&MySQL testing server on your PC or MAC

Do you need to create dynamic sites, for example generate menus or web charts based on database values or save a contact form in the database ?  To run dynamic web applications you need a server (Apache) a server-side language (PHP) and a database (Mysql). These are provided by the hosting companies for the live application (you should check yours) but if you build dynamic webpages using Dreamweaver then you’re also going to need a local testing server so you could test the application on your machine before deployment on the live server.

dynamic content

The hard way to create a WAMP testing environment on your PC

A PHP&MySQL server installed on a PC is called shortly WAMP (Windows-Apache-MySQL-PHP). You can install them manually: if you need just Apache you can get it from http://www.apache.org/ . But if you need also the MySQL database, you should download it and install it manually and the same goes for PHP.

The easy way to create a WAMP testing environment on your PC

The good news is that there are some one step installation programs that include Apache, MySQL and PHP. You also get phpMyAdmin – an easy to use interface for the database management.

XAMPP for Windows

Now if you’re on a windows environment you can try  XAMPP for Windows: http://www.apachefriends.org/en/xampp-windows.html

xamppThe latest XAMPP 1.7.3 includes:

  • Apache 2.2.14 (IPv6 enabled) + OpenSSL 0.9.8l
  • MySQL 5.1.41 + PBXT engine
  • PHP 5.3.1
  • phpMyAdmin 3.2.4
  • Perl 5.10.1
  • FileZilla FTP Server 0.9.33
  • Mercury Mail Transport System 4.72

XAMPP has many features, it even tells you how secure are your web pages and your database. Normally, you don’t have a password for the database, so it’s advisable to set a password for that, and a password for the working folder (accomplished via a .htacces file)  so your web pages won’t be visible in the network unless you provide the password.

After you set a password for the root admin user, for your web pages, and for the phpMyAdmin you can save them. Under the security tab in XAMPP you’ll see something like in the picture below:

xampp security

WAMPSERVER 2.0

Another solution for installing Apache, PHP and MySQL without any headaches is the WAMPSERVER 2.0:

wamp serverThe latest release of WampServer 2.0i [07/11/09] includes :
- Apache 2.2.11
- MySQL 5.1.36
- PHP 5.3.0
The difference can be seen quickly, it’s much simplified than XAMPP but you don’t have Perl, FileZilla  installed or the possibility to add the Tomcat add-on.

Wampserver it’s build for the beginner user to get use to dynamic web pages.

Also you don’t have the security verification, because wamp doesn’t check for security issues so your web pages and your databases and exposed to users from your network.

MAC alternative – MAMP

If you are on a Mac environment you can try the MAMP: http://www.mamp.info/en/index.html.

The MAMP includes Apache, Mysql and PHP. MAMP installs a local server environment in a matter of seconds on your Mac OS X computer.

mamp

Setting up the dynamic testing server in Dreamweaver

OK, if you did install one of the above solutions you have the testing environment set up. Now you need to setup Dreamweaver to work with dynamic sites.

Define a site

You need to have folder on your computer where the site files will be and in this folder you should create a new folder for each site. Let’s define a site in Dreamweaver.

Open Dreamweaver, go to Site, select “New Site…”, select Advanced, under Local Info, enter the name for your website. In Dreamweaver, under the local root folder enter the name of the site folder or simply browse for the folder you have created for the site.

new site

Go to the “testing server” tab, select server model : PHP MySQL, then from the Access drop down: Local/Network. The Testing server folder is the place where you’re files are going to be stored on the testing folder, so it’s best that you go to the default www folder inside the XAMPP or WAMSERVER installed. In XAMPP you can find the www folder in C:\Xampp\htdocs\. For WAMPSERVER go to c:\wamp\www . In the default www folder create a new folder and for the usability sake, give it the same name as the site.

testing_server

In the URL prefix the  location should be http://localhost/your_folder. If you misspelled the name of the site, Dreamweaver will show a popup window telling you that the name of the site doesn’t match with the URL prefix, like in the picture below.

error2

Creating a MySQL database connection in Dreamweaver

I will assume you have created a database via PhpMyAdmin – you can access PhpMyAdmin via XAMPP or WAMPSERVER interface.

Select from Dreamweaver “window” and then “databases” or press CTRL+SHIFT+F10 in order to display the databases tab. Press the + icon and select the MySQL Connection. A popup window will appear where you have to set the following items: connection name (put the site name there), MySQL server (default should be localhost), user name for the MySQL login, (usually the root user) and the password for the user. Dreamweaver tests the connection, and if everything is alright it should show you a popup window to select your database, like in the picture below. After that, press ok and you’re done.

mysql_connect

Creating the first PHP file

In the upper Dreamweaver menu go to File, select New file, select PHP, in the Layout: select <none>. Save the file “index.php” in your local folder “D:\local_folder\demo_site”.

Select view code, set the HTML title “First PHP Test Page” (between the <title> tags and in the body (between the <BODY> tags), enter the following code :

<?php
echo “Hello World !!!”;
?>

Let’s explain the code. In order to use PHP we have to place it in PHP tags, <?php   (your code goes here)  ?>, or  <?   (your code goes here)   ?> . The echo tag simply displays what you write inside the qoutes, in our case a simple Hello World text. In the end you have to put “;” in order to display the text, else it will give you an error. (Parse error: syntax error, unexpected T_ECHO, expecting ‘,’ or ‘;’ ). See the picture below.

first php

Now press F12 and in your browser you should see in the adress bar “http://localhost/demo_site/index.php” and the text should be like in the picture below.

Advanced PHP&MySQL applications

You are all set now to create dynamic applications in Dreamweaver and test them locally. You should learn how to create SQL queries to retrieve information from the database, and how to output the result using PHP. If you want a quick jumpstart you can use Dreamweaver extensions that generate PHP&MySQL code; for example here is a tutorial on how to create a simple menu using Creative DW Menus and a tutorial about creating a simple web chart with FusionCharts for Dreamweaver.

Facebook comments:



10 Responses to “Setup a local testing server for Dreamweaver dynamic applications”

  1. Setup a local testing server for Dreamweaver dynamic applications- Extend Studio Blog…

    Thank you for submitting this cool story – Trackback from Servefault.com…

  2. [...] Setup a local testing server for Dreamweaver dynamic applications … [...]

  3. Alain says:

    Cool guide. Thanks for sharing a very detailed steps in making a testing server.

  4. Sam says:

    Beautiful! Thank you. Where would mankind be without the free php + mySQL + Apachee combination?

  5. Eftegarie says:

    Beautiful! By the way, for those who want to let DreamWeaver CSx connect to an external online hosted MySQL database, be aware that NOT ALL hosting providers support externally incoming connections to yout internet databases.

    So in designtime this means Dreamweaver could not make that connection. I had to switch to another hosting sothat this would be possible. And you have to open port 3306 from your computer where Dreamweaver is running… Keep up the smart tutorials and greetings from Holland!

  6. Vix says:

    Hi I am using a testing server which is local and different to my remote server all working well until I want to upload to the remote server I have to disable the testing server to upload to the remote server? Is there a way of fixing this?
    thanks
    Vix

  7. Tasarimci says:

    Hi im using a mac, what would you recommend for mac users, is mamp any good?

  8. iliuta says:

    Yes mamp is the XAMPP or WAMP version for MAC

  9. Erwin says:

    Thnx guys for the input, I’m starting to develope local projects on my Mac and I need this guidelines, I’ve made it before on Win, but not in Mac.

    MAMP looks cooler than WAMPSERVER!!!!

    Regards

    Erwin

  10. Thanks for the blog loaded with such a lot of data. Stopping by your blog helped me to urge what i was yearning for.

Leave a Reply