实例:创建一个用户clinuxer
cd /var/www/html
/usr/bin/htpasswd -c /usr/local/apache/passwd/.htpasswd
在httpd.conf文件中设置该目录允许采用.htaccess进行用户身份认证
vi /etc/httpd/conf/httpd.conf
Alias /test "/var/www/html/"
Option Indexes MultiViews //允许列目录
AllowOverride AuthConfig //启用用户身份认证
Order deny,allow
Allow from all //允许所有用户访问
在/var/www/html目录下新建一个.htaccess文件
touch .htaccess
vi .htaccess
AuthName "Test Zone"
AuthType Basic
AuthUserFile /usr/local/apache/passwd/.htpasswd
require user clinuxer
(7).日志统计分析
编辑Webalizer配置文件
vi /etc/webalizer
LogFile /var/log/httpd/access_log
OutputDir /var/www/useage
Incremental yes
配置虚拟目录
vi /etc/httpd/conf/httpd.conf
Alias /webalizer/ "/var/www/usage/"
AllowOverride AuthConfig
Order deny,allow
Allow from all
创建.htaccess文件
vi /var/www/usage/.htaccess
AuthName "Test Zone"
AuthType Basic
AuthUserFile /usr/local/apache/passwd/.htpasswd
require user clinuxer
创建clinuxer用户
htpasswd -mb .htpasswd clinuxer 123
生成统计文档
在虚拟终端:webalizer
客户端访问
http://ServerName或IP/webalizer
(8).Apache服务器启动,停止,重启
service httpd start
service htttd stop
service httpd restart
2.源码安装Apache
(1).用tar命令释放源代码包
tar zxvf httpd-*.tar.gz
(2).使用./configure命令进行编译前的配置工作
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
(3).编译
make
(4).运行
make install
(5)./usr/local/apache2中的子目录
bin //保存Apache服务器运行和管理所需的执行程序
lib //保存Apache服务器运行所需的库文件
conf //保存Apache服务器的配置文件
htdocs //Apache服务器的文档根目录
manual //Apache服务器的帮助手册文件
man //Apache服务器的手册页文件
logs //Apache服务器的日志文件
(6).使用apachectl脚本启动,停止,重启服务器
/usr/local/apache2/bin/apachectl start
/usr/local/apache2/bin/apachectl stop
/usr/local/apache2/bin/apachectl restart