Installation and configuration of Apache + php + mysql in windows (latest version) _ PHP Tutorial

Source: Internet
Author: User
Tags website server root access
Installation and configuration of Apache + php + mysql in windows (latest version ). First ready software: Apache official: apache_2.0.55-win32-x86-no_ssl.msi, more versions here; php official: php-5.0.5-Win32.zip, more images Download First ready software:

Apache official website:Apache_2.0.55-win32-x86-no_ssl.msi,More versions are available here;

Php official website:Php-5.0.5-Win32.zip,More images,Download more versions;

Official mysql:Mysql-4.1.14-win32.zip,More images,Download more versions.

1. install Apache. a common website server is successfully configured.

Run the downloaded"Apache_2.0.55-win32-x86-no_ssl.msi", The following interface is displayed:

On the installation wizard page of Apache HTTP Server 2.0.55, click "Next" to continue.

Confirm to agree to the software installation license ordinance, select "I accept the terms in the license agreement", and click "Next" to continue

For instructions on installing Apache on Windows, please read the instructions and press "Next" to continue

Set system information, enter your Domain Name (for example, goodwaiter.com) under Network Domain, and enter your Server Name (for example, www.goodwaiter.com, that is, the host Name and Domain Name) under Server Name ), fill in the system Administrator's contact Email Address (for example, yinpeng@xinhuanet.com) under Administrator's Email Address, the above three information is for reference only, the contact email address will be provided to the visitor when the system fails. All three pieces of information can be filled in at will. The following two options are available: the image is installed for all users of the system, the default port 80 is used, and automatically started as the system service; the other is installed only for the current user, use Port 8080 to manually start the instance. Generally. Press "Next" to continue.]

Select the installation type, Typical is the default installation, and Custom is the user-defined installation. Here we select Custom for more options. Press "Next" to continue

The "select installation option" page appears. click "Apache HTTP Server 2.0.55" and select "This feature, and all subfeatures, will be installed on local hard drive. ", that is," this part and its sub-parts are all installed on the local hard disk ". Click "Change..." to manually specify the installation directory.

I chose to install it on "D: \" here. you have selected it by yourself. generally, we recommend that you do not install it on the disk where the operating system is located, so that the operating system will not be damaged, the Restore operation also clears the Apache configuration file. Select "OK" to continue.

Return to the interface and select "Next" to continue.

Confirm that the installation options are correct. if you think you want to check again, click "Back" to return to the check step by step. Click "Install" to start installation according to the preceding installation options.

Installing the interface. please wait until the following figure is displayed.

The installation wizard is successful. the following green icon should appear in the status bar in the lower right corner, indicating that the Apache service has started running. press "Finish" to complete the installation of Apache software.

Let's get familiar with this icon, which is very convenient. you can click it on the icon and the following interface appears, including "Start" and "Stop) you can easily perform the preceding operations on the installed Apache server.

Now let's test the website interface that runs according to the default configuration. in the IE address bar, click "http: // 127.0.0.1" and click "Go" to see the following page, indicates that the Apache server has been installed successfully.

Now, configure the Apache server to better serve us. In fact, if not configured, the Apache2 \ htdocs folder under your installation directory is the default root directory of the website, put the file in it. Here we still need to configure. if there is any problem or modification, the configuration will always be met ,, click Start, all programs, Apache HTTP Server 2.0.55, Configure Apache Server, and Edit the Apache httpd conf Configuration file.

XP notepad has made some minor changes. a very practical function is to view the row and column positions of the file content, as shown in. Click "View" and select "status bar ", there is an additional tag in the lower right corner of the interface. "Ln 78, Col 10" indicates "row 78, column 10", which can be quickly located in the file for ease of explanation. Of course, you can also enter keywords in "edit" and "search" to quickly locate the problem. Every time the configuration file changes, it must take effect after the Apache server is restarted. you can use the small icon mentioned above to conveniently control the server to "restart" at any time ".

