Efficient Analysis of Apache service configuration in linux

Source: Internet
Author: User

You may encounter many problems when learning about linux services. Here we will introduce how to configure the Apache service in linux. Here we will share with you.

1. Back up the master configuration file of the Apache service

[Root @ KCentOS5C ~] # Cp/etc/httpd/conf/httpd. conf/etc/httpd/conf/httpd. conf. backup

2. Configure the main configuration file of the Apache service in linux

[Root @ KCentOS5C ~] # Vi/etc/httpd/conf/httpd. conf

Here we mainly change the following parameters:

ServerName *: 80

Configure the Apache server name. If there is a domain name, enter the correct server name.

Include conf. d/*. conf (/etc/httpd/conf. d)

Confirm the path for storing the Apache extension configuration file.

3. view the Nagios webpage configuration Template File

[Root @ KCentOS5C ~] # Less nagios-2.9/sample-config/httpd. conf

# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER

# Last Modified: 11-26-2005

#

# This file contains examples of entries that need

# To be ininitialized ated into your Apache web server

# Configuration file. Customize the paths, etc.

# Needed to fit your system.

# Setting for nagios

ScriptAlias/nagios/cgi-bin "/usr/local/nagios/sbin" ### sets the system path of the Nagios CGI execution directory.

# SSLRequireSSL

Options ExecCGI

AllowOverride None

Order allow, deny

Allow from all

# Order deny, allow

# Deny from all

# Allow from 127.0.0.1

AuthName "Nagios Access"

AuthType Basic

AuthUserFile/usr/local/nagios/etc/htpasswd. user ### access the user account library file is specified here.

Require valid-user

Alias/nagios "/usr/local/nagios/share" ### sets the system path of the Nagios webpage URL.

# SSLRequireSSL

Options None

AllowOverride None

Order allow, deny

Allow from all

# Order deny, allow

# Deny from all

# Allow from 127.0.0.1

AuthName "Nagios Access"

AuthType Basic

AuthUserFile/usr/local/nagios/etc/htpasswd. user ### access the user account library file is specified here

Require valid-user

{###### Add the # setting for nagios section to the end of/usr/local/apache/conf/httpd. conf.

Use/usr/local/apache/bin/apachctl configtest to check configuration -- help view ##########}

Basically, this file can be used directly. According to the AuthUserFile item specified in this configuration file, it specifies that the account list library file of Valid users of Nagios is accessed through Apache. You need to use the htpasswd command to add users to this list library. By default, the file htpasswd. user does not exist in the/usr/local/nagios/etc/directory. Therefore, you must manually add the file. Please note that htpasswd created as root. the permission of the user file should be changed to the nagios group ownership immediately after the file is created, and the read and write permissions of users in the nagios group should be added.

4. Integrate the Nagios web page configuration file into Apache

Copy and rename the Nagios web page configuration file as the Apache extension configuration file to the/etc/httpd/conf. d/directory of Apache extension configuration file.

[Root @ KCentOS5C ~] # Cp nagios-2.9/sample-config/httpd. conf/etc/httpd/conf. d/nagios-httpd.conf

5. Create a Nagios web page to access the user account file (this must be consistent with the path file name specified by AuthUserFile in the Nagios web page configuration file)

[Root @ KCentOS5C ~] # Touch/usr/local/nagios/etc/htpasswd. user

6. Modify the owner of the Nagios web page to access the user account file

[Root @ KCentOS5C ~] # Chown nagios. nagios/usr/local/nagios/etc/htpasswd. user

7. Add read and write permissions for members of the same group to access the user account files on the Nagios webpage (this is mainly assigned to the apache user)

[Root @ KCentOS5C ~] # Chmod g + wr/usr/local/nagios/etc/htpasswd. user

8. view attributes of the user account file accessed on the Nagios webpage

[Root @ KCentOS5C ~] # Ll/usr/local/nagios/etc/htpasswd. user

-Rw-r -- 1 nagios 0 Oct 5/usr/local/nagios/etc/htpasswd. user

9. Add the htpasswd. user

I added a kanecruise user whose password is 123456.

[Root @ KCentOS5C ~] # Htpasswd-m/usr/local/nagios/etc/htpasswd. user kanecruise

New password: 123456

Re-type new password: 123456

Adding password for user kanecruise

10. Check the usage of htpasswd. Here I will explain some important and commonly used methods.

[Root @ KCentOS5C ~] # Htpasswd

Usage:

Htpasswd [-javaspsd] passwordfile username

Htpasswd-B [javaspsd] passwordfile username password

Htpasswd-n [mdps] username

Htpasswd-nb [mdps] username password

◆-C Create a new file.

Create a new account library file.

◆-N Dont update file; display results on stdout.

◆-M Force MD5 encryption of the password.

Add a new user with MD5 password encryption.

◆-D Force CRYPT encryption of the password (default ).

◆-P Do not encrypt the password (plaintext ).

Add a new user whose password is not encrypted.

◆-S Force SHA encryption of the password.

Add a new user with SHA password encryption.

◆-B Use the password from the command line rather than prompting for it.

◆-D Delete the specified user.

Deletes a specified user.

On Windows, NetWare and TPF systems the-m flag is used by default.

In Windows, NetWare, and TPF operating systems, the "-m" parameter (enabling MD5 encryption) is used by default.

On all other systems, the-p flag will probably not work.

The "-p" parameter in all other operating systems (encryption is not enabled) may cause failure.

11. Check the htpasswd account file

[Root @ KCentOS5C ~] # Cat/usr/local/nagios/etc/htpasswd. user

Kanecruise: $ apr1 $ Qwk9h/... $ HaRakpabADGZL10dwPcrx1

The user is added correctly, and the passwords are encrypted in MD5 mode.

The preceding section describes how to configure the Apache service in linux.
 

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.