1. Trang chủ
  2. » Công Nghệ Thông Tin

Setting Up a PHP-MySQL Development Environment

25 355 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 25
Dung lượng 1,82 MB

Nội dung

34 How to Do Everything with PHP & MySQL HowTo8 (8) / How to Do Everything with PHP & MySQL/Vaswani/225795-4/Chapter 2HowTo8 (8) / How to Do Everything with PHP & MySQL/Vaswani/225795-4/Chapter 2 The PHP configuration process is extremely sophisticated, enabling you to control many aspects of PHP’s behavior. To see a complete list of available options, use the command ./configure --help, and visit http://www.php.net/manual/en/configure.php for detailed explanations of what each option does. 7. Next, compile and install PHP using make and make install: [root@host]# make [root@host]# make install Figure 2-7 illustrates what you might see during the compilation process. PHP should now be installed to /usr/local/php5/. 8. The next step in the installation process consists of configuring Apache to correctly recognize requests for PHP pages. This is accomplished by opening the Apache configuration file, httpd.conf (which is found in the conf/ subdirectory of the Apache installation directory), in a text editor and adding the following line to it. AddType application/x-httpd-php .php FIGURE 2-6 Configuring the PHP source tree ch02.indd 34 2/2/05 3:06:32 PM TEAM LinG HowTo8 (8) CHAPTER 2: Setting Up a PHP-MySQL Development Environment 35 HowTo8 (8) 9. Save the changes to the file. Also, check to make sure this line appears somewhere in the file: LoadModule php5_module libexec/libphp5.so The PHP installation process should automatically add this line to the file, but it has been known to fail. If you don’t see it, add it yourself. 10. Start the Apache server by manually running the apachectl script. [root@host]# /usr/local/apache/bin/apachectl start Apache should start up normally. Figure 2-8 demonstrates what you will see as the server starts up. Once installation is successfully completed and the server has started, move down to the section entitled “Testing Apache and PHP” to verify that all is functioning as it should. Installing on Windows Compiling applications on Windows is a challenging process, especially for novice developers. With this in mind, it is advisable for Windows users to focus instead on installing and configuring prebuilt binary releases of MySQL, PHP, and Apache, FIGURE 2-7 Compiling PHP 2 ch02.indd 35 2/2/05 3:06:32 PM TEAM LinG 36 How to Do Everything with PHP & MySQL / How to Do Everything with PHP & MySQL/Vaswani/225795-4/Chapter 2 / How to Do Everything with PHP & MySQL/Vaswani/225795-4/Chapter 2 instead of attempting to compile them from source code. These releases can be downloaded from the web sites listed in the previous section. They are to be installed one after another, as outlined in the following subsections. Installing MySQL The binary distribution of MySQL for Windows comes with an automated installer, which enables you to get MySQL up and running on your Windows system in just a few minutes. 1. Log in as an administrator (if you’re using Windows NT or Windows 2000) and unzip the distribution archive to a temporary directory on your system. After extraction, your directory should look something like Figure 2-9. 2. Double-click the setup.exe file to begin the installation process. You should see a welcome screen (Figure 2-10). 3. Select the directory in which MySQL is to be installed, for example, c:\program files\mysql\ (Figure 2-11). FIGURE 2-8 Apache server startup messages ch02.indd 36 2/2/05 3:06:32 PM TEAM LinG HowTo8 (8) CHAPTER 2: Setting Up a PHP-MySQL Development Environment 37 HowTo8 (8) FIGURE 2-9 The directory structure created on unpackaging a MySQL binary distribution for Windows FIGURE 2-10 Beginning MySQL installation on Windows 2 ch02.indd 37 2/2/05 3:06:32 PM TEAM LinG 38 How to Do Everything with PHP & MySQL HowTo8 (8) / How to Do Everything with PHP & MySQL/Vaswani/225795-4/Chapter 2HowTo8 (8) / How to Do Everything with PHP & MySQL/Vaswani/225795-4/Chapter 2 FIGURE 2-11 Selecting the MySQL installation directory 4. Select the type of installation required (Figure 2-12). Most often, a Typical Installation will do. If you’re the kind who likes tweaking default settings, however, or if you’re short of disk space, select the Custom Installation option, and decide which components of the package should be installed (Figure 2-13). 5. MySQL should now begin installing to your system (Figure 2-14). 6. Once installation is complete, you should see a screen like Figure 2-15. You should now be able to start the MySQL server by diving into the bin\ subdirectory of your MySQL installation and launching the WinMySQLadmin tool (winmysqladmin.exe). This tool provides a graphical user interface to MySQL configuration, and is by far the simplest way to configure MySQL on Windows systems. The first time you start WinMySQLadmin, you will be asked for the name and password of the user the server should run as (Figure 2-16). Once this information is entered, WinMySQLadmin will automatically create the MySQL configuration file (named my.ini) and populate it with appropriate values for your system. You can edit these values at any time using the my.ini Setup section of the WinMySQLadmin application (see Figure 2-17). ch02.indd 38 2/2/05 3:06:33 PM TEAM LinG HowTo8 (8) CHAPTER 2: Setting Up a PHP-MySQL Development Environment 39 HowTo8 (8) FIGURE 2-12 Selecting the MySQL installation type FIGURE 2-13 Selecting components for a custom MySQL installation 2 ch02.indd 39 2/2/05 3:06:33 PM TEAM LinG 40 How to Do Everything with PHP & MySQL HowTo8 (8) / How to Do Everything with PHP & MySQL/Vaswani/225795-4/Chapter 2HowTo8 (8) / How to Do Everything with PHP & MySQL/Vaswani/225795-4/Chapter 2 You can also start the MySQL server by directly launching the mysqld. exe or mysqld-nt.exe binaries from the bin\ subdirectory of your MySQL installation. FIGURE 2-14 MySQL installation in progress FIGURE 2-15 MySQL installation successfully completed ch02.indd 40 2/2/05 3:06:33 PM TEAM LinG HowTo8 (8) CHAPTER 2: Setting Up a PHP-MySQL Development Environment 41 HowTo8 (8) FIGURE 2-16 Setting the WinMySQLadmin username and password FIGURE 2-17 Editing MySQL configuration on Windows via WinMySQLadmin 2 ch02.indd 41 2/2/05 3:06:34 PM TEAM LinG 42 How to Do Everything with PHP & MySQL HowTo8 (8) / How to Do Everything with PHP & MySQL/Vaswani/225795-4/Chapter 2HowTo8 (8) / How to Do Everything with PHP & MySQL/Vaswani/225795-4/Chapter 2 Once the server has started, WinMySQLadmin will minimize to a green icon in your Windows taskbar notification area. You can now proceed to test the server, as described in the section “Testing MySQL,” to ensure that everything is working as it should. You can bring the WinMySQLadmin application back to the foreground at any time by right-clicking its taskbar icon and selecting the Show Me option from the menu that pops up (see Figure 2-18). Installing Apache Once MySQL is installed, the next step is to install the Apache Web server. On Windows, this is a point-and-click process, similar to that used when installing MySQL. 1. Begin by double-clicking the Apache installer to begin the installation process. You should see a welcome screen (Figure 2-19). 2. Read the license agreement and accept the terms to proceed (Figure 2-20). 3. Read the descriptive information and proceed to enter basic server information and the e-mail address to be displayed on error pages (Figure 2-21). 4. Select the type of installation required (Figure 2-22). If you like, select the Custom Installation option to decide which components of the package should be installed (Figure 2-23). 5. Select the location to which Apache should be installed, for example, c:\program files\apache group\ (Figure 2-24). FIGURE 2-18 Using the WinMySQLadmin system tray icon ch02.indd 42 2/2/05 3:06:34 PM TEAM LinG HowTo8 (8) CHAPTER 2: Setting Up a PHP-MySQL Development Environment 43 HowTo8 (8) FIGURE 2-19 Beginning Apache installation on Windows FIGURE 2-20 Apache licensing terms 2 ch02.indd 43 2/2/05 3:06:34 PM TEAM LinG [...]... Windows, simply add a link to the mysqld.exe and apache.exe server binaries to your Startup group 2 Summary As popular open-source applications, MySQL, Apache, and PHP are available for a wide variety of platforms and architectures, in both binary and source form This chapter demonstrated the process of installing and configuring these software components to create a PHP-MySQL development environment on... scripts with appropriate parameters from your system’s bootup and shutdown scripts in the /etc/rc.d/* hierarchy TEAM LinG CHAPTER 2: Setting Up a PHP-MySQL Development Environment 55 On Windows On Windows, you can use the WinMySQLadmin utility to start and shut down MySQL, and the server controls installed by Apache on the Start menu to control the Apache server To start MySQL and Apache automatically on... Here’s an example of how to use the MySQL server control script: [root@host]# /usr/local/mysql/support-files/mysql.server start [root@host]# /usr/local/mysql/support-files/mysql.server stop And here’s an example of how to use the Apache control script: [root@host]# /usr/local/apache/bin/apachectl start [root@host]# /usr/local/apache/bin/apachectl stop To have MySQL and Apache start automatically at boot... Quick_Standard_Installation.html ■ General guidelines for compiling Apache on UNIX, at http://httpd apache.org/docs/install.html ■ Windows-specific notes for Apache binary installations, at http://httpd apache.org/docs/windows.html ■ Installation instructions for PHP on Windows, at http://www.php.net/ manual/en/install.windows.php ■ Installation instructions for PHP on UNIX, at http://www.php.net/manual/... The installation process takes a few minutes to complete, so this is a good time to get yourself a cup of coffee 7 Once installation is complete, you should see a screen like Figure 2-26 The Apache installer also takes care of starting the Apache Web server, as the final step of the automated installation process You can now proceed to test the server as described in the section “Testing Apache,” to... ensure that the server is correctly handling HTTP requests Installing PHP The PHP binary release for Windows has two versions a ZIP archive that contains all the bundled PHP extensions and requires manual installation, and an automated Windows Installer-version that contains only the basic PHP binary with no extra extensions This section outlines the installation process for the PHP 5.0.1 ZIP archive... 2-21 Entering Apache server information FIGURE 2-22 Selecting the Apache installation type TEAM LinG CHAPTER 2: Setting Up a PHP-MySQL Development Environment 45 2 FIGURE 2-23 Selecting components for a custom Apache installation FIGURE 2-24 Selecting the Apache installation directory TEAM LinG 46 How to Do Everything with PHP & MySQL 6 Apache should now begin installing to the specified location (Figure... CHAPTER 2: Setting Up a PHP-MySQL Development Environment 49 5 Open the Apache configuration file, httpd.conf (which can be found in the Apache/conf/ subdirectory of the Apache installation directory), in a text editor, and add the following lines to it 2 AddType application/x-httpd-php php LoadModule php5_module "c:\php\php5apache.dll" SetEnv PHPRC C:\windows These lines tell Apache how to deal with... commands or queries to test whether the server is working as it should Here are a few examples, with their output: mysql> SHOW DATABASES; + + | Database | + + | mysql | | test | + + 2 rows in set (0.13 sec) mysql> USE mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> SHOW TABLES;... 2-25 Apache installation in progress TEAM LinG CHAPTER 2: Setting Up a PHP-MySQL Development Environment 47 2 FIGURE 2-26 Apache installation successfully completed PHP 4.3.0 and better can only be used with Windows 98/Me/NT/2000/ XP/2003 Windows 95 is not supported as of PHP 4.3.0 1 Log in as an administrator (if you’re using Windows NT or Windows 2000) and unzip the distribution archive to a directory . binary release for Windows has two versions a ZIP archive that contains all the bundled PHP extensions and requires manual installation, and an automated. should see a screen like Figure 2-26. The Apache installer also takes care of starting the Apache Web server, as the final step of the automated installation

Ngày đăng: 18/10/2013, 23:20

TỪ KHÓA LIÊN QUAN

w