PHP Basics-Environment Building

Source: Internet
Author: User

Main:

    1. Environment construction
    2. Site Configuration

  

One, Environment construction

1) Web Run process:

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

2) 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代码

3) 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"

4) 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   " Mode 1 "<filesmatch" \.php$ ">    SetHandler application/x-httpd-php</filesmatch> #指定后缀使用php语言模块解析:" Mode 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

5) PHP Configuration:

1. 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 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

2. 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
Second, site configuration

1) Single-site 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/"
<Directory "d:/amp/www/" >
#当一个请求中没有给定请求的文件名有没有默认网页 (home), show file list
Options Indexes FollowSymLinks
#允许分布式权限配置 write. htaccess files in both sites
AllowOverride All
Require all granted
#设置该文件夹下的 "Default page" (Home)
DirectoryIndex index.php index.html
</Directory>

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

2) 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 [email protected]    #站点根目录   documentroot "D:/www"    #站点绑定的域名   ServerName www.test.com    #站点别名 (usually without the WWW domain name)    serveralias test.com    #错误日志的存储位置, Logs directory in the Apache directory    errorlog "Logs/test-error.log"    #正常访问日志的存储位置, logs directory in the Apache directory, common refers to the log of the record rule name    Customlog "Logs/test-access.log" common    #针对目录的详细配置    <directory "d:/www" >        #允许所有访问        #        allow to Require all granted        #允许分布式权限配置 (allows override) (. htacess) allowoverride all        # Represents the file structure that is allowed to display the site directory (it can be set to-if you do not want to display)        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

3) 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

PHP Basics-Environment Building

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.