Apache, Web software, Apache installation, common configuration items, zone configuration, log analysis

Source: Internet
Author: User

Apache installation

Specific steps:

1. Preparatory work

To avoid port conflicts, program conflicts, and so on, it is recommended that you uninstall the httpd and related dependencies (if any) that are installed using the RPM method. :

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image002 "border=" 0 "alt=" clip_ image002 "src=" http://s3.51cto.com/wyfs02/M00/74/AF/wKiom1YmBRXBvzztAABMpva4XCI791.jpg "height="/>

2. source code compilation and installation

Insert the installation disc and mount it into the disc directory, release the httpd source package to the/usr/src/directory, and switch to the expanded source directory.

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image004 "border=" 0 "alt=" clip_ image004 "src=" http://s3.51cto.com/wyfs02/M01/74/AF/wKiom1YmBRaDcbV2AACATN4P6yc460.jpg "height=" Bayi "/>650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px; padding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image006 "border=" 0 "alt=" clip_ image006 "src=" http://s3.51cto.com/wyfs02/M02/74/AF/wKiom1YmBRbTB-WKAAAquf5F91k784.jpg "height="/>

Depending on the actual application needs of the server, different customization options can be set flexibly.

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image008 "border=" 0 "alt=" clip_ image008 "src=" http://s3.51cto.com/wyfs02/M00/74/AF/wKiom1YmBRag7L37AABMj4DPhCw538.jpg "height="/>

In the configuration commands above, the meanings of each option are as follows:

--prefix : Specifies which directory to install the HTTPD service program to.

--enable-so : Enable dynamic load module support, so httpd has the ability to further expand functionality.

--enable-rewrite : Enable Web page address rewriting for site optimization and directory Migration maintenance.

--enable-charset-lite : start character set support to support Web pages that are encoded using a variety of character sets.

--enable-cgi : enables CGI scripting support to extend the application access capabilities of the Web site.

After the configuration is completed, execute the "make&& makes install" command to compile, replace the source code with the executable program, and then complete the final installation process; The compiled HTTPD program and related directories, The files are copied to the preset installation directory (specified by the "--prefix" option when configured).

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image010 "border=" 0 "alt=" clip_ image010 "src=" http://s3.51cto.com/wyfs02/M01/74/AF/wKiom1YmBReTJicJAAAgzvSCtLo971.jpg "height=" "/>"

3. confirm the installation results

Because the installation directory is specified as /usr/local/httpd/, various programs, modules, help files, and so on for the httpd service are copied to this directory.

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image012 "border=" 0 "alt=" clip_ image012 "src=" http://s3.51cto.com/wyfs02/M01/74/AC/wKioL1YmBUCwoqNJAAA95-d-sek657.jpg "height=" "/>"

In the post-installation /usr/local/httpd/ directory, the purpose of the primary subdirectory is as follows:

/usr/local/httpd/bin/ : Various execution Program files for HTTPD service, including main program httpd, Service Control tool APACHECTL, etc.

/usr/local/httpd/conf/ : A variety of configuration files for httpd services, including Master profile httpd.conf, enhanced configuration subdirectory extra/, and more.

/usr/local/httpd/htdocs/ : store Web documents, including default home file index.html, etc.

/usr/local/httpd/logs/ : The log file that holds the HTTPD service.

/usr/local/httpd/modules/ : A variety of module files that store httpd services.

/usr/local/httpd/cgi-bin/ : store various CGI program files.

4. Optimizing execution Paths

By compiling the installed HTTPD service through source code, the program path is not in the default search path, so you can add symbolic links to related programs in order to make the service more convenient to use.

Also available: Echo path= $PATH:/usr/local/httpd/bin/>>/etc/profile &&. /etc/profile && Echo $PATH Way

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image014 "border=" 0 "alt=" clip_ image014 "src=" http://s3.51cto.com/wyfs02/M02/74/AC/wKioL1YmBUCgZk9OAACzn9et-rM305.jpg "height=" 94 "/>

