"PHP Introductory Tutorial One" installation WAMP environment

Source: Internet
Author: User
Tags mysql command line

This tutorial is mainly for PHP interview and entry considerations, the content is relatively simple, master do not spray. First, let's study the installation of Wamp environment, Wamp is the abbreviation of Windows + Apache + mysql + PHP, this article describes the latest version of the installation. In fact, in the Windows Development environment has a suite of integrated environment Wamp can be used directly, but for us to learn a language, but also to learn its environment, so configuration installation is also very important. For production release, our most important thing is to learn about the lamp environment, which is installed in a Linux environment. We will introduce the next tutorial. Because this is necessary for a phper. Okay, so let's start learning.

Installing the WAMP Environment 1 Apache installation 1.1 directory

We'll download Http://www.apachehaus.com/cgi-bin/download.plx?dli=hpXRzMVVBFjTEN2aSd0Y0okVOpkVFVVcNdEbuJVQ from the official website.

Apache Haus This is a new name, in fact it's apache2.4.

After the download is complete, unzip to the directory you need.

Bin:apache binary executable file for Apache operation. The main implementation of the file Httpd.exe

Conf: Configuration file directory, Master Profile httpd.conf, additional httpd-vhosts.conf in extra directory to configure virtual host

Htdocs:apache the default root directory

Include:apache contains the C library

Logs: Records Apache logs including installation logs, access logs, error logs, etc.

Modules for Modules:apache

1.2 Registration Service

For the non-installed version of Apache we need to manually register the HTTPD service.

Install a httpd service named myServiceName with the following command,-n name, default service name apache2.4

httpd.exe -k install -n "MyServiceName"

The removal of the httpd service can be used:

httpd.exe -k uninstall

Start the httpd service

httpd.exe -k start -n "MyServiceName"

Stop httpd Service

httpd.exe -k stop -n "MyServiceName"

After the Windows Enrollment service succeeds, we can see in the list of services:

Again, we can start the service like this

Stop Service

1.3 Adding a Host domain name

Because there is no DNS, we need to manually add the required host name in the test environment, modify the file C:\Windows\System32\drivers\etc\hosts

127.0.0.1 localhost zf2-tutorial.localhost

This allows us to add localhost and zf2-tutorial.localhost two domain names, which will be mapped to our local address, plus a space to add more.

Once added, let's test it and see that this page shows that your Apache has been installed successfully.

1.4 Adding a virtual host

In general, in the Apache environment of Windows add a site, do not mind directly modify the main configuration file, and the master profile modification can only correspond to one site.

So we can add multiple sites by adding a virtual host. Modify the Conf\extra\httpd-vhosts.conf file

Add the following code

<virtualhost *:80>#设置站点方位端口, default is 80 port
documentroot "E:\ZendSkeletonApplication-master\ZendSkeletonApplication-master\public"#网站根目录
SETENV application_env "development"#设置应用环境变量
ServerName zf2-tutorial.localhost#设置服务器名, need to correspond with the Hosts file
<directory "E:\ZendSkeletonApplication-master\ZendSkeletonApplication-master\public" >#目录权限设置
DirectoryIndex index.php#设置默认入口文件
allowoverride All
Require All granted#apche中新的配置限制ip访问目录的方法, this means that any IP is allowed to access this directory
</Directory>
</VirtualHost>

AllowOverride parameter Description

The rewrite rule is usually written in the. htaccess file when the URL is rewritten using the Apache rewrite module. However, to enable Apache to read the contents of the. htaccess file properly, you must configure the directory where the. htaccess is located. From security considerations, the AllowOverride property of the root directory is generally configured to disallow any override, i.e.:

< Directory/>
AllowOverride None
</directory>

When AllowOverride is set to None, the. htaccess file is completely ignored. When this directive is set to all, any directives with the ". htaccess" Scope are allowed to appear in the. htaccess file.

For URL rewrite, at a minimum, you need to set the directory to:

< directory/myblogroot/>
AllowOverride FileInfo
</directory>

For URL rewrite, at a minimum, you need to set the directory to:

Authconfig

Allows the use of instructions related to certification authorizations (Authdbmgroupfile, Authdbmuserfile, AuthGroupFile, AuthName, AuthType, AuthUserFile, Require, etc.).

FileInfo

Directives that allow the use of control document types (DefaultType, ErrorDocument, Forcetype, languagepriority, SetHandler, Setinputfilter, Setoutputfilter, Add* and remove* directives in mod_mime, etc.), instructions for controlling document metadata (Header, Requestheader, Setenvif, Setenvifnocase, Browsermatch, Cookieexpires , Cookiedomain, Cookiestyle, cookietracking, cookiename), mod_rewrite directives (Rewriteengine, rewriteoptions, RewriteBase, Rewritecond, Rewriterule), and the action directive in mod_actions.

Indexes

Allows the use of commands that control the index of the directory (Adddescription, AddIcon, addiconbyencoding, Addiconbytype, DefaultIcon, DirectoryIndex, FancyIndexing, Headername, Indexignore, indexoptions, Readmename, etc.).

Limit

Allows the use of commands that control host access (Allow, Deny, Order).

