[Windows] configure Apache + PHP + MySQL + PHPmyadm in the php Development Environment

Source: Internet
Author: User
Tags php development environment php error server website how to use phpmyadmin root access
1. Install the Apache server software Step 1. Because apache needs to use port 80 of the computer, make sure that other programs that use port 80 are disabled before installing apache. For example: 2. Double-click the Installation File apache_2.2.10.msi to install the Apache server software. The installation wizard window is displayed, as shown in Figure 1.2. Step

1. Install the Apache server software Step 1. Because apache needs to use port 80 of the computer, make sure that other programs that use port 80 are disabled before installing apache. For example: 2. Double-click the Installation File apache_2.2.10.msi to install the Apache server software. The installation wizard window is displayed, as shown in Figure 1.2. Step

I. Installation of Apache server software

Step 1Because apache needs to use port 80 of the computer, make sure that other
Programs that use port 80, such as thunder, skype, and IIS
Step 2Double-click the Installation File apache_2.2.10.msi to start installing the Apache server software. The installation wizard appears.
Window, as shown in Figure 1.2.



Step 3Click "Next" to perform the Next step.
Step 4Go to the software license agreement screen and select accept agreement to go to the next step, as shown in 1.3.



Step 5The overview and Information Window of Apache is displayed. After browsing, click Next.
Step 6Go to the system information setting page, and enter the domain name, server name, and email address, as shown in Figure 1.4.



Note: In the previous interface, you can enter localhost as needed. However, if you enter all localhost, it will match with the subsequent settings. Therefore, we recommend that you enter it as needed. In addition, whether your Windows server has been installed with other Web servers. For example, if you have already installed IIS (a server supporting asp), IIS uses port 80 by default, apache cannot use port 80. You can only switch to port 8080 during installation, or stop iis (net stop iisadmin/net stop w3svc) before installing Apache ), if you are operating in a clean XP environment, ignore it.

Step 7Select the installation method: advanced users can select "custom installation". Generally, we select "typical installation" by default"
As shown in 1.5.



Step 8Select the installation path: by default, the installation path is under drive C. You can select your own directory (but do not install Apache in a path containing Chinese characters), and then click "OK", as shown in Figure 1.6.
. 6



Step 9Ask again whether to install according to the previous settings. To modify the settings, click back"
Button, as shown in Figure 1.7. If it is correct, select the "Install" button to start installation.



Step 10Complete the installation.
Note: After Apache is installed successfully, the Apache Server icon appears in the lower right corner of the screen, as shown in Figure 1.8, indicating that the Apache service has started running. If necessary, you can stop or restart the Apache server.



Step 11Browse Apache installation directory: After Apache is successfully installed, find the htdocs file in the installation root directory.
Folder, which is the default root directory of the website, as shown in Figure 1.9.



Step 12Test Apache running: Open the browser and enter http: // localhost/in the address bar to display
Displays the current home page of the local server, as shown in Figure 1.10, indicating that the Apache server is running normally.



Ii. simple configuration of Apache server software

After installing Apache, you can use it without any configuration. To learn more about it, you can modify the configuration options of Apache.
The Apache server adopts the configuration file. The configuration file is the httpd. conf file under the conf directory in the installation directory. open the file in notepad and modify the corresponding settings. (Note: After the Apache configuration file is modified, you must restart the Apache server software to make the modification take effect .)

Configure 1 to set the listening port. The Apache server listens to port 80 by default. If other programs occupy port 80, you can also set Apache to listen to other ports. If you want your Apache to listen to port 8080, you only need to set httpd. code in the conf file (approximately 47th rows): change Listen 80 to Listen 8080, and restart Apache.
Configuration 2 in the example of changing the root directory of the server, the installation directory of the Apache server is "d:/Program Files/Apache Software Foundation/Apache2.2". Therefore, the default root directory of the server website is "d: /Program Files/Apache Software Foundation/Apache2.2/htdocs ". You can modify the default website root directory of the Apache server in the following two steps.
1. about 178 lines in the configuration file: "DocumentRoot" d:/Program Files/Apache Software Foundation/Apache2.2 "" Modify the root directory of the new website you want to set, for example, set "DocumentRoot" F:/web "under the web directory of drive F "".
2. About 205 lines in the configuration file:" ", Change to the website root directory set in the previous step," ".
Configuration 3 modify the default file loading option when the "http: // localhost/hosts or other address is entered, the server opens the" index.html "file in the input directory. To make the" index. php "file also become the default file opening option, you can modify the default file loading option. (About 240 lines in the configuration file. Note that multiple files are separated by spaces)

DirectoryIndex index.html index. php

Configuration 4 configure the VM

A single server can sometimes be configured with multiple hosts for use by multiple websites (especially when the network is running ). You can add a virtual host to the configuration file of the Apache server to support the running of multiple websites.

Common Apache Virtual Hosts include port-based virtual hosts and name-based virtual hosts.

1. Port-based virtual host configuration method

Add an empty line at the end of the configuration file and enter the following configuration information in the empty line.

DocumentRoot "E:/Web"

Options FollowSymLinks

AllowOverride All