Now, configure the Apache server, "Ln 228", or search for the keyword "DocumentRoot" (that is, the root directory of the website) and find the location shown in, then, change the address in "" to the root directory of your website. write the address format as shown in the figure. generally, change the file address "\" to "/" in Apache.

"Ln 253", you can also find"

The specified parameter file name is arbitrary. it is not necessarily set to "index.html", such as "test. php.

Here is a configuration option, which may have to be configured in the past. now it seems to be corrected. you don't need to configure it, that is, to force the language encoding of all output files. the html file contains the language tag (, this is also mandatory conversion when the document language is set to gb2312. If the webpage is garbled, check whether the above html language mark exists in the webpage. if not, it will be displayed normally after being added. Remove "#" in front of "# DefaultLanguage nl" and change "nl" to the language you want to force the output. the Chinese name is "zh-cn". save and close the language.

Now, the simple Apache configuration is over. now, with the restart of the previous small icon, all the configurations will take effect and your website will become a website server, if you have loaded the firewall, open port 80 or port 8080, or allow the Apache program to access the network. otherwise, others will not be able to access the network. If you have a public IP (usually ADSL or dial-up Internet), you can invite all friends who can access the internet to use http: // your IP address (IP address query can access http://www.goodwaiter.com, the content in the query is) your website. if you do not have a public IP address, you can also tell other users in the LAN through http: // your intranet IP address, visit your website.

2. php installation and module-based integration of php and apache enables your website server to support php server script programs

Download the php installation filePhp-5.0.5-Win32.zipRight-click and extract.

Specifies the decompression location, which is set to "D: \ php"

View the decompressed folder and find "php. ini-dist file, rename it as "php. ini, open edit, find the place in the figure below, Ln385, there is a "register_globals = Off" value, this value is used to open global variables, such as the value sent from the form, if this value is set to "Off", you can only use "$ _ POST ['variable name'], $ _ GET ['variable name']" to obtain the sent value, if it is set to "On", you can directly use "$ variable name" to obtain the sent Value. of course, it is safer to set it to "Off, it is not easy to intercept data transmitted between webpages. If this value is changed to "On", it depends On your own feeling. is it important for security or convenience?

There is another area to edit. the function is to enable php to directly call other modules, such as accessing mysql, as shown in Ln563. select the module to be loaded and remove the previous ";", it indicates that the module is to be loaded. the more loaded the module, the more resources it occupies, but there is not much to load. for example, if I want to use mysql, I need to "; remove ";" before "extension = php_mysql.dll. All the module files are placed under the "ext" of the php decompression Directory. here I load all the modules that can be loaded, and the previous ";" is not removed, this module is not found in the "ext" directory by default. an error occurs when the file cannot be found during loading. This is just a reference. Generally, you do not need to load so much data. you can load the data as needed. Save the edited data and close it.

If other modules are loaded in the previous step, you must specify the module location. Otherwise, the system prompts the error "the specified module cannot be found" when you restart Apache. here is the simplest method, directly specify the php Installation Path and the ext path to the windows system path -- right-click "My Computer", select "properties", and select the "Advanced" tab, click "environment variables", find the "Path" variable under "system variables", Select, double-click or click "edit", and set "; D: \ php; D: \ php \ ext is appended to the original value. of course, "D: \ php" is my installation directory. you need to change it to your php installation directory, as shown in, confirm all. After the system path is added, it takes effect after the computer is restarted. you can restart the system now, or restart the system after all software is installed or configured.

Now we can combine php with Apache in the module mode to integrate php into Apache. open the configuration file of Apache in the previous method, Ln 173. locate here and add the two lines in the selection, the first line is "LoadModule php5_module D:/php/php5apache2. dll is used to load php in module mode. The second line "PHPIniDir" D:/php "indicates the php configuration file. the ini location is, of course, where "D:/php" should be changed to the directory you have previously selected for php decompression.

