Configuring Firefox for Chrome and a Server - Configuring the Server (Page 4 of 4 )
We first must install a web server on our local machine; for this application we install Apache. Once the web server is installed and running, we should see the startup page shown in Figure4-6 when we enter http://localhost/ in a browser’s URL field.
Apache is managed through the text file httpd.conf. On Unix systems, this is located in the /etc/http/ directory, whereas Windows systems will put this file in Apache’s conf directory. You can edit the file using a text editor.
Figure 4-6. Apache startup page
The DocumentRoot directory is used to select the home directory for serving web pages. That entry, in httpd.conf, is operating-system-specific, and depends on the options we have specified during the installation:
If the installation was performed correctly, an entry should provide Apache with information about the directories served:
Although we don’t need to make any changes to the httpd.conf file, we must note what these entries are in order to place our Common Gateway Interface (CGI) scripts in the correct directory. We will use the PHP scripting engine to provide the logic for our CGI.
We can install the PHP binaries into any directory. In a Windows environment, an example would be C:\php\, whereas a Unix install may be in /usr/local/php/. Regardless, we must make changes to Apache’s httpd.conf to properly serve PHP-generated output.
Depending on the version of PHP installed, entries in Apache’s configuration file will take one of two forms. In the first:
The second form would instruct Apache to use an external configuration file to load the PHP libraries:
Regardless of the particular PHP version and operating system, we can check the installation by using a text editor to write a simple PHP script to echo version information:
<?php phpinfo(); ?>
Save the preceding text as test.php in your Apache document root directory:
Now type the URL into a browser to yield a page that looks like Figure4-7.
Figure 4-7.Testing PHP installation
With a PHP engine running on our server, we can now conduct some simple connection tests between our application and the server.
The Client/Server Protocol
This approach will use the XMLHttpRequest object to send inquiries to our PHP server, and PHP scripts to return textual responses to the client.
ConventionalPOSTmessages from a browser to a server result in the server generating an entire page to be displayed by the browser. This process is what causes many web applications to “freeze up” after the user presses a form submission button and waits for a response.
We will first use a simpler protocol to issue a request for data resembling “classic” client/server operations. The server provides only data; the client determines what to do with the data and how to render the interface.
Please check back next week for the continuation of this article.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.