B.3 What's Needed for This Book
This section shows you how to download and install our example
database, all of the book code examples, the sample online winestore
application, and the additional packages that are used throughout the
book.
B.3.1 Installing PEAR Packages
The
optional PEAR package HTML_Template_IT is
required. It is needed to work with Chapter 7
and all later chapters.
Detailed instructions to install optional packages can be found in
Chapter 7. You'll also find a
discussion there about how to find about, install, and upgrade
packages.
In brief, after you've installed EasyPHP, carry out
the following steps:
If you're not already, connect to the Internet. Run a command window. Do this by selecting the Run option from the
Start Menu and typing command and then
pressing OK. A window will appear that shows a prompt. Into the command window, type: C:\> C:\progra~1\easyph~1\php\pear\pear.bat install HTML_Template_IT
Press Enter. The package will download and install. If something goes
wrong, check that you've completed Steps 18 to 24 in
Section B.2. Now, check if upgrades of the core packages used in this book are
available. Into the command window, type: C:\> C:\progra~1\easyph~1\php\pear\pear.bat upgrade PEAR
Press Enter and the package will be downloaded if required. Repeat Step 4, but type: C:\> C:\progra~1\easyph~1\php\pear\pear.bat upgrade Date
Repeat Step 4, but type: C:\> C:\progra~1\easyph~1\php\pear\pear.bat upgrade DB
Repeat Step 4, but type: C:\> C:\progra~1\easyph~1\php\pear\pear.bat upgrade Mail
B.3.2 Installing the Code Examples
The example PHP scripts from this book
are available from our book's web site, http://www.webdatabasebook.com. In this
section, we show you how to install them for use on your machine. The
winestore application isn't installed in this
section; see Section
B.3.5 for instructions.
To install the example scripts, follow these steps:
Using a browser, download the file http://www.webdatabasebook.com/examples.zip
into a temporary directory such as
C:\windows\temp. To start, you need to configure your Apache web server so that it
won't show users the content of the
.inc include files if they're
retrieved with a web browser. There are several ways to do this, but
the simplest is to edit your httpd.conf
configuration file in C:\Program
Files\EasyPHP1-7\apache\conf. Open the httpd.conf file in an editor such as
Notepad or WordPad, and add this to the end of the file: <Files ~ "\.inc$">
Order allow,deny
Deny from all
Satisfy All
</Files>
Save the file and exit the editor. You now need to restart your
Apache server by double-clicking the E icon in the taskbar, pressing
the Apache button, and selecting Restart from the drop-down list. Now, create a directory in your Apache document root to store the
examples, and copy the downloaded file to that location. To do this, use Windows Explorer to create a new folder below
C:\Program Files\EasyPHP1-7\www with the name
wda, and then copy and paste the file
C:\windows\temp\wda.zip into that folder. Unzip the wda.zip examples in their new
directory using your Zip program. You can do this with a double-click on the
wda.zip icon and then using your Zip program to
extract the files into C:\Program
Files\EasyPHP1-7\www\wda. Edit the file db.inc in the
wda directory and modify the lines beginning
with $username and $password so
that fred and
shhh are replaced with the username and
password you chose for your user when installing MySQL: <?php
$hostName = "127.0.0.1";
$databaseName = "winestore";
$username = "fred";
$password = "shhh";
Save the file and exit the editor. You should now be able to load the example list by requesting the
following URL with a web browser running on the same machine as the
web server: http://127.0.0.1/wda/. Test the examples from Chapter 2 to Chapter 4, and they should work. You'll find that some of the examples from Chapter 6 onwards run only if the
winestore database has been loaded into the
MySQL DBMS by following the instructions in the next section. In
addition, most examples from Chapter 7 onwards
work only if you've installed the PEAR package
HTML_Template_IT.
B.3.3 Installing the PDF PHP Library
To work with the PDF PHP library in
Chapter 13, you need to download the class
files. To do this, follow these steps:
Visit the web site http://ros.co.nz/pdf/. From the Downloads section, choose the link to the Zip file that
contains the class, sample, and the required font metric files. Save
the file in a temporary directory such as
c:\windows\temp. Unzip the download file into an install directory using your Zip
program. If you're only planning to use the library
with this book, then a good location is C:\Program
Files\EasyPHP1-7\www\wda. This is a directory
that's used in the previous section for the code
examples. An alternative approach is to install the files into a shared file
location such as C:\Program Files\EasyPHP1-7\PDF
PHP. Then, edit your php.ini file and
include the directory at the end of the
include_path directive. This allows you to include
the path in a PHP script using only the class name and without
specifying the directory.
B.3.4 Loading the Winestore Database
A local copy of the
winestore database is required to test the SQL
examples in Chapter 5, to test some of the web
database application examples in Chapter 6 to Chapter 13, and to use
the sample winestore application described in Chapter 16 to Chapter 20. MySQL must be
installed and configured before the winestore
database can be loaded.
The steps to load the winestore database are as
follows:
Using a web browser, download the file http://www.webdatabasebook.com/database.zip
into a temporary directory such as
C:\windows\temp. Uncompress the winestore database in any directory. You can do this
with your Zip utility and save the file in the
C:\windows\temp directory. Run the MySQL command-line interpreter using the root username and
the password you set, and load the
winestore database. You do this by choosing the Run option in the Start menu and typing: "C:\Program Files\EasyPHP1-7\mysql\bin\mysql.exe" -uroot -ppassword
Then, load the database using: mysql> source C:\windows\temp\winestore.data
Be patient, this may take a while. After the loading is complete (it may take a while) the database can
be tested by running a query. To do this, type: mysql> SELECT * FROM region;
This should produce the following list of wine regions as output: +-----------+---------------------+
| region_id | region_name |
+-----------+---------------------+
| 1 | All |
| 2 | Goulburn Valley |
| 3 | Rutherglen |
| 4 | Coonawarra |
| 5 | Upper Hunter Valley |
| 6 | Lower Hunter Valley |
| 7 | Barossa Valley |
| 8 | Riverland |
| 9 | Margaret River |
| 10 | Swan Valley |
+-----------+---------------------+
The winestore database has now been loaded and
tested.
B.3.5 Installing the Winestore Application
The sample online winestore
application is available from our book's web site,
http://www.webdatabasebook.com.
In this section, we show you how to install it on your machine.
We assume you've installed the
winestore database by following the instructions
in the previous section. We also assume you've
already followed the instructions in this chapter to install EasyPHP.
Follow these steps:
Using a browser, download the file http://www.webdatabasebook.com/wda2-winestore.zip
into the directory C:\Program
Files\EasyPHP1-7\www. If you haven't configured your Apache web server so
that it won't show users the content of the
.inc include files, follow Step 2 in
Section B.3.2. Unzip the wda2-winestore.zip code in the
document root directory using your Zip program. This will create the
subdirectory wda2-winestore. You can usually do
this by double-clicking on the
wda2-winestore.zip icon and using your Zip
program to extract the files into c:\Program
Files\EasyPHP1-7\www\. Edit the file wda2-winestore/includes/db.inc and
modify the lines beginning with $username and
$password so that fred
and shhh are replaced with the username
and password you selected when configuring MySQL: <?php
$hostname = "127.0.0.1";
$databasename = "winestore";
$username = "fred";
$password = "shhh";
Save the file and exit the editor. Edit the file
wda2-winestore/includes/winestore.inc and locate
the following three lines: // define("D_INSTALL_PATH", "c:/progra~1/easyph~1/www");
// define("D_INSTALL_PATH", "/Library/WebServer/Documents");
define("D_INSTALL_PATH", "/usr/local/apache2/htdocs");
Uncomment the first line and comment-out the third so that you have
the following: define("D_INSTALL_PATH", "c:/progra~1/easyph~1/www");
// define("D_INSTALL_PATH", "/Library/WebServer/Documents");
// define("D_INSTALL_PATH", "/usr/local/apache2/htdocs");
Save the file and quit the editor. Note that forward slashes are used in the Microsoft Windows path. You should now be able to load the application index by requesting
the following URL with a web browser running on the same machine as
the web server: http://127.0.0.1/wda2-winestore/. Click on
the Use the Application link and you should be able to use the
application.
|
No comments:
Post a Comment