Or Apache configuration file, Ln 757, add "AddType application/x-httpd-php. php "," AddType application/x-httpd-php. html "two lines, you can also add more, the essence is to add file types that can execute php, for example, if you add a line "AddType application/x-httpd-php .htm.pdf", The .htm file can also execute the php program. you can even add the last line "AddType application/x-httpd-php. txt, so that the common text file format can also run php programs.

The default index file of the directory mentioned above can also be changed. because php is added, some files are saved directly. php, we can also set "index. php "is set as the default index file, which is ranked first in priority. Edited, saved, and closed.

Now, php installation and integration with Apache have all been completed. restart Apache with a small icon in the lower right corner of the screen, and your Apache server supports php.

III. mysql installation, combined with php and Apache

Open the downloaded mysql installation fileMysql-4.1.14-win32.zip, Double decompress, run “setup.exe ", the following interface appears

Start the mysql installation wizard and press "Next" to continue

Select the installation type, which has three options: "Typical (default)", "Complete (Complete)", and "Custom (Custom)". select "Custom ", with more options, you can familiarize yourself with the installation process.

Click "Developer Components (Developer part)" and select "This feature, and all subfeatures, will be installed on local hard drive. ", that is," this part and its sub-parts are all installed on the local hard disk ". The preceding operations include "MySQL Server", "Client Programs (mysql Client program)", and "Documentation (document)" to ensure that all files are installed. Click "Change..." to manually specify the installation directory.

Enter the installation directory "D: \ mysql" and do not place it in the same partition as the operating system. This prevents data from being cleared during system backup and restoration. Press "OK" to continue.

Return to the interface and press "Next" to continue.

Confirm the previous settings. if there is an error, press "Back" to return the redo. Click "Install" to start installation.

Installing. please wait until the following interface appears

This is to ask if you want to register an account for mysql.com or use an existing account to log on to mysql.com. Generally, this is not required. click "Skip Sign-Up ", click "Next" to skip this step.

Now that the software has been installed, the above interface appears. here is a good function. mysql configuration wizard does not need to be configured in a mess like before. ini. check the "Configure the Mysql Server now" and click "Finish" to Finish the software installation and start the mysql configuration wizard.

Start the mysql configuration wizard and press "Next" to continue.

Select the Configuration method, "Detailed Configuration (manual precise Configuration)", and "Standard Configuration". select "Detailed Configuration" to familiarize yourself with the Configuration process.

Select the Server type, "Developer Machine (development and testing class, mysql occupies a small amount of resources)", "Server Machine (Server type, mysql occupies a large amount of resources) "," Dedicated MySQL Server Machine (Dedicated Database Server, mysql occupies all available resources) ", you choose according to your own type, generally choose" Server Machine ", not too little, it will not be full.

Select the general purpose of the mysql Database, "Multifunctional Database (universal multi-function type, Good)", "Transactional Database Only (server type, dedicated to transaction processing, general) "," Non-Transactional Database Only (non-transaction processing type, relatively simple, mainly used for monitoring and recording, the support for MyISAM data types is limited to Non-transactional ), I chose it with my own purpose. here I select "Transactional Database Only" and press "Next" to continue.

Configure InnoDB Tablespace to select a bucket for the InnoDB database file. if you modify the bucket, remember the location and select the same place for the reinstallation. Otherwise, the database may be damaged, of course, it is okay to back up the database. we will not detail it here. I have not modified it here. use the default position and press "Next" to continue.

Select the average mysql access volume of your website and the number of connections at the same time. for example, "demo-support (DSS)/OLAP (about 20 connections)" and "Online Transaction Processing (OLTP) (about 500) "and" Manual Setting (manually set, enter a number by yourself) ". here I select" Online Transaction Processing (OLTP) "and my server, enough. press "Next" to continue.

