Briefly describe the establishment and configuration of the php environment, and briefly describe the establishment of php

Source: Internet
Author: User

Briefly describe the establishment and configuration of the php environment, and briefly describe the establishment of php

Recently I am studying PHP. The following is a tutorial on PHP100 video. The learning notes are stored here for future use.

Apache -- PHP--DB (mysql)

I. apache: basic work

· When a user accesses a Server File through a browser, it passes the file to the user and displays the content of the file in the user's browser.

· Common text files can be directly transmitted to the user's browser through apache.

· Program files, such as PHP, cannot be directly displayed in the browser. Therefore, apache needs to call a component of PHP to parse and execute the PHP file before returning it to apache, apache then transmits the executed file to the user's browser for display.

Key configurations:

Configuration File: conf/httpd. conf; (restart apache after each modification)

1. Introduce PHP Components

When a user accesses a PHP file, apache can call the PHP component to execute the PHP file. Therefore, when configuring apache, You need to associate the PHP component with it in the configuration file.

For example, I installed apache in the Program of the f disk, so its component path is: LoadModule php5_module "f:/Program Files/php54/php5apache2_2.dll"

2. Set when to call the PHP component

Because not every time a user accesses a PHP file, it is not necessary for apache to call the PHP parsing component every time. Because apache needs to determine when to call apache. That is, it is called only when it is. php.

Add the following sentence to the <IfModule mime_module> </IfModule> tab:

AddType application/x-httpd-php .php

3. PHP configuration and Path

PHPIniDir "f:\Program Files\php54"

These are the most critical and essential configurations.

Other configurations:

In the PHP Directory, there are two configuration files: php. ini-development and php. ini-productor. Change the name to PHP. INI.

1. directory permissions:

[<Directory "F:/Program Files/Apache2.2/htdocs">] with this setting, you can control the Directory of the Access Server.

Note that the directory level must be greater than or equal to [DocumentRoot "F:/Program Files/Apache2.2/htdocs "]

For example: <Directory "F:/Program Files/Apache2.2/htdocs">You can only access the site directory under the htdocs directory.
<Directory "F:/Program Files/Apache2.2>You can access all the site directories under the directory Apache2.2.

2. By default, the file name configuration for accessing the homepage is as follows:

[<IfModule dir_module> DirectoryIndex index.html index.htm index. php </IfModule>]

With this setting, you can control the default homepage of the site;

Similar to the Host Header configured on the IIS server;

3. Logs

The logs/access. log file records user access, accessed IP pages, and other information;

4. Configure error message

# Some examples:#ErrorDocument 500 "The server made a boo boo."#ErrorDocument 404 /missing.html#ErrorDocument 404 "/cgi-bin/missing_handler.pl"#ErrorDocument 402 http://FREESKYC-B2D592.bavo/subscription_info.html#

Ii. multi-site configuration

Principle: when a user accesses a server with the same IP address through a domain, apache on the server directs different domain names to different or identical folders on the server. This process is also called a virtual host;

1. directory permissions:

[<Directory "F:/Program Files/Apache2.2/htdocs">] with this setting, you can control the Directory of the Access Server.

Note that the directory level must be greater than or equal to [DocumentRoot "F:/Program Files/Apache2.2/htdocs "]

For example, <Directory "F:/Program Files/Apache2.2/htdocs"> can only access the site Directory under the htdocs Directory.
<Directory "F:/Program Files/Apache2.2> you can access all site directories under the Directory Apache2.2

2. Load multi-site components:

The configuration file of apach is near the bottom.

# Include conf/extra/httpd-vhosts.conf

Remove the # sign to load the component;

3. Configure the multi-site components

In the apach installation directory

Conf \ extra \ httpd-vhosts.conf

Find this file for configuration

4. configuration instructions:

NameVirtualHost *: 8080 indicates the port number, which must be in the same way as the apach configuration file.

ServerAdmin: the Administrator's email address. You can set different email addresses for different sites. If you do not set them, the Administrator email address in the apach configuration file is found by default;

DocumentRoot is the virtual directory pointed

ServerName: The domain name or IP address to bind

ServerAlias bind multiple domain names

ErrorLog error log storage path to create different error logs for different sites

CustomLog Log File

You only need to configure the above

For example:

<VirtualHost *:8080>DocumentRoot "F:/Program Files/www/bcom"ServerName 127.0.0.3:8080</VirtualHost>

You can copy the above Code and change the Directory and bound domain name to have multiple sites.

Note that,

* The directory permission in apach must correspond to the directory of this multi-site
That is:
<Directory "F:/Program Files/www">

* After many sites are configured, apach will not go to the previous default site.

This statement does not work: DocumentRoot "F:/Program Files/apach/htdocs"

* If the domain name is not saved in the address bar, apach automatically points to the first site directory in the multi-site configuration.

The above is all the content in this article. I hope it will be helpful to you, and I also hope to provide more support for the customer's home!

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.