RedHat6.5  httpd实验的大概步骤

#解包
tar zxf httpd-2.2.17.tar.gz -C /usr/src
#切换到目录
cd /usr/src/httpd-2.2.17/
#编译
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi && make && make install
#确认安装结果
ls /usr/local/httpd/
#优化执行路径
ln -s /usr/local/httpd/bin/* /usr/local/bin/
ls -l /usr/local/bin/httpd /usr/local/bin/apachectl
#查看版本
httpd -v
#添加httpd系统服务
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
vi /etc/init.d/httpd
#!/bin/sh
# chkconfig: 35 85 15
# description: Startup script for the Apache HTTP Server
chkconfig --add httpd
chkconfig --list httpd

#配置域名解析
IP
192.168.174.130
网站名称
www.benet.com
 /etc/hosts修改配置文件

#配置httpd.conf
vim /usr/local/httpd/conf/httpd.conf
97行
ServerName www.benet.com
#检查
/usr/local/httpd/bin/apachectl -t
Syntax OK
#启动httpd服务
[root@lianxi httpd-2.2.15]# /etc/init.d/httpd start
[root@lianxi httpd-2.2.15]# netstat -anpt |grep httpd
tcp 0 0 :::80 :::* LISTEN 54646/httpd
#部署网页文档
[root@lianxi httpd-2.2.15]# cat /usr/local/httpd/htdocs/index.html
<html><body><h1>It works!</h1></body></html>
#在网页上访问
www.benet.com
#查看日志
tail /usr/local/httpd/logs/access_log
登陆信息等
tail /usr/local/httpd/logs/error_log
故障日志 notice是告警

#全局配置
ServerRoot 服务器根目录
Listen 设置监听端口
User 设置运行httpd进程时用户身份
Group设置运行httpd进程时组身份
ServerName 设置web站点
ServerAdmin设置管理员E-mail地址
DocumentRoot 设置网站站点目录
Directorylndex 设置网站默认的索引页(首页)可设置多个首页文件 以空格分开
ErrorLog 设置错误日志文件的路径
LogLevel 设置记录日志的级别路径 默认级别为warn(警告)
CustomLog 设置访问日志路径类型 common(通用格式)
PidFile 设置用于保存httpd进程号(PID)的文件
CharsetDefault 设置字符集
Include 包含一个配置文件内容,可以将一些特殊功能配置放到一个单独的文件中
再将Include配置项将其包含到httpd.conf这样便于独立配置功能的维护而不影响主配置文件

#区域配置
114行
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
Options:配置在特定目录使用哪些特性,常用的值和基本含义如下:
FollowSymLinks: 在该目录下允许文件系统使用符号连接。
AllowOverride:允许存在于.htaccess文件中的指令类型(.htaccess文件名是可以改变的,其文件名由AccessFileName指令决定):
Order:控制在访问时Allow和Deny两个访问规则哪个优先:
Allow:允许访问的主机列表(可用域名或子网,例如:Allow from 192.168.0.0/16)。
Deny:拒绝访问的主机列表。
Deny from all禁止访问

#安装AWStats分析系统
wget http://awstats.sourceforge.net/files/awstats-7.2.tar.gz
tar zxf awstats-7.3.tar.gz
mv awstats-7.3 /usr/local/awstats

#创建配置文件
cd /usr/local/awstats/tools/
chmod +x awstats_configure.pl
./awstats_configure.pl

#指定httpd主配置文件的路径
----- AWStats awstats_configure 1.0 (build 1.9) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).

-----> Running OS detected: Linux, BSD or Unix

-----> Check for web server install

Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):
> /usr/local/httpd/conf/httpd.conf

#设置文件类型
-----> Check and complete web server config file '/usr/local/httpd/conf/httpd.conf'
Warning: You Apache config file contains directives to write 'common' log files
This means that some features can't work (os, browsers and keywords detection).
Do you want me to setup Apache to write 'combined' log files [y/N] ? y
-----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'
File awstats.model.conf updated.

-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y

#指定web站点创建配置文件
-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> www.benet.com
回车

#修改站点统计配置文件
vim /etc/awstats/awstats.www.benet.com.conf
51行
LogFile="/usr/local/httpd/logs/access_log"
204行
DirData="/var/lib/awstats"
#创建目录
mkdir /var/lib/awstats
#执行日志分析,并设置cron任务计划
chmod +x awstats_updateall.pl
./awstats_updateall.pl now
crontab -e
crontab -l
*/5 * * * * /usr/local/awstats/tools/awstats_updateall.pl now
[root@lianxi tools]# /etc/init.d/crond start
[root@lianxi tools]# chkconfig --level 35 crond on
#访问AWStats
为了访问简单我们可以编辑一个配置文件
[root@lianxi tools]# vim /usr/local/httpd/htdocs/awb.html
<html>
<head>
<meta http-equiv=refresh content="0;
url=http://www.benet.com/awstats/awstats.pl?config=www.benet.com">
</head>
<body></body>
</html>

