Sams Teach Yourself PHP, MySQL and Apache in 24 Hours combines these
most popular open source Web development tools into one easy-to-understand book,
packaged with one easy-to-use Starter Kit CD. This book teaches the reader to
install, configure and set up the PHP scripting language, the MySQL database
system, and the Apache Web server. By the end of this book the reader will
understand how these technologies work, and more importantly, how they work
together to create a dynamic Web site. After creating a simple Web site using
these tools, the reader will be able to manage a simple mailing list, and to
create an online address book, shopping cart, and storefront.
Sams Teach Yourself PHP, MySQL and Apache in 24 Hours also teaches the
reader how to fine-tune Apache and MySQL, and covers simple Web server
security.
Table of Contents
Introduction.
Who Should Read This Book? How This Book Is
Organized. Conventions Used in This Book.
I. LAYING THE GROUNDWORK.
1. Installing and Configuring MySQL.
Current and Future Versions of MySQL. How to Get
MySQL. Installing MySQL on Linux/Unix. Installing MySQL on Windows.
Troubleshooting Your Installation. Basic Security Guidelines. Introducing the
MySQL Privilege System. Working with User Privileges. Summary. Q&A.
Workshop.
2. Installing and Configuring Apache.
Current and Future Versions of Apache. Choosing
an Installation Method. Installing Apache on Linux/Unix. Installing Apache on
Windows. Apache Configuration File Structure. Apache Log Files. Apache-Related
Commands. Starting Apache for the First Time. Troubleshooting. Summary. Q&A.
Workshop.
3. Installing and Configuring PHP.
Current and Future Versions of PHP. Building PHP
on Linux/Unix with Apache. Installing PHP Files on Windows. php.ini Basics.
Testing Your Installation. Getting Installation Help. The Basics of PHP Scripts.
Summary. Q&A. Workshop.
II. PHP LANGUAGE STRUCTURE.
4. The Building Blocks of PHP.
Variables. Data Types. Operators and
Expressions. Constants. Summary. Q&A. Workshop.
5. Flow Control Functions in PHP.
Switching Flow. Loops. Code Blocks and Browser
Output. Summary. Q&A. Workshop.
6. Working with Functions.
What Is a Function? Calling Functions. Defining
a Function. Returning Values from User-Defined Functions. Variable Scope. Saving
State Between Function Calls with the static Statement. More About Arguments.
Testing for the Existence of a Function. Summary. Q&A. Workshop.
7. Working with Arrays and Objects.
What Is an Array? Creating Arrays. Some
Array-Related Functions. Creating an Object. Object Inheritance. Summary.
Q&A. Workshop.
III. GETTING INVOLVED WITH THE CODE.
8. Working with Strings, Dates, and Times.
Formatting Strings with PHP. Investigating
Strings in PHP. Manipulating Strings with PHP. Using Date and Time Functions in
PHP. Summary. Workshop.
9. Working with Forms.
Creating a Simple Input Form. Accessing Form
Input with User-Defined Arrays. Combining HTML and PHP Code on a Single Page.
Using Hidden Fields to Save State. Redirecting the User. Sending Mail on Form
Submission. Working with File Uploads. Summary. Workshop.
10. Working with User Sessions.
Session Function Overview. Starting a Session.
Working with Session Variables. Passing Session IDs in the Query String.
Destroying Sessions and Unsetting Variables. Summary. Q&A. Workshop.
11. Working with Files and Directories.
Including Files with include(). Testing Files.
Creating and Deleting Files. Opening a File for Writing, Reading, or Appending.
Reading from Files. Writing or Appending to a File. Working with Directories.
Summary. Q&A. Workshop.
12. Working with the Server Environment.
Opening Pipes to and from Processes Using
popen(). Running Commands with exec(). Running Commands with system() or
passthru(). Summary. Q&A. Workshop.
13. Working with Images.
Understanding the Image-Creation Process.
Necessary Modifications to PHP. Drawing a New Image. Getting Fancy with Pie
Charts. Modifying Existing Images. Summary. Q&A. Workshop.
IV. PHP AND MYSQL INTEGRATION.
14. Learning the Database Design Process.
The Importance of Good Database Design. Types of
Table Relationships. Understanding Normalization. Following the Design Process.
Summary. Q&A. Workshop.
15. Learning Basic SQL Commands.
Learning the MySQL Data Types. Learning the
Table Creation Syntax. Using the INSERT Command. Using the SELECT Command. Using
WHERE in Your Queries. Selecting from Multiple Tables. Using the UPDATE Command
to Modify Records. Using the REPLACE Command. Using the DELETE Command.
Frequently Used String Functions in MySQL. Using Date and Time Functions in
MySQL. Summary. Q&A. Workshop.
16. Interacting with MySQL Using PHP.
Connecting to MySQL with PHP. Working with MySQL
Data. Summary. Workshop.
V. BASIC PROJECTS.
17. Managing a Simple Mailing List.
Developing the Subscription Mechanism.
Developing the Mailing Mechanism. Summary. Q&A. Workshop.
18. Creating an Online Address Book.
Planning and Creating the Database Tables.
Creating a Menu. Creating the Record Addition Mechanism. Viewing Records.
Creating the Record Deletion Mechanism. Adding Subentries to a Record. Summary.
Workshop.
19. Creating a Simple Discussion Forum.
Designing the Database Tables. Creating the
Input Forms and Scripts. Displaying the Topic List. Displaying the Posts in a
Topic. Adding Posts to a Topic. Summary.
20. Creating an Online Storefront.
Planning and Creating the Database Tables.
Displaying Categories of Items. Displaying Items. Summary. Workshop.
21. Creating a Shopping Cart Mechanism.
Planning and Creating the Database Tables.
Integrating the Cart with Your Storefront. Payment Methods and the Checkout
Sequence. Summary. Workshop.
22. Creating a Simple Calendar.
Building a Simple Display Calendar. Creating a
Calendar library. Summary. Q&A. Workshop.
23. Restricting Access to Your Applications.
Authentication Overview. Apache Authentication
Module Functionality. Using Apache for Access Control. Combining Apache Access
Methods. Limiting Access Based on HTTP Methods. Introducing Cookies. Setting a
Cookie with PHP. Restricting Access Based on Cookie Values. Summary. Q&A.
Workshop.
24. Logging and Monitoring Web Server
Activity.
Standard Apache Access Logging. Standard Apache
Error Logging. Managing Apache Logs. Logging Custom Information to a Database.
Summary. Q&A. Workshop.
25. Application Localization.
About Internationalization and Localization.
About Character Sets. Environment Modifications. Creating a Localized Page
Structure. Summary. Q&A. Workshop.
VI. ADMINISTRATION AND FINE TUNING.
26. Apache Performance Tuning and Virtual
Hosting.
Scalability Issues. Load Testing with
ApacheBench. Proactive Performance Tuning. Preventing Abuse. Implementing
Virtual Hosting. Summary. Q&A.
27. Setting Up a Secure Web Server.
The Need for Security. The SSL Protocol.
Obtaining and Installing SSL Tools. Managing Certificates. SSL Configuration.
Summary. Q&A.
28. Optimizing and Tuning MySQL.
Building an Optimized Platform. MySQL Startup
Options. Optimizing Your Table Structure. Optimizing Your Queries. Using the
FLUSH Command. Using the SHOW Command. Summary. Q&A. Workshop.
29. Software Upgrades.
Staying in the Loop. Upgrading MySQL. Upgrading
Apache. Upgrading PHP. Summary. Workshop.
VII. LOOKING TOWARD THE FUTURE.
30. Features and Backward Compatibility of
PHP 5.0.
What's Wrong With PHP 4? The New Object Model.
Additional New Features. So, When Should I Upgrade to PHP 5? Summary. Q&A.
31. Features and Backward Compatibility of
MySQL 4.1.
Using Subqueries. Internationalization
Enhancements. Additional New Functionality. Looking Further Ahead to MySQL 5.0.
Summary. Q&A. Workshop.
VIII. APPENDIX.
Appendix A: Installing MySQL, Apache, and PHP
from the CD-ROM.
Linux/Unix Installation. Windows Installation.
Troubleshooting.
Index.
《Sams Teach Yourself PHP, MySQL and Apache in 24 Hours》將這些最受歡迎的開源網頁開發工具結合成一本易於理解的書籍,並附有一個易於使用的入門套件CD。這本書教導讀者如何安裝、配置和設置PHP腳本語言、MySQL資料庫系統和Apache網頁伺服器。到本書結束時,讀者將了解這些技術如何運作,更重要的是,它們如何協同工作以創建一個動態的網站。在使用這些工具創建一個簡單的網站後,讀者將能夠管理一個簡單的郵件列表,並創建一個線上地址簿、購物車和商店前台。
《Sams Teach Yourself PHP, MySQL and Apache in 24 Hours》還教導讀者如何微調Apache和MySQL,並涵蓋簡單的網頁伺服器安全性。
目錄
引言
誰應該閱讀這本書?這本書的組織方式。本書中使用的約定。
I. 基礎建設
1. 安裝和配置MySQL
當前和未來版本的MySQL。如何獲取MySQL。在Linux/Unix上安裝MySQL。在Windows上安裝MySQL。故障排除安裝。基本安全指導。介紹MySQL權限系統。處理用戶權限。總結。問答。工作坊。
2. 安裝和配置Apache
當前和未來版本的Apache。選擇安裝方法。在Linux/Unix上安裝Apache。在Windows上安裝Apache。Apache配置文件結構。Apache日誌文件。與Apache相關的命令。首次啟動Apache。故障排除。總結。問答。工作坊。
3. 安裝和配置PHP
當前和未來版本的PHP。在Linux/Unix上使用Apache構建PHP。在Windows上安裝PHP文件。php.ini基礎。測試安裝。獲取安裝幫助。PHP腳本的基礎。總結。問答。工作坊。
II. PHP語言結構
4. PHP的基本組件
變數。數據類型。運算符和表達式。常量。總結。問答。工作坊。
5. PHP中的流程控制函數
流程切換。循環。代碼塊和瀏覽器輸出。總結。問答。工作坊。
6. 使用函數
什麼是函數?調用函數。定義函數。從用戶定義的函數返回值。變數範圍。使用static語句在函數調用之間保存狀態。更多關於參數的內容。測試函數的存在。總結。問答。工作坊。
7. 使用數組和對象
什麼是數組?創建數組。一些與數組相關的函數。創建對象。對象繼承。總結。問答。工作坊。
III. 參與代碼
8. 使用字符串、日期和時間
使用PHP格式化字符串。在PHP中調查字符串。使用PHP操作字符串。在PHP中使用日期和時間函數。總結。工作坊。
9. 使用表單
創建一個簡單的輸入表單。使用用戶定義的數組訪問表單輸入。在單個頁面上結合HTML和PHP代碼。使用隱藏字段保存狀態。重定向用戶。在表單提交時發送郵件。處理文件上傳。總結。工作坊。
10. 使用用戶會話
會話函數概述。啟動會話。處理會話變數。在查詢字符串中傳遞會話ID。銷毀會話和取消變數。總結。問答。工作坊。
11. 使用文件和目錄
使用include()包含文件。測試文件。創建和刪除文件。打開文件以進行寫入、閱讀或附加。從文件中讀取。寫入或附加到文件。處理目錄。總結。問答。工作坊。
12. 使用伺服器環境
使用popen()打開進程的管道。使用exec()運行命令。使用system()或passthru()運行命令。總結。問答。工作坊。
13. 使用圖像
理解圖像創建過程。對PHP的必要修改。繪製新圖像。使用圓餅圖進行美化。修改現有圖像。總結。問答。工作坊。
IV. PHP和MySQL整合
14. 學習資料庫設計過程
良好資料庫設計的重要性。表關係的類型。理解正規化。遵循設計過程。總結。問答。工作坊。
15. 學習基本SQL命令
學習MySQL數據類型。學習表創建語法。使用INSERT命令。使用SELECT命令。在查詢中使用WHERE。從多個表中選擇。使用UPDATE命令修改記錄。使用REPLACE命令。使用DELETE命令。在MySQL中經常使用的字符串函數。在MySQL中使用日期和時間函數。總結。問答。工作坊。
16. 使用PHP與MySQL互動
使用PHP連接MySQL。處理MySQL數據。總結。工作坊。
V. 基本項目
17. 管理簡單的郵件列表
開發訂閱機制。開發郵件機制。總結。問答。工作坊。
18. 創建線上地址簿
規劃和創建資料庫表。創建菜單。創建記錄添加機制。查看記錄。創建記錄刪除機制。向記錄添加子項。總結。工作坊。
19. 創建簡單的討論論壇
設計資料庫表。創建輸入表單和腳本。顯示主題列表。顯示主題中的帖子。向主題添加帖子。總結。
20. 創建線上商店前台
規劃和創建資料庫表。顯示商品類別。顯示商品。總結。工作坊。
21. 創建購物車機制
規劃和創建資料庫表。將購物車與商店前台整合。支付方式和結帳流程。總結。工作坊。
22. 創建簡單的日曆
構建簡單的顯示日曆。創建日曆庫。總結。問答。工作坊。
23. 限制對應用程序的訪問
身份驗證概述。Apache身份驗證模塊功能。使用Apache進行訪問控制。結合Apache訪問方法。根據HTTP方法限制訪問。介紹Cookies。使用PHP設置Cookie。根據Cookie值限制訪問。總結。問答。工作坊。
24. 記錄和監控網頁伺服器活動
標準Apache訪問日誌。標準Apache錯誤日誌。管理Apache日誌。將自定義信息記錄到資料庫。總結。問答。工作坊。
25. 應用程序本地化
關於國際化和本地化。關於字符集。環境修改。創建本地化頁面結構。總結。問答。工作坊。
VI. 管理和微調
26. Apache性能調整和虛擬主機
可擴展性問題。使用ApacheBench進行負載測試。主動性能調整。防止濫用。實施虛擬主機。總結。問答。
27. 設置安全的網頁伺服器
安全性的需求。SSL協議。獲取和安裝SSL工具。管理證書。SSL配置。總結。問答。
28. 優化和調整MySQL
構建優化平台。MySQL啟動選項。優化表結構。優化查詢。使用FLUSH命令。使用SHOW命令。總結。問答。工作坊。
29. 軟體升級
保持更新。升級MySQL。升級Apache。升級PHP。總結。工作坊。
VII. 展望未來
30. PHP 5.0的特性和向後相容性
PHP 4有什麼問題?新的物件模型。其他新特性。那麼,我什麼時候應該升級到PHP 5?總結。問答。
31. MySQL 4.1的特性和向後相容性
使用子查詢。國際化增強。其他新功能。展望MySQL 5.0。總結。問答。工作坊。
VIII. 附錄
附錄A:從CD-ROM安裝MySQL、Apache和PHP
Linux/Unix安裝。Windows安裝。故障排除。
索引。