<b>高效解析Linux系统中配置Apache服务</b>[服务器安全]
本文“<b>高效解析Linux系统中配置Apache服务</b>[服务器安全]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
本文主要讲授在Linux系统中配置Apache服务,此中包含查抄htpasswd帐户文件,查看htpasswd的利用办法,成立Nagios的网页拜候,备份Apache服务的主配置文等知识.
学习Linux系统服务时,你大概会碰到多种问题,这里将介绍在Linux系统中配置Apache服务问题的办理办法,在这里拿出来和大家分享一下.
1.备份Apache服务的主配置文件
[root@KCentOS5C ~]# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.backup
2.Linux系统中配置Apache服务的主配置文件
[root@KCentOS5C ~]# vi /etc/httpd/conf/httpd.conf
这里主要窜改以下这些参数:
ServerName *:80
配置Apache的服务器名,假若有域名的话请填写精确的服务器名.
Include conf.d/*.conf (/etc/httpd/conf.d)
确认Apache扩大配置文件的存放途径.
3.查看Nagios网页配置模板文件
[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 incorporated into your Apache web server
# configuration file. Customize the paths, etc. as
# needed to fit your system.
#setting for nagios
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" ###设定了Nagios的CGI履行目录对应的系统途径.
# 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 ###这里指定了拜候用户帐户库文件.
Require valid-user
Alias /nagios "/usr/local/nagios/share" ###设定了Nagios的网页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 ###这里指定了拜候用户帐户库文件
Require valid-user
{######将#setting for nagios --这一段加到/usr/local/apache/conf/httpd.conf的末尾.
用/usr/local/apache/bin/apachctl configtest 检测配置 --help查看##########}
基本上这个文件可以直接利用.按照这个配置文件中指定的AuthUserFile项,它指定的是通过Apache拜候Nagios的合理用户的帐户名单库文件,需求利用htpasswd号令对这个名单库举行用户的增添.而默许安装环境下在/usr/local/nagios/etc/目录下是没有htpasswd.user这个文件的,所以需求手动增添.请分外注意,用root身份成立的htpasswd.user文件的权限问题,应当在成立该文件完毕后当即更改成nagios用户nagios组的全部权,并且要增添Nagios同组用户读写权限.4.整合Nagios网页配置文件到Apache中
将Nagios网页配置文件作为Apache的扩大配置文件复制改名到Apache的扩大配置文件目录/etc/httpd/conf.d/目录下
[root@KCentOS5C ~]# cp nagios-2.9/sample-config/httpd.conf /etc/httpd/conf.d/nagios-httpd.conf
5.成立Nagios的网页拜候用户帐户文件(这里必必要与Nagios网页配置文件当中AuthUserFile指定的途径文件名一致)
[root@KCentOS5C ~]# touch /usr/local/nagios/etc/htpasswd.user
6.更改Nagios网页拜候用户帐户文件的属主
[root@KCentOS5C ~]# chown nagios.nagios /usr/local/nagios/etc/htpasswd.user
7.对Nagios网页拜候用户帐户文件增添同构成员读写权限(这主如果赋给apache这个系统用户)
[root@KCentOS5C ~]# chmod g+wr /usr/local/nagios/etc/htpasswd.user
8.察看Nagios网页拜候用户帐户文件的属性信息
[root@KCentOS5C ~]# ll /usr/local/nagios/etc/htpasswd.user
-rw-rw-r-- 1 nagios nagios 0 Oct 5 14:05 /usr/local/nagios/etc/htpasswd.user
9.增添htpasswd.user用户
我增添了一个kanecruise用户,口令是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.查看htpasswd的利用办法,这里我就注释一些对比重要和常用的.
[root@KCentOS5C ~]# htpasswd
Usage:
htpasswd [-cmdpsD] passwordfile username
htpasswd -b[cmdpsD] passwordfile username password
htpasswd -n[mdps] username
htpasswd -nb[mdps] username password
◆-c Create a new file.
成立新的帐户库文件.
◆-n Don't update file; display results on stdout.
◆-m Force MD5 encryption of the password.
增添一个MD5口令加密的新用户.
◆-d Force CRYPT encryption of the password (default).
◆-p Do not encrypt the password (plaintext).
增添一个口令不加密的新用户.
◆-s Force SHA encryption of the password.
增添一个SHA口令加密的新用户.
◆-b Use the password from the command line rather than prompting for it.
◆-D Delete the specified user.
删除一个指定的用户
以上是“<b>高效解析Linux系统中配置Apache服务</b>[服务器安全]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |