How PHP's environment is built

Source: Internet
Author: User
Tags apache download php language
This article mainly introduces the method of the environment construction of PHP, has a certain reference value, now share to everyone, the need for friends can refer to

Main:

    1. Environment construction

    2. Site Configuration

  

Environment construction

Web Run Flow:

1. Browser input address, enter (send request) 2. Locate the corresponding Web server according to the rules. The rules are as follows:        first find the corresponding IP hosts location in the native Hosts file        : Operating system/system32/drivers/etc/                   "Administrator opens editor to save this file"        if host is not found, To the Internet to find the corresponding IP (DNS server)        if not found, then terminate the request, return "server not found" prompt 3.    The Web server obtains the corresponding file (that is, the requested file). If necessary to process the file 4)    return the file (or execution result) to the browser (return answer) 5)    The browser receives the file, displays the result

 Command line run PHP script

1 PHP installation directory/php.exe-  f    "php file path              #运行php文件2 PHP installation directory/php.exe-  r    " php script code "             #运行php代码

apache,mysql,php Installation

Planning Software Installation directory: such as d:/amp/

Apache Download: http://www.apache.org/dyn/closer.cgi

Apache installation: Similar to installing general Windows software "slightly"

PHP Installation: Direct decompression can be used

MySQL installation: Similar to installing general Windows software "slightly"

Apache Configuration: Access php

Configuration file Add configuration: "Apache installation directory/config/httpd.conf"

# Load the PHP module, which is a file in the PHP language pack loadmodule php5_module "D:/amp/php/php5apache2_4.dll" #以. PHP End file, find the PHP language module   "Way 1" < FilesMatch "\.php$" >    SetHandler application/x-httpd-php</filesmatch> #指定后缀使用php语言模块解析: "Way 2": AddType application/x-httpd-php. php. Pap. phtml

Restart Apache to test access to PHP files

Apache Configuration Detection command: Run in cmd

Apache Installation location/bin/httpd.exe      -t #没有语法错误, display/return: syntax OK

PHP Configuration:

Time zone configuration

step1:php directory/php.ini-development copy modified to PHP.ini

Step 2: Open PHP.ini Search "ctrl+f shortcut" "TimeZone"

[Date]; Defines the default timezone used by the date functions; Http://php.net/date.timezone;date.timezone =; Configure time zone Date.timezone = PRC

SETP 3:apache configuration file "Apache installation directory/config/httpd.conf"

#php. ini location phpinidir "d:/amp/php"

Step 4: Restart Apache, test time display with ph script file

Module configuration

Open php config file php.ini, search extension_dir Specify Configuration Module directory "module default in PHP directory ext directory"

; Directory in which the loadable Extensions (modules) reside.; Http://php.net/extension-dir; Extension_dir = "./"; On Windows:; Extension_dir = "ext" Extension_dir = "D:/amp/php/ext"

Search for extension= in php.ini, turn on MySQL, PDO module

Extension=php_mysql.dllextension=php_mysqli.dllextension=php_pdo_mysql.dll

Site Configuration

 Single Site Configuration

Configuration in Apache configuration file httpd.conf "Apache installation directory/config/httpd.conf"

Port snooping is 80 port by default: Listen

Listen 80

Site Name: ServerName

ServerName   Www.demo.io

Site path: DocumentRoot Directory Custom Location

"d:/amp/www/" < "d:/amp/www/" > #当一个请求中没有给定请求的文件名有没有默认网页 (First page), show file list    Options Indexes FollowSymLinks # Allows distributed permissions to be configured  both in the site and in the. htaccess file    allowoverride all Require all    granted #设置该文件夹下的 "Default page" (Home)    DirectoryIndex index.php index.html</>

Restart Apache, files in the site "d:/amp/www/" directory can be accessed in the same browser: Www.demo.io

Multi-site Configuration

Turn on multi-site configuration in Apache configuration file httpd.conf

# Virtual Hostsinclude conf/extra/httpd-vhosts.conf

Configure the virtual site in the httpd-vhosts.conf file "Apache Directory/conf/extra/Directory"

#配置第一个站点 <virtualhost *:80>    #配置站点管理员的邮箱, 500 error message is prompted on the page, and the administrator mailbox is listed    ServerAdmin abcx@163.com    # Site root    documentroot "d:/www"    #站点绑定的域名    ServerName www.test.com    #站点别名 (typically a domain name without www)    Serveralias test.com    #错误日志的存储位置, logs directory in the Apache directory    errorlog "Logs/test-error.log"    #正常访问日志的存储位置, logs directory in the Apache directory, Common refers to the record rule name of the log    Customlog "Logs/test-access.log" common    #针对目录的详细配置    <directory "D:/www" >        #允许所有访问        #allow from all        Require all granted        #允许分布式权限配置 (allow rewriting) (. htacess)        allowoverride All        #表示允许显示站点目录的文件结构 (can be set to-if not shown)        Options +indexes    </Directory></VirtualHost>

Set domain name resolution in host File "C:\Windows\System32\drivers\etc\hosts" join

127.0.0.0 www.test.com test.com

Restart Apache, browser access www.test.com

Virtual directory settings

If the demo directory exists in the Www.test.io/demo site directory, you can access

The test directory does not exist in the Www.test.io/Test site directory and is inaccessible. In order to achieve this kind of access

Method: In the Site Directory, before directory configuration, add: Alias/test "D:/www/web"

<virtualhost *:80>    ServerName localhost    documentroot "d:/www/web"    #虚拟目设置    alias/ww  "d:/ Www/web "    <directory" D:/www/web ">        Options indexes followsymlinks        Require all granted    </ Directory></virtualhost>

Summary:

1. Implement access to PHP script files, including connection database access

2. Establish site www.test.com

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

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.