Apache installation and configuration, Apache installation and configuration _ PHP Tutorial

Source: Internet
Author: User
Install and configure Apache. Apache installation and configuration, Apache installation and configuration, Apache1 installation, download apache software www. apache. org2, install as administrator 3, set host name and domain name 4, select Apache installation and configuration, Apache installation configuration
Install Apache

1. download apache software http://www.apache.org

2. Installation

Install as Administrator

3. set the host name and domain name

4. select the installation type

5. customize the installation path

6. start installation

7. installation is complete

8. test:

Enter localhost in the address bar of the browser

Apache Directory structure:

Bin directory:

Apache Main configuration file

Httpd. conf is the main configuration file, which is located in the conf directory.


SeverRoot

Server root directory (apache installation directory)

Example:

ServerRoot "D:/wamp1027"

Listen 80

Listening port

Example:

Listen 80

Set multiple listening ports

Listen 80

Listen 5000.

Load function module

Group name to which the user belongs

Example:

User daemon

Group name

Example:

Group daemon

ServerAdmin

Administrator email

Example:

ServerAdmin 20151027@itcast.net

ServerName

SET domain name (host name)

Example:

# ServerName localhost: 80

DocumentRoot

The root directory of the site. it is mainly used for the ing between the recommended domain name and the Directory.

Example:

DocumentRoot "D:/wamp1027/htdocs"

Domain name function:

1. provide external access (the DNS server of the ISP completes the function)

2. establish a ing relationship between domain names and directories (you only need to configure servername and documentroot in the configuration file)

Directory settings

# Directory configuration

Directory configuration:

Default homepage

DirectoryIndex is mainly used to return the homepage file when only the domain name is specified for the access request and no specific file is specified.

Example:

DirectoryIndex homepage 1 homepage 2

Whether to allow list of directory structures

OptionSIndexEs

Purpose: when the requested homepage file does not exist, whether to list the directory structure is not safe. The website must be closed after going online (do not write this item)

AllowOverride

It is mainly used to set whether to enable the external configuration file (. htaccess)

Set directory permissions

Order

Form 1:

Order deny, allow

Purpose: Allow all requests without explicit rejection.

Form 2:

Order allow, deny

Purpose: reject all requests without explicit permission

Disable deny items and allow items using deny and allow for configuration

Example 1:

Order deny, allow

Deny from 192.168.10.11

Allow from all

All disallow except 192.168.10.11 (not related to the order of deny and specific allow items)

Example 2:

Order allow, deny

Allow from 192.168.10.11

Deny from all

Only access to 192.168.10.11 is allowed, and all others are rejected (it is irrelevant to the order of deny and specific allow items)

Virtual host configuration:

Extends the configuration file httpd-vhosts.conf, located in the extra directory under the conf Directory

Enable domain name-based VM on NameVirtualHost

NameVirtualHost *: 80

VM usage:

# Host configuration items

IP-based host

Requirements:

One company has one server and three NICs.

Nic 1: 192.168.10.11 www.fist.com d:/php_folder/20151027/20151201/first

Nic 2: 192.168.10.22 www.second.com

D:/php_folder/20151027/20151201/second

Nic 3: 192.168.10.33 www.third.com

D:/php_folder/20151027/20151201/second

Configuration steps:

1. use the host file to simulate the DNS server

2. enable loading of the extension configuration file in the master configuration file.

Create a VM in the extended configuration file

Domain name-based configuration

Requirement: Company A has A server with only NIC interfaces

Configure two hosts

192.168.20.11 www.one.com d:/php_folder/20151027/20151201/one

192.168.20.11 www.two.com d:/php_folder/20151027/20151201/two

Example:

Port-based configuration

Requirements:

Company A has A server

A fixed IP address: 192.168.30.11

Use the www.234.com domain name for all common access through port 80.

All administrators are required to use port 5000 for background system management.

Example:

Listening port

Host file

Virtual host configuration

AllowOverride

Used to enable the external configuration file. htaccess

. Htaccess is mainly used for redirection, anti-leeching, and custom error message prompt pages.

You do not need to restart apache to modify the. htaccess file.

The. htaccess file needs to be created using another method stored in the editor.

The. htaccess file only takes effect for the current directory

I. Custom error page

Example 1:

Step 2: enable the external configuration file. htaccess

Step 2: Set the custom error information page in the. htaccess file

Example 2:

Step 2:

Step 2:

Create an image resource directory under the root directory, and create a. htaccess file in this directory. the content is as follows:

Prohibit access to all files in this directory

Step 2:

2. redirection

When you access the files in Directory A in the root directory of the site, the system automatically turns to directory B (or the directory under another host)

Apache working mode

Apache only supports HTML files by default. it supports PHP through modules (plug-ins) and Tomcat to support JSP.

All functions of Apache are extended in the form of modules, which can be understood as plug-ins.

Illustration:

Example:

Apache implements user authentication

Step 1: enable the following functional modules

Step 2:

Use the htpasswd.exe file to create a password file. the runtime environment is cmd.

Htpasswd syntax:

User name of the htpasswd-c password file

The role is to re-create the password file,

Example:

Step 3:

Set authentication method

Syntax:

AuthType Basic

Step 4:

Setting realm is to set a display name for the authenticated folder and display it to the user during access.

Syntax:

AuthName 'prompt information'

Example:

Step 5:

Set the authentication user password file

Syntax:

AuthUserFile 'Directory of the password file'

Example:

Step 6: Set the authentication User name

Authenticate multiple users

Require user 1 user 2 user 3

Authenticate all users

Require valid-user

Add authenticated users

Syntax:

Htpasswd 'user password file' user name

Example:

Delete a user

Syntax:

Htpasswd-D 'user password file' user name

Complete Code example:

Http://www.bkjia.com/PHPjc/1116378.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1116378.htmlTechArticleApache installation and configuration, Apache installation configuration installation Apache 1, download apache software http://www.apache.org 2, installation as administrator installation 3, set host name and domain name 4, select...

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.