Installation and configuration of Apache + PHP + MySql in Windows (Latest Version)

Source: Internet
Author: User
Tags php server website server root access

Prepare the software first:

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, "Start" and "allProgram"," Apache HTTP Server 2.0.55 "," Configure Apache server "," edit the Apache httpd conf configuration file ", and click open.

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.

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.