Setting Up the Application Server

Team-Fly    

Macromedia® DreamWeaver® MX Unleashed
By Matthew Pizzi, Zak Ruvalcaba
Table of Contents
Chapter 17.  Web Application Preparation


The application server consists of the middleware and database. Regardless of the options you use in both cases, both components of the application server need to be able to talk to each other and to the Web server.

What this means is that you must have a Web server up and running first before you install any middleware or database software. It also means that after you get any middleware and database components working, you'll need to configure your Web server software to recognize and talk to these components.

The following sections walk you through these installation and configuration procedures.

PHP/MySQL

PHP and MySQL are usually installed at the same time. The following information should get you up and running on Apache or IIS.

Installing PHP on Apache 1.3.x or 2.0.x

To install PHP and get it working with Apache, follow these instructions after you've installed Apache:

  1. Go to http://www.php.net and download the latest stable Windows binaries. This is usually packaged as a ZIP archive.

  2. After the ZIP archive downloads, create a \php directory right off your hard drive's root (that is, D:\php or C:\php).

    WARNING

    It's important that your PHP directory not have spaces in its name; otherwise, Apache and other Web servers might crash.

  3. Extract the contents of the ZIP archive to this \php directory.

  4. Open the \php directory and rename the php.ini-recommended file to php.ini.

  5. Open the php.ini file in a text editor and find the extension_dir variable in the file. Change this line so that the variable is set to C:\php. The line should look like this when you're done:

     extension_dir = c:\php  

    NOTE

    In some cases, you'll have to use forward slashes (/) instead of backslashes (\) when editing configuration files; sometimes it's the other way around. Sometimes you put quotes around the values set for variables, and sometimes not. Confusing, isn't it? Just be sure to follow these directions to the letter.

  6. Save your changes to the php.ini file and copy it to your %WINDOWS% directory. On NT/2000/XP machines, this directory is C:\winnt. On 95/98/ME machines, this directory is C:\windows.

  7. Copy the \php\php4dts.dll file to either the \windows\system or \winnt\system32 directory on your machine.

  8. Now it's time to configure Apache to work with PHP. Open the \program files\apache group\apache2\conf\httpd.conf file in a text editor and make the following changes:

    • Search for LoadModule and then add the following line at the end of the LoadModule section:

       LoadModule php4_module c:/php/sapi/php4apache.dll  
    • Search for AddType and then add the following line at the end of the AddType section:

       AddType application/x-httpd-php .php .phtml  
    • Search for ScriptAlias and then add the following two lines at the end of the ScriptAlias section:

       ScriptAlias /php/ "c:/php"  Action application/x-httpd-php "/php/php.exe " 
  9. Save your changes to the httpd.conf file.

  10. Stop the Apache Web Server by clicking Start, Apache HTTP Server, Control Apache, Stop.

  11. Restart the Apache Web Server by clicking Start, Apache HTTP Server, Control Apache, Restart.

  12. You can test your Apache Web Server setup by creating a test file called index.php. Insert the following line of code into the file:

     <p>My first php: <? echo "hello world!"; ?>  
  13. Save the file to the htdocs directory of Apache and point your browser to http://localhost/index.php. If you see the "hello world!" message, PHP and Apache are talking to each other.

Installing PHP on IIS

To install PHP on an NT/2000/XP Server running IIS 4 or later, you have two options for setup: using the CGI binary (php.exe) or the ISAPI module.

ISAPI or CGI?

When given the choice, choose ISAPI over CGI. It's faster, more reliable, and more secure. However, I've included directions for CGI setup in case your version of Windows or IIS doesn't support ISAPI access.

In either case, you'll need to do the following:

  1. Go to http://www.php.net and download the latest stable Windows binaries.

  2. After the ZIP archive downloads, create a \php directory right off your hard drive's root (that is, D:\php or C:\php).

    WARNING

    It's important that your PHP directory not have spaces in its name; otherwise, Apache and other Web servers might crash.

  3. Extract the contents of the ZIP archive to this \php directory.

  4. Start the Microsoft Management Console (under Control Panel, Administrative Tools) and right-click the Web Server node.

  5. Select Properties.

To use the CGI binary:

  1. Click the Configuration button under Home Directory, Virtual Directory, or Directory, and then enter the App Mappings tab.

  2. Click Add, and in the Executable box, enter C:\php\php.exe.

  3. In the Extension box, type the file name extensions you want associated with PHP scripts (.php and .phtml are two good ones). You'll have to enter them in one at a time.

  4. Stop IIS completely (NET STOP iisadmin).

  5. Restart IIS (NET START w3svc).