mkdir /var/www/html/accpcom -p
mkdir /var/www/html/benetcom -p
echo "<h1>www.benet.com</h1>" > /var/www/html/benetcom/index.html
echo "<h1>www.accp.com</h1>" > /var/www/html/accpcom/index.html
[root@httpd benetcom]# vim /etc/hosts
192.168.174.101 www.benet.com www.accp.com
127.0.0.1 httpd

基于域名的虚拟主机配置:
[root@httpd benetcom]# vim /usr/local/httpd/conf/extra/httpd-vhosts.conf
<Directory "/var/www/html"> 手动添加
Order allow,deny
Allow from all
</Directory>

NameVirtualHost 192.168.174.101 修改IP地址

<VirtualHost 192.168.174.101>
DocumentRoot "/var/www/html/benetcom" 指定网页根目录
ServerName www.benet.com
ErrorLog "logs/www.benet.com.error_log"
CustomLog "logs/www.benet.com.access_log" common
</VirtualHost>

<VirtualHost 192.168.174.101> 修改IP地址
DocumentRoot "/var/www/html/accpcom" 指定网页根目录
ServerName www.accp.com
ErrorLog "logs/www.accp.com.error_log"
CustomLog "logs/www.accp.com.access_log" common
</VirtualHost>

[root@httpd benetcom]# vim /usr/local/httpd/conf/httpd.conf
ServerName localhost:80
Include conf/extra/httpd-vhosts.conf 388行 把#去掉

/usr/local/httpd/bin/apachectl -t 检查语法
/usr/local/httpd/bin/apachectl restart 重启服务

####登录访问....

