Windows + Apache + PHP + MySQL simple configuration tutorial

Source: Internet
Author: User
Tags learn php
The first step of preparation is to download the software and decompress it. (Note that the non-Chinese directory is required. The Software Directory here uses C: ProgramFiles as an example ), the installation of this installation (MySQL installation has many options. If you are good at English, you just need to check and fill in as needed. If you cannot, refer to here. Although the version is old, but the configuration options

The first step of preparation is to download the software and decompress it. (Note that the non-Chinese directory is required. The Software Directory here uses C: \ Program Files as an example ), the installation of this installation (MySQL installation has many options. If you are good at English, you just need to check and fill in as needed. If you cannot, refer to here. Although the version is old, but the configuration options

Preparations

First, download the software and decompress it. (Note that the non-Chinese directory is required. The Software Directory here uses C: \ Program Files as an example ), the installation of this installation (MySQL installation has many options. If you are good at English, you just need to check and fill in as needed. If you cannot, refer to here. Although the version is oldConfiguration).

The following is a brief introduction of several software:

Apache

Apache is the world's top Web server software. We use it to build a local Web server. It listens for http requests and sends local Web data to browsers, simply put, after building Apache, we can access the local website through a browser.

: Httpd-2.4.4-win32.zip (more)

PHP

Now that you have a Web server, why do you need PHP? Because the Web server is only used to respond to browser requests and does not have the function of parsing PHP files, PHP is also required for parsing.

: Php-5.4.12-Win32-VC9-x86.zip (more)

MySQL

MySQL is a relational database management system. It is out of configuration with PHP because it is fast and powerful. More importantly, it is free of charge (O (∩ _ ∩) O ~).

: Mysql-installer-community-5.6.10.1.msi (more)

PhpMyAdmin

PhpMyAdmin is neither a software nor a WAMP environment, but it is almost indispensable in PHP development. PhpMyAdmin is a MySQL visual management tool written in PHP, so it does not need to be installed orConfiguration, Directly decompress it to your default website directory (additional instructions ).

: PhpMyAdmin-3.5.7-all-languages.zip (more)

ConfigurationPHP

You may wonder why I putConfigurationPut Apache in the front, but put Apache in the back? Because we need to combine the two, and the process of integration is in the ApacheConfigurationFile, ifConfigurationApache, thenConfigurationAfter PHP is complete, you must continue looking back.ConfigurationApache.

PHPConfigurationThe file is php under the root directory. ini, but you will find that there are two files in the directory, one is development and the other is production. As the name suggests, the former is used for development and testing, and the latter is used for online products, high Security Factor. I only do development and testing locally, so I chose the php. ini-development file, changed it to php. ini, and opened it.ConfigurationThe steps are all performed here.

    ConfigurationPath of the extension Library:
  1. Find; extension_dir = "ext" (about 730 rows), remove the semicolon, and change its value to the extension library file directory of PHP, such as extension_dir = "C: /Program Files/PHP/ext ". The directory here is determined by the path of your PHP. Remember to add ext next to it.
ConfigurationPHP + MySQL

HereConfigurationAlso in php. ini:

  1. By default, PHP does not support MySQL. Therefore, we need to enable the MySQL extension library and remove the semicolon before the two rows:
       
       
    1. ;extension=php_mysql.dll
    2. ;extension=php_mysqli.dll

You can also remove the semicolon to introduce other extension libraries as needed. I have enabled php_curl and php_mbstring here.

ConfigurationApache + PHP

ApacheConfigurationThe file is the httpd. conf file under the conf directory. Open it:

  1. First, find ServerName (about 213 rows), set it to localhost: 80, and delete the previous well number. Although this step can run normally without modification, however, an annoying prompt (AH00558: httpd.exe: cocould not reliably determine the server's fully qualified do main name, using fe80: fc76: abca: e24b: d490. Set the 'servername' directive globally to suppress this message). For cleaner, modify it.
  2. Set the Apache directory and replace c:/Apache24 in the file with the directory where Apache is located, for example, C:/Program Files/Apache.
  3. Modify the default website directory address (about 237 rows) and find
       
       
    1. DocumentRoot"C:/Program Files/Apache/htdocs"
    Replace the path with the default website directory you want to set. The default website directory refers to the directory where the website files are stored during future development and debugging. When Apache receives a browser request, the corresponding files are read from the directory, executed, and sent to the browser. Here, F:/Websites is used as an example (it must also be a non-Chinese directory ):
       
       
    1. DocumentRoot"F:/Websites"
  4. In (about 171 rows)
       
       
    1. #LoadModule xml2enc_module modules/mod_xml2enc.so
    Add the following two lines to support PHP:
       
       
    1. LoadModule php5_module "C:/Program Files/PHP/php5apache2_4.dll"
    2. PHPIniDir"C:/Program Files/PHP"
    The path here corresponds to your PHP Directory.
  5. Add a default homepage. When Apache receives an http request without a file name, it automatically searches for the default homepage in the directory, in this way, you do not need to add a file name to each visitor's website. (for example, when you access http://www.clanfei.com/, the content of http://www.clanfei.com/index.php is displayed automatically:
       
       
    1. DirectoryIndex index.html
    (About 274 rows) change it
       
       
    1. DirectoryIndex index.html index.php
    In this case, the prefix is higher than the latter. It is also said that when index.html and index.php are found in the same directory, index.html is displayed as the default homepage, rather than index. php.
  6. To add support for PHP file types, find:
       
       
    1. AddType application/x-gzip .gz .tgz
    (About 402 rows), add below:
       
       
    1. AddType application/x-httpd-php .php
Run and Test

The above is the WAMP EnvironmentConfigurationNow, start the service and TestConfigurationResults:

Press Win + R to open the Run window, Enter CMD, and enter (the Apache path is determined by the quotation marks ):

 
 
  1. "C:\Program Files\Apache\bin\httpd.exe"-k install

After installing the service, you do not have to reinstall it. Then enter:

 
 
  1. "C:\Program Files\Apache\bin\httpd.exe"-k start

After the service is started, the service will be automatically started after it is started. Unless the service is stopped by using the stop parameter, the above command needs to be re-run.

The parameters after-k can be install, uninstall, start, stop, and restart.

Of course, there is an apachemonitor.exe file in the bindirectory of apacheto visually complete these functions. You can create a shortcut for it or directly set it as a startup Item to facilitate Apache service management.

The test method is very simple, under the default website directory (according to the aboveConfiguration(F:/Websites), create a text file and change it to index. php. Enter the code below:

 
 
  1. phpinfo();

If you open a Web page about the PHP environment information, it indicates Apache + PHPConfigurationClick Ctrl + F to search for mysql. If there is a table named "mysqlnd", it means that MySQL is alsoConfigurationSucceeded.

Additional instructions
  1. If your port 80 is in use (if you have installed IIS and other website server programs), you need to change the port number listened to by Apache and find Listen 80 (about 58 lines ), change 80 to the port number you want to set, such as 8080. When debugging a local PHP program, enter http: // localhost: 8080 in the address bar of the browser, because the default port number of http protocol is 80, You need to inform the browser of the new port number so that the browser can request data from Apache through the new port correctly.
  2. The default MySQL management tool is just a dark command line window, which is inconvenient to use. We can download phpMyAdmin as a visual MySQL management tool, decompress the package to the default website directory and change the folder name to phpMyAdmin. Then, you can enter http: // localhost/phpMyAdmin in the browser to access the file.
  3. To enable the rewrite/pseudo-static function, refer to my article Apache to enable rewrite for pseudo-static.
Postscript

Many people think that the WAMP EnvironmentConfigurationPlease download WampServer directly as a PHP development environment. However, after all, the software integrated by WampServer is not the latest version, and more importantly, as a Geek, how can we not have any research spirit? We will learn PHP next semester.ConfigurationReview the process and share it with you. If you have any omissions, please kindly advise!

Blue flying technology blog

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.