Order allow, deny

Allow from all

Add listening port (8080), restart the Apache server, create an index.html file (enter any content) under "E:/website", and enter" http: // localhost: 8080/Second, the contents of the index.html page can be uploaded.

2. Name-based virtual host configuration method

NameVirtualHost *: 80

DocumentRoot "E:/Web"

ServerName VirtualHostTest

Options FollowSymLinks

AllowOverride All

Order allow, deny

Allow from all

Use a text editor such as EditPlus or notepad to open the host file in Windows: C: \ Windows \ System32 \ drivers \ etc \ hosts.

Add a row at the end: 127.0.0.1 VirtualHostTest

Restart the Apache server and open the browser to access http: // virtualhosttest. then, you can access the content on the index.html page.

Configuration 5 allow URL rewriting

If you want to access the message on page 2nd, the URL entered in the address bar may be "http: // localhost/msg/index. php? Page = 2, but this form of URL is not conducive to search engines, if the URL is in the form of "http: // localhost/msg/index/page/2 ", it is helpful for search engines. In this case, the URL rewriting technology is required to match the two URLs. Find the "# LoadModule rewrite_module modules/mod_rewrite.so" line in the configuration file and remove the "#" line from the front side (remove comments). Even if the Apache server supports URL rewriting, restart the Apache server. (The test of this modification needs to be tested in the Zend Framework application .)

Iii. Installation of the PHP interpretation Engine

Step 1Decompress php-5.3.4.zip to an installation directory. In this example, select "d:/Program ".

Files/php-5.3.4/"directory. (The PHP interpretation engine is a compressed package, which can be directly decompressed .)

Step 2Configure the Apache server to support the PHP interpretation engine.

1. Load the PHP interpretation engine on the Apache server

Add the following configuration information in the last line of the Apache configuration file.

LoadModule php5_module "d:/Program Files/php-5.3.4/php5apache2_2.dll"

2. Add the PHP configuration file directory to the Apache server.