httpd基础配置和虚拟主机的配置方法的更多相关文章

  1. nginx的基本配置和虚拟主机的配置

    在Nginx配置文件(nginx.conf)中,一个最简化的虚拟主机配置代码如下: 跟Apache -样,Nginx也可以配置多种类型的虚拟圭机:一是基于IP的虚拟主机,二是基于域名的虚拟主机,三是基 ...

  2. apache2 httpd 基于域名的虚拟主机配置 for centos6X 和debian-8

    全系统虚拟主机: for debian 系统的apache2 域名 虚拟主机

  3. 配置Apache虚拟主机

    实验环境 一台最小化安装的CentOS 7.3虚拟机 配置基础环境 1. 安装apache yum install -y httpd 2. 建立虚拟主机的根目录 mkdir /var/wwwroot ...

  4. linux(十二)___Apache服务器用户认证、虚拟主机的配置

    创建xiangkejin  zhangsan两个用户 可看见文件中创建的两个用户: 建立虚拟目录并配置用户认证 ①建立虚拟目录 /xiangkejin ②在Apache的主配置文件httpd.conf ...

  5. apache中虚拟主机的配置

    一.两种方式:基于域名的虚拟主机和基于IP地址的的虚拟主机 (这里基于前者) 二.作用:实现在同一个web服务器下,同时运行很多个站点(项目) 三.虚拟主机的配置 1.在核心配置文件中加载虚拟主机配置 ...

  6. apache 虚拟主机详细配置:http.conf配置详解

    apache 虚拟主机详细配置:http.conf配置详解 Apache的配置文件http.conf参数含义详解 Apache的配置由httpd.conf文件配置,因此下面的配置指令都是在httpd. ...

  7. apache 多端口配置和虚拟主机配置

    1 打开httpd.conf文件 2 添加端口监听 (找到Lisen 80 在后面添加 Listen 端口号 如Listen 1112) port =>你的端口 project_name=> ...

  8. wamp虚拟主机的配置 .

    开发环境:WAMP 实例一,Apaceh配置localhost虚拟主机步骤 1,用记事本打开apache目录下httpd文件(如:D:\wamp\bin\apache\apache2.2.8\conf ...

  9. Web服务器(Apache)虚拟主机的配置

    一.定义    所谓虚拟主机是指在一台服务器里运行几个网站,提供WEB.FTP.Mail等服务.    二.虚拟主机的实现方法有三种:    基于IP的方法,基于主机名的方法和基于端口的法官法.    ...

随机推荐

  1. 2013暑假总结-SB学习

    经过暑假的学习,使英语原本基础不好的我找到了英语学习的感觉.方向.信心,暑假的这种团队学习英语的感觉才刚刚开始,即将开学了,我们并将保持着这学习的劲头坚持努力的做下去. 暑假35天英语的全职学习,对于 ...

  2. Dynamics CRM 系统自定义部分的语言翻译

    Dynamics CRM 自带语言切换功能,在官网下载所需语言包安装后,在设置语言中就能看到你所添加的语言,勾选要启用的语言应用即可,再打开系统设置--语言就能看到可更改用户界面语言的显示了. 但官方 ...

  3. Linux环境编程导引

    计算机系统硬件组成 总线 贯穿整个系统的一组电子管道称为总线, 分为: 片内总线 系统总线 数据总线DB 地址总线AB 控制总线CB 外部总线 I/O设备 I/O设备是系统与外界联系的通道 键盘鼠标是 ...

  4. Linux 进程等待队列

    Linux内核的等待队列是以双循环链表为基础数据结构,与进程调度机制紧密结合,能够用于实现核心的异步事件通知机制. 在这个链表中,有两种数据结构:等待队列头(wait_queue_head_t)和等待 ...

  5. centos下安装mysql(安装,启动,停止,服务端口查询,用户密码设定)

    http://www.2cto.com/database/201305/208114.html http://smilemonkey.iteye.com/blog/673848 netstat -na ...

  6. Android性能优化之界面UI篇

    1.使用style.color.string.dimen样式来分离xml布局文件,减少代码的重复使用,增加代码复用率,防止hardcode,下面是一个例子: 在定义layout时候,因为每个View或 ...

  7. SpriteBuilder物理对象的父子关系

    注意:打开物理使能(Physics-enabled)的节点忽略他们的父节点关系. 这意味着,一个物理使能的子节点不会随着其父节点移动. 物理引擎对于节点父子关系这个概念毫不知情,因此单独的对待所有物理 ...

  8. LeetCode之“散列表”:Contains Duplicate && Contains Duplicate II

     1. Contains Duplicate 题目链接 题目要求: Given an array of integers, find if the array contains any duplica ...

  9. objc直接通过指针访问对象实例变量

    我们现在来做一件被认为是very bad的事情,如题所示:无论实例变量是私有的.保护的都可以通过地址访问到,并且还可以修改之.这可以称之为所谓的"超级键值编码". 首先上代码: # ...

  10. Http的定义及其基本概念介绍

    HTTP的特性 HTTP构建于TCP/IP协议之上,默认端口号是80 HTTP是无连接无状态的 HTTP报文 请求报文 HTTP定义了与服务器交互的不同方法,最基本的方法有4种,分别是GET,POST ...