Whether to enable the TCP/IP connection and set the Port. if the Port is not enabled, you can only access the mysql database on your machine. I enable it here and tick the Port Number: 3306. press "Next" to continue

This is very important. it is to set the default mysql database language encoding. The first is the Spanish encoding, and the second is the multi-byte general utf8 encoding, which is not our general encoding, select the third Character here, and then select or fill in "gbk" in the Character Set. of course, you can also use "gb2312". The difference is that the gbk font size is large, including all the Chinese characters of gb2312, and added traditional Chinese characters and other messy words-when using mysql, run "set names gbk;" before executing the data operation command (just run it once, GBK can be replaced with other values, depending on the settings here), you can use Chinese characters (or other texts) normally, otherwise the Chinese characters cannot be displayed normally. Press "Next" to continue.

Select whether to install mysql as a windows Service. you can also specify the Service Name (Service ID Name) and add the mysql bin directory to the Windows kernel-uusername-ppassword##directory. then, the complete address of mysql.exe is displayed, it is very convenient), I have checked all of them here, and the Service Name remains unchanged. Press "Next" to continue.

This step asks if you want to change the default root user (Super management) password (blank by default). If you want to change the "New root password", enter the New password here (if re-installed, you have already set a password. changing the password may cause errors. leave it blank and remove the check box before "Modify Security Settings". after the installation and configuration are complete, change the password separately ), "Confirm (re-enter)" is entered again to prevent errors. "Enable root access from remote machines (whether to allow root users to log on to other machines. if you want security, do not check it. if you want convenience, check it )". Finally, "Create An Anonymous Account (Create An Anonymous user, and the Anonymous user can connect to the database, and cannot operate data, including queries)" is not checked. The settings are complete, press "Next" to continue.

Confirm that the settings are correct. if any error occurs, press "Back" to return for the check. Press Execute to make the settings take effect.

After the configuration is complete, press "Finish" to end mysql installation and configuration. here is a common error, that is, the "Start service" is not allowed, which usually appears on a server where mysql was previously installed, to solve this problem, first ensure that the previously installed mysql server is completely uninstalled. if not, check whether the previous password has been modified as mentioned above; if not, back up the data folder under the mysql installation directory and delete it. after the installation is complete, delete the data folder generated by the installation and remove the backed up data folder, restart the mysql service. in this case, you may need to check the database and fix it once to prevent data errors.

This is a combination of Apache and php. I have mentioned it before. here I will talk about it. in the php installation directory, find the php that was previously renamed and edited. ini, as shown in Ln563, remove ";" before "; extension = php_mysql.dll" and load the mysql module. Save and shut down. restart apache. You can also select other modules to be loaded and remove the previous ";", which indicates that the module is to be loaded. the more loaded, the more resources occupied, however, there is not much to do. All the module files are placed under the "ext" of the php decompression Directory. here I load all the modules that can be loaded, and the previous ";" is not removed, this module is not found in the "ext" directory by default. an error occurs when the file cannot be found during loading. This is just a reference. Generally, you do not need to load so much data. you can load the data as needed. Save the edited data and close it.

Similarly, after the module is loaded, it is necessary to specify the module location. Otherwise, the error "the specified module cannot be found" will be prompted when Apache is restarted. here is the simplest method, directly specify the php Installation Path and the ext path to the windows system path -- right-click "My Computer", select "properties", and select the "Advanced" tab, click "environment variables", find the "Path" variable under "system variables", Select, double-click or click "edit", and set "; D: \ php; D: \ php \ ext is appended to the original value. of course, "D: \ php" is my installation directory. you need to change it to your php installation directory, as shown in, confirm all. After the system path is added, it takes effect after the computer is restarted. you can restart the system now, or restart the system after all software is installed or configured.

Apache official: apache_2.0.55-win32-x86-no_ssl.msi, more versions here; php official: php-5.0.5-Win32.zip, more images download...

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.