You do not have to enter a lengthy path when you execute the related command again. For example, when you execute "httpd-v" (for viewing a program version), it is equivalent to executing "/usr/local/httpd/httpd-v".

"httpd-t" is used to detect whether the master configuration file is misconfigured.

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image016 "border=" 0 "alt=" clip_ image016 "src=" http://s3.51cto.com/wyfs02/M00/74/AC/wKioL1YmBUGivGmaAAA4NQHbVsk077.jpg "height="/>

5. adding httpd system Services

If you want to add httpd as a system service for management through Chkconfig, you need to establish a controlled service script.

650) this.width=650; "Style=" Background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left : 0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image018 "border=" 0 "alt=" clip_image018 "src=" http://s3.51cto.com/wyfs02/M01/74/AC/wKioL1YmBUGgh3BZAABIzcQTo9M599.jpg "height="/>650 ) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px; padding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image020 "border=" 0 "alt=" clip_ image020 "src=" Http://s3.51cto.com/wyfs02/M02/74/AC/wKioL1YmBUOxA9qYAAHcgjlZUs8216.jpg "height=" 308 "/>650" this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px; padding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image022 "border=" 0 "alt=" clip_ image022 "src=" http://s3.51cto.com/wyfs02/M00/74/AC/wKioL1YmBUSi19bxAABQOeQyzyM599.jpg "height="/>

After successful execution, the HTTPD service will run automatically every time the Linux system enters RunLevel 3 and 5 o'clock. During routine maintenance, you can use the Apachectl tool directly to control the HTTPD service, or you can use the/etc/init.d/httpd script.

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image024 "border=" 0 "alt=" clip_ image024 "src=" http://s3.51cto.com/wyfs02/M02/74/B0/wKiom1YmBRvwZp_AAAAlekY4UnA143.jpg "height=" "/>"

6. determine the site name, IP address

7. Configure and start the HTTPD service

1) Configure HTTPD service

Edit the HTTPD service's master profile httpd.conf, look for the configuration item "ServerName", and add a row of "ServerName www.benet.com" nearby to set the site name.

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image026 "border=" 0 "alt=" clip_ image026 "src=" http://s3.51cto.com/wyfs02/M01/74/AC/wKioL1YmBUWw7retAAEsFb5hzj0504.jpg "height=" 237 "/>

After modifying the configuration of the httpd.conf file, it is recommended to use the APACHECTL command with the "-t" option to check the configuration content (or use the "httpd-t" command). If there is no syntax error, the message "Syntax OK" will be displayed, otherwise you will need to correct the configuration based on the error prompt. :

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image028 "border=" 0 "alt=" clip_ image028 "src=" http://s3.51cto.com/wyfs02/M02/74/AC/wKioL1YmBUXy6KEOAAAtH0prbnA805.jpg "height=" "/>"

2) Start httpd service

Use the script file /usr/local/httpd/bin/apachectl or /etc/init.d/httpd, respectively, through the start, stop, restart options to control, can be used to start, Terminates and restarts the httpd service. After you start the httpd service normally, the TCP protocol's port 80 is monitored by default.

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image030 "border=" 0 "alt=" clip_ image030 "src=" http://s3.51cto.com/wyfs02/M00/74/AC/wKioL1YmBUbiKe5CAABCREAn00A998.jpg "height="/>

8. Deploying Web page Documents

For the newly compiled installation of the HTTPD service, the Web site root directory is located in /usr/local/httpd/htdocs/ , and you need to copy or upload the Web page document of the website to this directory. The HTTPD server has already provided a test Web page named index.html, which displays the string "It works! ") as the default home page when visiting a website.

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image032 "border=" 0 "alt=" clip_ image032 "src=" http://s3.51cto.com/wyfs02/M01/74/AC/wKioL1YmBVWj6qieAAA2qjdBgFs201.jpg "height="/>

9. Accessing the Web site in the client