To use the ISAPI module:

  1. Click the Configuration button under Home Directory. Add a new entry to the Application Mappings.

  2. Enter C:\php\php4isapi.dll as the Executable.

  3. Supply .php and .phtml as Extensions.

  4. Leave Method exclusions blank.

  5. Check the Script engine check box.

  6. Stop IIS completely (NET STOP iisadmin).

  7. Restart IIS (NET START w3svc).

You can test the PHP installation by creating a simple PHP file, saving it to the \inetpub\wwwroot directory, and then pointing your browser at that file.

Installing MySQL

MySQL is available as free software from http://www.mysql.com. Follow these instructions to install and configure MySQL with PHP.

  1. Go to http://www.mysql.com/downloads and download the latest stable release for Windows. It is a ZIP archive between 12MB and 15MB in size, so it will take some time to download.

  2. After the ZIP archive downloads, extract the files to a temporary directory on your desktop.

  3. Double-click the setup.exe file.

  4. Click Next to accept the legal disclaimers and terms of usage.

  5. Accept C:\mysql as the default directory for MySQL and click Next.

  6. Select Typical installation and click Next.

  7. Click Finish.

  8. After the installation completes, create a my.ini file in Notepad (or other text editor) and populate it with the following data:

     [mysqld]  basedir=c:/mysql datadir=c:/mysql/data 
  9. Save this my.ini file in either C:\windows or C:\winnt, depending on your Windows version.

  10. Click the Start button and then click Run. Type Command and click OK. This opens a C:\prompt window.

  11. Type the following commands into the window:

     cd \mysql\bin  mysqld  standalone 

    The first command changes the directory to the mysql binaries directory, and the second command starts the mysql server in standalone mode.

  12. Using the Start button, create a second C:\prompt window. Change directories to the \mysql\bin directory and type:

     mysql  
  13. This command starts MySql in interactive mode. You should see the following on your screen:

     Welcome to the MySQL monitor. Commands end with ; or \g.  Your MySQL connection id is 1 to server version: 3.23.52-max-debug Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> 
Testing MySQL

Now you can issue commands directly to MySQL. PHP should also be able to communicate with MySQL. To test this, create a test table in MySQL:

  1. Switch to the built-in test database by typing the following command:

     use test  
  2. Create a simple two-field database called mytest by typing the following lines, one line at a time into MySQL:

     create table mytest (  name varchar(32), birthday date ); 
  3. Add a few records to this new database, one at a time:

     insert into mytest (name,birthday)  values ("tom", "1971-06-05"); insert into mytest (name,birthday) values ("john", "1944-01-05"); 
  4. Create the following simple PHP file and save it to your Web server's docroot:

     <html>  <title>test php</title> <body> <? //first, connect to db if (!($mylink = mysql_connect( "localhost", "root", ""))) {     print "<h3>could not connect to database</h3>\n";     exit; } mysql_select_db( "test"); //now issue the sql query $sql = "select * from mytest"; $result = mysql_query($sql); while (list($name, $birthday) = mysql_fetch_array($result)) {     echo "$name's birthday is <b>$birthday</b>.<br>"; } ?> </body> </html> 
  5. Point your browser to this file. If you see a list of names and birthdays, PHP was able to connect to the MySQL Server. You're in business.

SQL Server

Although Microsoft's SQL Server isn't a free, open-source tool, you can get a 120-day trial download at http://www.microsoft.com/sql/evaluation/trial.

Before you can install and run the software, make sure that you're logged in to your system as an administrator. Then see if you meet some basic system requirements:

  • Microsoft Windows 2000 Server with Service Pack 1 (SP1) or later

  • Microsoft Windows NT Server 4.0 with Service Pack 5 (SP5)

  • Microsoft Windows XP Professional

  • Microsoft Windows XP Home Edition

  • Microsoft Windows 2000 Professional

After you sign up for the 120-day trial, download the package and follow these instructions:

  1. Double-click the executable package.

  2. Select SQL Server 2000 Components.

  3. Select Install Database Server. This starts the SQL Server Installation Wizard. At the Welcome screen, click Next.

  4. In the Computer Name dialog box, you can leave Local Computer as the default option for your system. Click Next.

    NOTE

    If you are installing SQL Server on a remote computer, click Remote Computer and type a computer name; you also can click Browse to locate a remote computer.

  5. In the Installation Selection dialog box, click Create a New Instance of SQL Server, or install Client Tools, and then click Next.

  6. Click through the software licensing and user information confirmation screens.

  7. Click Server and Client Tools in the Installation Definition dialog box and then click Next.

  8. In the Instance Name dialog box, choose the Default instance and then click Next.

  9. Choose Typical as the setup type, and then click Next.

  10. In the Service Accounts dialog box, accept the default settings, enter your domain password, and then click Next.

  11. In the Authentication Mode dialog box, accept the default setting and click Next.

  12. Click Next to start copying files.

  13. After the installation is complete, select the computer restart option and click Finish.

