LinuxApacheWeb server ultimate tutorial

Source: Internet
Author: User
Tags http authentication perl script
Article Title: LinuxApacheWeb server ultimate tutorial. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
According to a survey conducted by the famous WWW Server Survey Company, more than 50% of WWW servers in the world are using Apache, which is the world's top WEB server. The emergence of Apache is dramatic. After the ncsa www server project pause, those who use the ncsa www server began to exchange their patches for the server, and they soon realized that it was necessary to set up a forum to manage these patches. In this way, the Apache Group was born, and then the Group created Apache on the basis of NCSA.
  
  
  
The main features of Apache are:
  
. Can run on all computer platforms;
  
. Supports the latest HTTP 1.1 protocol;
  
. Simple and powerful file-based configuration;
  
. Supports General Gateway Interface CGI;
  
. Supports virtual hosts;
  
. Supports HTTP authentication;
  
. Integrate the Perl script programming language;
  
. Integrated proxy server;
  
. Custom server logs are available;
  
. Supports server-side inclusion commands (SSI)
  
. Supports Secure Socket Layer (SSL)
  
Tracking the user session process;
  
. Supports FastCGI;
  
Java Servlets is supported.
  
  
  
Install Apache
  
  
  
Next we will start a long journey to conquer Apache. Through step-by-step demand instances, we will learn how to use Apache step by step, from getting started to being proficient.
  
  
  
  
System Requirements
  
Running Apache does not require too many computing resources. It runs well on a Linux system with 6-10 MB hard disk space and 8 mb ram. However, running Apache alone may not be what you want to do. More likely, you want to run Apache to provide the WWW Service, start the CGI process, and make full use of all the amazing functions that WWW can provide. In this case, you need to provide additional disk space and memory space that reflect the load requirements. That is to say, if you only start the WWW Service, you do not need too many system resources, but you need more system resources to provide services to a large number of customers.
  
Obtain Software
  
You can get the latest Apache version in the http://www.apache.org. Almost all Linux distributions contain the Apache Software Package. You can also use it directly.
  
Note that there are two types of Apache Software Packages: source code, which needs to be re-compiled after downloading, and executable files, which can be decompressed after downloading.
  
  
  
  
  
Install software
  
You can install the Apache server in the following three ways.
  
  
  
1. if Apache is installed in the Linux version, select the httpd service when selecting the server to be installed. The Linux installation program automatically installs Apache, make basic configurations.
  
2. Use the executable file package, which is suitable for beginners who are not familiar with compilation, because it is relatively simple.
  
Download the software package apache_1.2.4.e.tar.gz
  
Tar xvzf apache_1.2.4.e.tar.gz
  
This completes the installation, simple!
  
If you are using RedHat Linux, You can also download the apache_1.2.4.rpm software installation package, and then install it using the rpm-ivh apache_1.2.4.rpm command.
  
3. If you want to make full use of the Apache server, you must compile Apache to customize its functions.
  
Download the apache_1.2.4.tar.gz software package containing the apachesource code, unbind it with the tar command, change the current directory to the src directory of the Apache source code release, and copy the Configuration sample file (Configuration. tmpl) as the Configuration file;
  
Edit the Configuration options in the Configuration file:
  
Makefile configuration options: Some compilation options:
  
. "CC =" specifies the compilation software used for a row, which is generally "CC = gcc ";
  
. If you need to specify the additional flag (parameter) to the C compilation software, you can use:
  
EXTRA_CFLAGS =
  
EXTRA_LFLAGS =
  
. If the system requires special libraries and include files, you can specify them here:
  
EXTRA_LIBS =
  
EXTRA_INCLUDES =
  
If you want to change the code optimization settings, you must remove the following comments. However
  
Then change it to the value you need:
  
# OPTIM =-O2
  
Rule Configuration option: used to determine what features are required. Generally, this option does not need to be changed.
  
Module configuration: the module is a component of Apache and adds new features to the Apache kernel. By using module configuration, you can customize the functions required on the Apache server, which is also a manifestation of Apache flexibility. The module configuration line is as follows:
  
AddModule modules/standard/mod_env.o
  
If you need the functions of the Apache server, add the module to the Configuration file Configuration using the AddModule statement.
  
The following table lists the functions of Apache modules:
  
Module name function default
  
