Installation of the PHP environment (i)

Source: Internet
Author: User
Tags learn php php script phpmyadmin

The first step in learning PHP is to install the PHP environment, of course, this article will not introduce a similar phpmyadmin this one-button installation of the environment to build, this installation method only need to go crazy point next good, there is nothing to say, I want to put apache+php and iis+ The installation method of PHP is described in detail in this document. Many beginners puzzled, why learn PHP to install Apache This software, it is not difficult to understand, PHP is a server-side script, it was born for the BS software Architecture design, so inevitably need a Web server as an intermediary bridge. Such as:

The process is that when the server receives a request from the client, it will be treated differently depending on the MIME type of the requested resource, and typically the WEB server will be sent directly to the client for static resources. For example, txt,.png,.html, etc., for files that need to be processed before they are sent back to the client, you need to hand the file to the handler that resolves the file in the server and then back to the client, which is also a feature of the BS software, the interactive mode of response based on the request.

However, PHP is the service-side scripting language, generally speaking, the. php suffix file is called a PHP script file, if need to be parsed to use the PHP parsing engine support, therefore, we only need for the Web server Adding a PHP processing engine module and handing out a MIME-type request for a. php file to the PHP engine to process it will be a successful implementation of the PHP environment.

PHP is open source free software, you can go to http://php.net/downloads.php to download the installation package, according to their own operating system to choose a different version, window version is a ZIP package, nothing to say, decompression can be used.

window+apache+php

Here I did not write on MySQL, personally feel that MySQL is not necessary, because the installation of a Web server software on an operating system and the PHP interpretation engine can successfully execute the PHP code, as for MySQL, it is also possible to add in the time needed, If you use the phpMyAdmin one-click Installation, will automatically install MySQL, the amount, as a beginner, personal feeling is best to manually install a few more times, to understand the best relationship between them.

Apache is also free software like PHP, you can go to Http://httpd.apache.org/download to download the installation package. This article takes apache2.4+php5.6 as an example to elaborate the following installation steps:

1. Unzip the PHP compression package, put the extracted files into the appropriate folder, I am more accustomed to the third-party software installed in the "D:\Program" directory, by default, PHP and Apache compressed package are signed "-" The individual does not recommend in the directory does not conform to the variable naming method of other characters, Generally speaking, it is best to choose letters, numbers or underscores as the directory name, do not recommend the use of numbers or underscores, of course, this is my personal habit, my php root directory is "D:\Program\PHP5\", my Apache root directory is "D:\Program\ Apache24\ "

2. For PHP, there is nothing to adjust, I do not know why there are many words on the internet is the need to put the PHP root INI file in the system directory, as if to facilitate the call, but we can completely do not, for the configuration of PHP, later involved in the need to configure the time in detail said, By default, PHP can be run directly without any configuration of PHP, and it will meet a lot of work needs. But the first time to install it is necessary to know where the PHP configuration file, after decompression, you will find in the root directory of PHP named "Php.ini-development" and "Php.ini-production" two files, yes, this is the PHP configuration file, Just rename one of them to "php.ini", of course, the individual is not recommended to do this directly, if later configuration error, do not know the default configuration value, it is more troublesome, conservative, the recommended approach is to rename one of the copies to "PHP.ini" best, I generally choose to " The copy of Php.ini-development "is renamed" PHP.ini ".

3. For Apache, it is more cumbersome, need to do more configuration, and, Since the Apache2.4 version, the configuration file is allowed to use the Define keyword to define constants, the configuration file in the Apache root directory under the Conf directory, httpd.conf file is the Apache configuration file, say no more, we come to know this configuration file.

3.1 Open the configuration file can see "ServerRoot" ${srvroot} "" Code, which has a define keyword defined with a constant named Srvroot, used to define the root directory of Apache, it is obvious that This sentence needs to be changed to the correct directory.

Define srvroot "d:/program/apache2/"

Speaking of which, in fact, we can also define a constant to identify the site root directory, easy to call in the configuration file. Suppose I need to use "D:\Web\" as the site root, then write it immediately in the previous sentence (need to guarantee the existence of the directory):

Define WEBROOT "d:/web/"

As shown in the following:

3.2 Continue looking down, you can see the "Listen 80" line, this is the Apache listening port, because the machine has IIS installed and has occupied 80 ports, therefore, I will change the port here is 8080 port, as shown in:

3.3 And then down, you can see a lot of "LoadModule", this is Apache for different MIME types called the program module, it is obvious that if you need to let the requested script file can be parsed PHP code, you must add PHP parsing module for Apache. Therefore, we add a line after loadmodule this paragraph, add PHP module for Apache, note that the specified path is the absolute address of the "Php5apache2_4.dll" file in the PHP root directory, And the directory where the PHP configuration file is also told to Apache, so that you do not have to copy the php.ini to the system directory, as shown in:

3.4 Next, we need to specify the site root of the site for Apache, locate the DocumentRoot setting item, and invoke the custom constant webroot in the same way that you just called the constant Srvroot, as shown in:

3.5 Next we need to set the next site's default page, find the DirectoryIndex node, change to Index.html and index.php, it is important to note that, the higher the priority.

3.6 Last configuration, we need to set the MIME type for Apache and tell Apache to give the PHP engine a file with a. php suffix to finish, find Mime_module, add a category, as shown in:

4. After Apache is configured, we need to install Apache into the service so that it can run, open a command prompt, enter "D:\Program\Apache2\bin\httpd.exe-k install-n Apache2" Install Apache, let me explain, the preceding string of course refers to the Apache main program absolute address,-K parameter has two values, one is installed, one is uninstall, I believe you know what to do with it, as for the-n parameter to say, is installed into the service name, Can be arbitrarily named, of course, the name of the best choice of personal recommendation of the variable name method. A description appears stating that the installation was successful.

When the installation process occurs, remember to click Allow

We can confirm that the installation is successful in the service, open the service, and show that it was successfully installed.

Click on the left to start, if you can start successfully, it means that everything has been done.

Installation of the PHP environment (i)

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.