The application binaries for SQL Server are located at \Program Files\Microsoft SQL Server\Mssql\Binn. You can start SQL Server by double-clicking the database server.

You can also access SQL Server by clicking Start, Microsoft SQL Server.

ColdFusion

ColdFusion MX is available on the Macromedia Studio MX CD-ROM. TO install ColdFusion, follow these steps:

  1. Place the Studio MX CD-ROM into the CD-ROM drive.

  2. On the splash screen, click ColdFusion MX Developer Edition. ColdFusion MX prepares the installer.

  3. Click Next on the Welcome screen.

  4. Accept the terms and then click Next.

  5. Enter your name, company name (if applicable), and the ColdFusion MX serial number. Then click Next.

  6. Select Complete Installation and click Next.

  7. Select a Web server from the list and click Next.

    WARNING

    Macromedia strongly recommends that you use the standalone Web server that comes with ColdFusion MX.

  8. Accept the default Webroot folder location and click Next.

  9. Select a password for the ColdFusion Administrator and click Next.

  10. Click Install to start copying files.

  11. After the installation process ends, click Finish and restart your system when prompted.

After it's installed, ColdFusion MX runs as a service. You can stop, start, or configure this service by clicking the Start button and then selecting Settings, Control Panel, Administrative Tools, Services. You can then select Macromedia ColdFusion MX Application Server from the list to access commands.

You can start the ColdFusion Administrator by choosing Start, Macromedia ColdFusion MX, Administrator. The Administrator is a browser-based tool that lets you access all server features and configuration settings.

Tomcat

Tomcat is a JSP/Servlet engine used to serve up JSP pages. It is available as part of the Apache Jakarta project. This project includes various implementations of Tomcat that follow the different Servlet and JSP specifications.

Before you can download Tomcat, though, you need to have a Java Development Kit (JDK). You can find a JDK by going to Sun's http://java.sun.com/j2se page and downloading a version 1.2 (or later) release.

Install the JDK according to the instructions included with the release. Be sure to install the JDK in a \JDK folder in your C:\or D:\drive root.

Finally, open a shell window (using Start, Run) and set a JAVA_HOME variable pointing to the directory in which you installed the JDK:

 set JAVA_HOME=\jdk  

After you've set up the JDK, you can download Tomcat 3.3.1 (this release follows the JSP 1.1 and Servlet 2.0 specifications), found on the downloads page at http://jakarta.apache.org/downloads/binindex.html.

WARNING

Be sure to pull down a Release build of Tomcat 3.3.1. Release builds are the most stable code packages.


Next, follow these instructions:

  1. Download the ZIP file containing the Tomcat binaries for Windows.

  2. Create a \tomcat directory off your C:\ or D:\drive root.

  3. Extract the contents of the ZIP to this \tomcat directory. This should create a subdirectory named jakarta-tomcat-3.3.1.

  4. Open a shell window by clicking the Start button and choosing Run; then type command and press the Enter key.

  5. Change directories to the subdirectory created in step 3.

  6. In the shell window, type the following command:

     set TOMCAT_HOME=tomcat\jakarta-tomcat-3.3.1  
  7. You can browse Tomcat services by visiting http://localhost:8080.

Getting Tomcat and Apache to Cooperate

After you have Tomcat installed, you will need to get Apache and Tomcat working together. To do this, you must make some changes in Apache's httpd.conf file. Include the following text to the end of that file, save it, and restart Apache:

 # This loads the jserv module--used by Tomcat as an apache adapter  LoadModule jserv_module libexec/mod_jserv.so <IfModule mod_jserv.c> # once the module loads, set up jserv parameters ApJServManual on ApJServSecretKey DISABLED ApJServMountCopy on ApJServLogLevel notice # sets the base communication protocol ApJServDefaultProtocol ajpv12 # here are the default locations of host and port ApJServDefaultHost localhost ApJServDefaultPort 8007 # the following redirects all Web server paths that # start with /jsp to Tomcat ApJServMount /jsp /root # You can also listen on a specific host and port: # ApJServMount /examples ajpv12://hostname:port/root </IfModule> 

    Team-Fly    
    Top


    Macromedia Dreamweaver MX Unleashed
    Macromedia Dreamweaver MX 2004 Unleashed
    ISBN: 0672326310
    EAN: 2147483647
    Year: 2002
    Pages: 321

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net