Options[=option,...]

Allows the use of commands (options and Xbithack) that control the functionality of the specified directory. You can append a comma-delimited list of options (no spaces) after the equals sign to control which options are allowed for the option directive.

Require parameter description

    1. ################################################
    2. Configuration on the 2.2
    3. Order Deny,allow
    4. Deny from all
    5. Configuration on the 2.4
    6. Require all denied
    7. ################################################
    8. Configuration on the 2.2
    9. Order Allow,deny
    10. Allow from all
    11. Configuration on the 2.4
    12. Require all granted
    13. #################################################

Order Allow,deny

Can be understood as first permission, after exclusion,

Then the next sentence is to write a deny from IP. To deny these IP access

Order Deny,allow

Can be understood as first excluded, then allowed

So the next sentence is to write allow from IP. To limit the number of IP access

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here are a few examples of configurations on version 2.4
1. Allow only hosts with IP 192.168.1.1 access

    1. <RequireAll>
    2. Require all granted
    3. Require IP 192.168.1.1
    4. </RequireAll>

2. Allow only host access to the 192.168.0.0/24 network

    1. <RequireAll>
    2. Require all granted
    3. Require IP 192.168.1.0/24
    4. </RequireAll>

3. Prohibit 192.168.1.2 host access, others are allowed to access,

    1. <RequireAll>
    2. Require all granted
    3. Require not IP 192.168.1.2
    4. </RequireAll>

4. Allow all Access,

    1. Require all granted
    2. Note that this can not be added to the container ...
    3. Direct, write in ... It's going to be there.

5. Deny all Access,

    1. Require all denied
2 PHP Installation

Currently, the latest version of PHP for Windows is PHP 5.6

Http://windows.php.net/downloads/releases/php-5.6.5-Win32-VC11-x86.zip

After the download is done, the configuration file with the Php.ini-development development under the main directory has the same name as PHP.ini

modifying extension paths

Extension_dir = "D:\software\php\ext"

To Extension=php_mysql.dll the former;

Load the corresponding module to remove the front;

Modify time zone, domestic with PRC

Date.timezone = UTC

Modify the Apache master configuration file httpd.conf

After the LoadModule list, add

LoadModule php5_module "D:/software/php/php5apache2_4.dll"
Phpinidir "D:/software/php/php.ini"

Added Apache support for PHP file types within the Ifmodule mime_module tag

# ADD Type for PHP
AddType application/x-httpd-php. php. html. htm

If you need to have a rewrite module, you can open the comment (for URL rewriting in the. htacess file)

LoadModule Rewrite_module modules/mod_rewrite.so

Here, the integration of Apache and PHP has been completed,

Add a test file to view the configuration under the root directory

<? PHP Phpinfo ();? >

success!

3 MySQL Installation

MySQL installation under Windows is still relatively simple and can be described as "easy + enjoyable".

First we go to MySQL official website download community version http://dev.mysql.com/downloads/file.php?id=455349

-Select Install

-Confirm licence

-Choose the installation type to customize, remove those huge useless, such as Workbench, recommend yourself to install a lightweight client such as SQLyog

-Select the appropriate development components, with odbc,jdbc,c++ connector,.net connector, etc.

-Being installed

-Installation Complete configuration parameters default port number 3360

-Configure root users and new users

-Configure service name and run account

After the installation is complete, we start the MySQL service/turn off the MySQL service by default installation has started

Startup Success Instructions installation is complete, it is recommended to install the database client, such as SQLyog, I always use this, very useful.

You can then log in to the database using MySQL command line client (start-up menu), or you can go to the command lines MySQL directory to operate

To enter the command line, we first create a database

Create DATABASE test;

Use this database

Use test;

Create a data table

CREATE TABLE Person (

ID int auto_increment,

Name varchar (255) is not NULL,

Primary KEY (ID)

);

Inserting data

Intert into the person values (1, ' David ');

Finally we add the test file

<?PHP//link MySQL    $link=mysql_connect("localhost", "root", "") or die(' Faild to connect! '); //Select Database Library    mysql_select_db("Test"); //Execute SQL    $result=mysql_query("Select Id,name from Person"); Print"<table border=1>"; Print"<tr><th>ID</th><th>Name</th></tr>"; //To remove an array of rows     while($t _result=Mysql_fetch_array($result)){      $tr= "<tr><td>".$t _result["id"]. " </td><td> ".$t _result["Name"]. " </td></tr> "; Print $tr; }    Print"</table>";?>

Link Successful! Data display is normal!

4 references

Http://blog.sina.com.cn/s/blog_9082c1e501018v5x.html

Http://www.chinaz.com/server/2010/0129/105397.shtml

Http://httpd.apache.org/docs/current/platform/windows.html#down

5 Summary

This document briefly describes the installation of the WAMP environment, which is mainly used for development and testing, the production environment is best deployed on Linux, if you use the server also mind the use of IIS, do not use the Apache on Windows. We'll cover the installation of the lamp environment on Linux, and we'll look into the configuration file. The configuration of MySQL will also be detailed in the following articles!

                          

"PHP Introductory Tutorial One" installation WAMP environment

Related Article

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.