Apache installation and configuration, Apache installation configuration
Installing Apache
1. Download Apache software http://www.apache.org
2. Installation
Install as an administrator
3. Set host name and domain name
4. Select the type of installation
5. Custom Installation path
6. Start the installation
7. End of installation
8. Test:
Enter localhost in the address bar of the browser
Apache Directory structure:
Bin directory:
Apache's master configuration file
Httpd.conf is the master configuration file, located in the Conf directory
Severroot
Server root directory (Apache installation directory)
Example:
ServerRoot "d:/wamp1027"
Listen 80
Listening port
Example:
Listen 80
Setting up multiple listening ports
Listen 80
Listen 5000
Load function Module
The group name that the user belongs to
Example:
User Daemon
Group name
Example:
Group Daemon
ServerAdmin
Admin Mailbox
Example:
ServerAdmin 20151027@itcast.net
ServerName
Set the domain name (host name)
Example:
#ServerName localhost:80
DocumentRoot
Site root, which is used primarily to suggest the mapping of domain names and directories internally
Example:
DocumentRoot "D:/wamp1027/htdocs"
The role of the domain name:
1. Provide external access (ISP's DNS server completion function)
2. Establish the mapping relationship between the domain name and the directory internally (as long as you configure it with the ServerName and DocumentRoot options in the configuration file)
Settings related to the directory
#目录相关配置
Directory-related configuration:
Default Home
DirectoryIndex is primarily used when accessing a request that specifies only that the domain name does not specify a specific file, the returned home file
Example:
DirectoryIndex Home 1 First page 2
Whether to allow directory structure to be listed
Options Indexes
Role: When the requested home page file does not exist, whether to allow directory structure, very insecure, the website must be closed after the site (not write this)
AllowOverride
Used primarily to set whether external configuration files (. htaccess) are turned on
Set permissions on the directory
Order
Form 1:
Order Deny,allow
Function: All allowed if no explicit refusal
Form 2:
Order Allow,deny
Function: Reject all without explicit permission
Use Deny and allow to configure with Deny
Example 1:
Order Deny,allow
Deny from 192.168.10.11
Allow from all
Except for 192.168.10.11 rejection, all the rest is allowed (independent of the order of deny and allow specific items)
Example 2:
Order Allow,deny
Allow from 192.168.10.11
Deny from all
Allow only 192.168.10.11 access, all remaining rejects (regardless of the order of deny and allow specific items)
Configuration of the virtual host:
Extension profile httpd-vhosts.conf, extra directory located in the Conf directory
Namevirtualhost opening a domain-based virtual host
Namevirtualhost *:80
Virtual Host use:
#主机配置项
IP-based hosts
Demand:
There's a company that has a server with 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 impersonate the DNS server
2. Open the load of the extension profile in the master configuration file
To create a virtual host in an extension configuration file
Domain-based configuration
Requirements: A company has a server, only the NIC interface
Configuring 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
Demand:
A company has a server
A fixed ip:192.168.30.11
Use the www.234.com domain name for all common access operations via port 80
Requires all administrators to use 5000 ports for management of the backend system
Example:
Listening port
Host File
Virtual Host Configuration
AllowOverride
Used to open the external configuration file. htaccess
htaccess main role is redirect, anti-theft chain, custom error message Prompt page
Modifications to the. htaccess file do not require a restart of Apache
The. htaccess file needs to be created using the editor's Saved method
. htaccess files are only valid for the current directory
One, custom error page
Example 1:
1th Step: Open the external configuration file. htaccess file
2nd Step: Set the custom error information page in the. htaccess file
Example 2:
1th Step:
2nd Step:
Create an Image resource directory under the root directory, and create a. htaccess file in this directory with the following contents:
Disable access to all files in this directory
3rd Step:
Second, redirect
Automatically turn to B directory (or directory under another host) when accessing files within a directory in the root directory of the site
Apache's working mode
Apache supports only HTML files by default, PHP is supported through modules (plugins), and can be connected to Tomcat to support JSPs.
All the functions of Apache are implemented in the form of modules, which can be understood as plugins.
Graphic:
Example:
Apache to enable user authentication
First step: Turn on the following function modules
Step Two:
Create a password file using the Htpasswd.exe file and run the environment as CMD
HTPASSWD Syntax:
Htpasswd-c Password File user name
function is used to recreate the password file,
Example:
Step Three:
Set up authentication methods
Grammar:
AuthType Basic
Fourth Step:
Setting up Realm is a display name for the Certified folder, which is displayed to the user when the user accesses it.
Grammar:
AuthName ' Hint information '
Example:
Fifth Step:
Set the authentication user password file
Grammar:
AuthUserFile ' The directory where the password file resides '
Example:
Sixth step: Set the Authentication user name
Authentication for multiple users
Require user User 1 users 2 users 3
Certification for all Users
Require Valid-user
Add Authenticated Users
Grammar:
htpasswd ' User password file ' user name
Example:
Delete User
Grammar:
htpasswd-d ' User password file ' user name
Complete code example:
http://www.bkjia.com/PHPjc/1116378.html www.bkjia.com true http://www.bkjia.com/PHPjc/1116378.html techarticle Apache installation and configuration, Apache installation configuration installation Apache 1, download Apache software http://www.apache.org 2, install as an administrator to install 3, set the hostname and domain 4, select ...