In the client's Web browser, access to the HTTPD server via a domain name or IP address will allow you to see the page content of the Web site. :

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image034 "border=" 0 "alt=" clip_ image034 "src=" http://s3.51cto.com/wyfs02/M02/74/AC/wKioL1YmBV3zwHLXAADBue1G4zE194.jpg "height=" 189 "/>

View Web site access

The HTTP server uses two types of logs: Access logs and error logs. Both logs and filenames are Access_log and error_log, respectively, in the /usr/local/httpd/logs/ directory.

By viewing the access log file Access_log, you can keep up to date on your Web site's access. Each row in the access log corresponds to an access record that records the client's IP address, the date and time the server was accessed, the requested Web page object, and so on. :

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image036 "border=" 0 "alt=" clip_ image036 "src=" http://s3.51cto.com/wyfs02/M00/74/AC/wKioL1YmBWPihUMUAABl3liwu7k079.jpg "height="/>

By viewing the error log file Error_log, you can provide a reference for troubleshooting server failures. Each line in the error log file corresponds to an error record, with information such as the date and time the error occurred, the type of error event, the description of the error event, and so on. :

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image038 "border=" 0 "alt=" clip_ image038 "src=" http://s3.51cto.com/wyfs02/M02/74/B0/wKiom1YmBUuAw0iZAABSZDxnGFM824.jpg "height="/>

L httpd.conf configuration file

1. Global Configuration Items

ServerRoot : Sets the root directory of the httpd server, which includes subdirectories and files that are required to run the Web site. The default root directory is /usr/local/httpd/, which is the same as the HTTPD installation directory.

Listen : Set the site port number that the HTTPD server listens to, default is 80

User : Sets the user identity when running the httpd process, which defaults to daemon.

Group : Set the group identity when running the httpd process, which defaults to daemon.

ServerAdmin : Set the Administrator e-mail address of the HTTPD server, you can contact the administrator of the Web site in time by this e-mail address.

ServerName : Sets the full hostname of the Web site (that is, hostname + domain name).

DocumentRoot : Sets the root directory of the Web site, which is the actual path of the Web document in the system. This configuration item is relatively easy and serverroot confusing and requires extra attention.

DirectoryIndex : Set the default index page of the site (first page), you can set up a number of home files, separated by a space, the default home file for index.html.

errorlog : Sets the path to the error log file, the default path is Logs/error_log.

LogLevel : Sets the level of logging, with the default level of warn (warning).

Customlog : Sets the path of the access log file, the log type, the default path is Logs/access_log, and the type used is common common format.

Pidfile : Set the file to hold the httpd process number (PID), the default save address is Logs/httpd.pid, and the "logs" directory is located in the Apache server root directory.

Charsetdefault : Sets the default character set encoding used by Web pages in the site, such as UTF-8, gb2312, and so on.

Include : contains the contents of another configuration file. You can put the configuration that implements some special functions into a separate file, and then use the include configuration item to include it in the httpd.conf file, which makes it easy to maintain the configuration functionality independently without affecting the master profile.

The above configuration items are the most important global configuration items in the httpd.conf file.

2. zone Configuration Items

In addition to global configuration items, most of the configurations in the httpd.conf file are included in the zone. A zone configuration item uses a pair of combination tags to define the scope of the configuration item. For example, the most common form of directory area configuration is as follows:

650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;padding-left:0px; padding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" clip_image040 "border=" 0 "alt=" clip_ image040 "src=" http://s3.51cto.com/wyfs02/M00/74/B0/wKiom1YmBVWDwq0FAADY0g-NuWg825.jpg "height="/>

In the above zone definition, a zone configuration for the root directory is set, where the access control-related configuration added is valid only for the root directory, not for global or other directory zones.

This article is from the "Wang Gaoli" blog, make sure to keep this source http://wanggaoli.blog.51cto.com/10422005/1704606

Apache, Web software, Apache installation, common configuration items, zone configuration, log analysis

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.