Add the following configuration information in the last line of the Apache configuration file (below the preceding configuration information.

PHPIniDir "d:/Program Files/php-5.3.4"

3. determine which types of files on the Apache server need to be explained by the PHP interpreter.

In the last line of the Apache configuration file (below the preceding configuration information), add the following configuration information (the code after # Is a comment and can be left blank ).

AddType application/x-httpd-php. php # php File

AddType application/x-httpd-php. inc # inc file (including files)

AddType application/x-httpd-php. phtml # Zend Framework Template File

Step 3In the "f:/web/" Directory (in the server root directory), create a php file phpInfo. php,

The file content is as follows.

Echo phpinfo ();

?>

Step 4Restart the Apache server and enter "http: // localhost/phpInfo. php" in the address bar of the browser. If the 1-11 page appears, the Apache server supports the PHP interpretation engine.



Iv. simple configuration of the PHP interpretation Engine

The PHP interpretation engine takes the form of a configuration file. Its configuration file is: PHP In the installation directory of the php interpretation engine. ini-development (development configuration file), change this file to php. ini (this configuration file is used in the Apache server ). (Note: After the PHP configuration file is modified, you must restart the Apache server software to make the modification take effect .)

Configure 1 to display (Suppress) PHP error messages

In php. "display_errors = On" is found in the INI file. This record is used to configure whether errors in the PHP file are displayed On the HTML page. (if no error information is displayed, change it to "display_errors = Off ").

Configure 2 to set the Default Time Zone

In php. in the INI file, find "; date. timezone = ", which is used to configure the default time zone of the PHP interpretation engine. timezone = PRC ", indicating that the default PHP interpretation engine time zone is China. (";" In the front of the configuration file indicates that this line is a comment .)

Configure 3 extension library support

In PHP, connecting to the database, drawing GD images, and outputting PDF files are all supported in the form of extended libraries. Modify the following configuration items to allow PHP to support the corresponding extension Library (remove ";" from the Front ).

; Extension = php_gd2.dll # configure PHP to support the GD graphics library

; Extension = php_mbstring.dll

; Extension = php_exif.dll # Two configuration items: PHP supports multi-byte text

; Extension = php_mysql.dll # configure PHP to support MySQL Databases

; Extension = php_pdo_mysql.dll # configure PHP to support connecting to MySQL using PDO

; Extension = php_soap.dll # configure PHP to support the SOAP Service

Configuration 4 modify ext path

In php. ini, find extension_dir = "ext" and change it to extension_dir = "d:/Program Files/php-5.3.4/ext". Remove the semicolon before it.

Configure 5 configure the output buffer size

In PHP, when setting HTTP Response Message Headers, cookies, and sessions (For details, refer to the core Web Technology Section), no HTML output can be provided before the setting statement. You can modify the configuration file, enable the buffer to allow HTML code output before these statements.

In php. "output_buffering = 4096" is found in the INI file. The configuration information for this row indicates that the output buffer size supported by PHP is 4096 bytes, which is kept by default. If the buffer is disabled, you only need to comment out the statement of this line (the first plus sign of the line is the comment ).

Configure 6. Modify the maximum file size of the uploaded file

When uploading files in PHP (For details, refer to the core Web Technology Section), the maximum file upload size is 2 Mb by default. You can modify the PHP configuration file, to change the maximum file upload size.

In php. the "upload_max_filesize = 2 Mb" statement is found in the INI file. This statement indicates that the maximum file size of the uploaded file is 2 Mb. If you want to set the maximum file size to 20 Mb, you only need to modify this configuration item to "upload_max_filesize = 20 m.

The above PHP configuration options require modifying the PHP configuration file php. ini and restarting the Apache server to take effect. We call this configuration method "hard configuration ". In contrast to "soft configuration", in the PHP script file, the configuration option is dynamically written, and the configuration option takes effect without restarting the Apache server, valid only for the current file.

In the PHP script, use the ini_set () function to configure the PHP configuration options. If no error message is displayed for a script, add the following statement at the beginning of the file. The first parameter of the ini_set () function represents the configuration option and the second parameter code configuration option value. For details, see the reference manual.

Ini_set ('display _ errors ', 1 );

?>

V. Installation of MySQL database software

Step 1Double-click the Installation File mysql-5.1.msi to start installing MySQL database software, the installation wizard appears

Interface, as shown in figure 1-12.


Step 2Click Next to display the installation method selection interface, and select the default Typical installation (Typical ),

1-13. In this case, the Program will be installed in the C: \ Program Files \ MySQL Server5.1 directory by default.

Select m and click Next to set the installation directory in the Next step.


Step 3Click Next To Go To The Information overview page before installation. Click Install to Install the database software.

Step 4Click Next step until the installation completion page is displayed, as shown in figure 1-14.


Step 5Click Finish to go To the MySQL configuration page, as shown in figure 1-15.


Step 6Click "Next" step by step until the encoding format selection page is displayed, as shown in figure 1-16. To enable the database to support multiple languages, we select the UTF8 encoding format.


Step 7Click Next To Go To The page shown in Figure 1-17. We keep the default settings and install MySQL

Windows service.


Step 8Click Next To go to the page for setting the password of the MySQL database superuser (root user,

1-18. This super user has all the operation permissions on MySQL, And the password must be kept in mind after it is set. The check box "Enable root access from remote machines" below selects whether to allow remote machines to connect to your MySQL server as a root user. If you need this, you can also select this check box.


Step 9Click Next to complete the configuration and start the MySQL service interface. Click Execute.

Configuration. The page 1-19 is displayed.


Step 10Click Finish to complete the MySQL configuration.

6. Use phpMyAdmin to manage MySQL Databases

For MySQL database management, the built-in console manager is used by default. The startup mode is to enter the MySQL installation directory on the console interface, and enter "mysql-u root-p ", go to the MySQL console interface (where root is the MySQL account to be used) and enter the password as prompted to enter the MySQL console, as shown in figure 1-20.


The MySQL Database Console can complete all the MySQL database operation functions, but the operation is troublesome and error-prone. PhpMyAdmin is a Web application written in PHP to operate MySQL Databases graphically. Now we will learn how to use phpMyAdmin to manipulate the MySQL database.

Step 1Install the phpMyAdmin database operation application

Decompress the phpmyadminpackage phpmyadmin-3.3.8.rar and decompress it to an independent folder under the root directory of the Apache server.

Step 2Enter "http: // localhost/phpMyAdmin-3.3.8/index. php" in the address bar of the browser

PhpMyAdmin logon interface (Port 3306 is used by default to access the MySQL database service on the local machine), as shown in figure 1-21. Enter the user name and password of the local MySQL database in the user name and password, and click "execute.


Step 3Go to the phpMyAdmin page, as shown in figure 1-22.

On the main phpMyAdmin page, the database name on the current database server is displayed on the left, and the central area is the main operation area.

Step 4Configure phpMyAdmin to access the database of a specific IP Address

PhpMyAdmin is the default access to the local MySQL database, if you want to access the MySQL database on another IP host (such as 10.7.1.98), rename the "F:/web/phpMyAdmin-3.3.8/" directory config. sample. inc. the PHP file (F:/web directory is the modified Apache server root directory) is config. inc. php, and find the line "$ cfg ['servers'] [$ I] ['host'] = 'localhost';" in the file, change it to "$ cfg ['servers'] [$ I] ['host'] = '10. 7.1.98 '; "indicates that phpMyAdmin wants to access the MySQL database on the 10.7.1.98 server.

Step 5Configure phpMyAdmin to access the database on a specific host port

PhpMyAdmin accesses the MySQL database through port 3306 by default. If you want to access the MySQL database through other ports (such as port 3307) (generally, when one host installs two or more MySQL databases, database port is certainly not the same, access to which database, need to be determined by the port number), you can edit the "F:/web/phpMyAdmin-3.3.8/" directory config. inc. PHP file (F:/web directory is the modified Apache server root directory), find "$ cfg ['servers'] [$ I] ['Port'] = ''; "line, modify it to" $ cfg ['servers'] [$ I] ['Port'] = '2016 ';", that is, phpMyAdmin accesses the MySQL database on the server through port 3307.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.