Mod_access provides Host-Based Access Control Command y
  
Mod_actions can run the MIME-type CGI script or HTTP Request Method y
  
Mod_alias can execute URL redirection service y
  
Mod_asis enables documents to be sent to client y without an HTTP Header
  
Mod_auth supports user name and password stored in text files for authentication y
  
Mod_auth_dbm support using DBM file storage basic HTTP Authentication n
  
Mod_auth_mysql supports using MySQL database for basic HTTP Authentication n
  
Mod_auth_anon allows anonymous access to the region y to be authenticated
  
Mod_auth_external supports third-party authentication n
  
Mod_autoindex automatically generates a dynamic directory list y when the index file is missing.
  
Mod_cern_meta provides support for metadata n
  
Mod_cgi supports CGI y
  
Mod_dir can redirect any request to the command without the tail slash character y
  
Mod_env enables you to pass environment variables to CGI or SSI script n
  
Mod_expires lets you determine how Apache handles Expires y when the server responds to a request
  
Mod_headers can operate the HTTP Response Header labeled y
  
Mod_imap provides graph ing support n
  
Mod_include enables SSI n
  
Mod_info provides a comprehensive description of server configuration y
  
Mod_log_agent allows users to store proxy information in separate log files. n
  
Mod_log_config supports logging y
  
Mod_log_referer provides the function of writing the Referer header in the request to logs. n
  
Mod_mime is used to provide meta information about documents to the client. y
  
Mod_negotiation provides support for content negotiation y
  
Mod_setenvif enables you to create custom environment variable y
  
Mod_speling enables you to process URL requests containing spelling or case-insensitive characters n
  
Mod_status allows administrators to manage Apache y through the WEB
  
Mod_unique_id provides each request with a unique identifier n under special conditions.
  
  
Run "./configure" in the src directory ";
  
Compile Apache: Execute the command "make ";
  
Depending on the performance of the machine, after 5-30 minutes of compilation, you are done.
  
Copy the compiled executable file httpd to the/etc/httpd/bin directory;
  
Copy the configuration files of Apache release: access. conf, httpd. conf, mime. types, and srm. conf to the/etc/httpd/conf directory. So far, the installation is complete.
  
  
Notes
  
In Red Hat Linux 6.0, Apache stores all its configuration files and log files in the "/etc/httpd" directory, "/etc/httpd/conf" is the configuration file, and "/etc/httpd/log" is the log file.
  
At the same time, it will create a "/home/httpd" directory and create three subdirectories under it: "html/": store HTML (home page) files under this directory; "cgi-bin/": Some CGI programs can be stored in this directory; "icons/": some icons that come with the server are in this directory.
  
Configure Apache basics to run the WWW Server
  
The configuration files of Apache server software mainly include: "access. conf ": used to set the access mode and environment in the system;" httpd. conf ": used to set the basic environment for server startup;" srm. conf ": Mainly used for setting file resources;" mime. type: record the MIME format that the Apache server can recognize.
  
Before proceeding, we must tell you that Apache has adopted a series of default values during installation and has enabled the WWW server to run. You only need to connect the host installed with Linux + Apache to the Internet, and then store the home page under the "/home/httpd" directory.
  
The following describes the meanings of some of the most important configuration options, so that you can prepare the server with the minimum effort and minimum configuration.
  
  
Httpd. conf
  
Tpd. conf is the main configuration file. It tells the server how to run it.
  
1. ServerType standalone | inetd
  
This configuration option specifies how to run the WEB server. Apache can run servers in two ways: standalone (independent) and inetd (run by inetd ). The standalone parameter indicates that a WEB service process listens for client requests in the background in a separate waiting process. If yes, a sub-process is generated to serve it. The inetd parameter indicates that the WEB service is not supported in the form of a separate waiting process. Instead, the super server Inetd waits for the process to do the work. When it receives a WEB service request from a client, it starts a WEB service process to serve it. From a functional perspective, the two methods are almost the same. But there is a big difference between them, the difference lies in the server performance. A server process running by inted exits immediately after it finishes requesting services. In standalone mode, the sub-WWW server processes need to be suspended for a period of time before exiting, which provides them with the opportunity to serve new requests again.
  
In standalone mode, there is no overhead for starting a new process for each request, so it is more efficient. inetd mode is recognized
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.