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. XBMC源代码分析 6:视频播放器(dvdplayer)-文件头(以ffmpeg为例)

    XBMC分析系列文章: XBMC源代码分析 1:整体结构以及编译方法 XBMC源代码分析 2:Addons(皮肤Skin) XBMC源代码分析 3:核心部分(core)-综述 XBMC源代码分析 4: ...

  2. (四十五)Modal 模态窗口 -遮盖

    任何控制器都能通过Modal方式切换. Modal的默认效果是:新显示的控制器从屏幕底部向上,直到盖住之前的控制器为止. 假设有One和Two两个控制器: One到Two的Modal方法:presen ...

  3. leetcode 104 Maximum Depth of Binary Tree二叉树求深度

    Maximum Depth of Binary Tree Total Accepted: 63668 Total Submissions: 141121 My Submissions Question ...

  4. Linux Shell 命令--cut

    解读-help 用法:cut [选项]... [文件]... 从每个文件中输出指定部分到标准输出. 长选项必须使用的参数对于短选项时也是必需使用的.   -b, --bytes=列表          ...

  5. shell脚本格式的几点注意:格式严格,空格不能随便出现(一写就记不住)

    shell脚本中,不能随意添加空格,否则出错: 1,=等号两边必须无空格.否则出错.如i =$1和i= $1都是错的.但是在()内部不限制如for ((i= 1;i < 3;i= i+1))是正 ...

  6. 《java入门第一季》之面向对象综合小案例

    需求: /*     教练和运动员案例         乒乓球运动员和篮球运动员.         乒乓球教练和篮球教练.         跟乒乓球相关的人员都需要学习英语.         分析,这 ...

  7. CSS中让一个div的高度随着另外个一个统计的div的高度变化而变化的代码

     .w1002 .left_part{overflow:hidden; padding-bottom:9999px; margin-bottom:-9999px;display:inline;}

  8. 俺的新书《Sencha Touch实战》终于出版了

    内容简介:Sencha框架是第一个基于HTML 5的移动也能给予框架,可以让Web应用看起来像网络应用.美丽的用户 界面 组件和丰富的数据管理,全部基于最新的HTML 5和CSS 3的Web标准,全部 ...

  9. 网站开发进阶(十一)如何将一个jsp页面嵌套在另一个页面中

    如何将一个jsp页面嵌套在另一个页面中 这个在做网页中常要用到,有些通用的内容可集中放在一个页面文件中,其它要用到这些内容的页面只需要包含(引用)这个通用文件即可.这样便于维护,如果有很多网页,当通用 ...

  10. 巧用FineReport搭建成本管控监测系统

    一.应用背景 企业在近几年快速发展,规模也越来越大,而信息传递与反馈手段却仍然比较落后,随着信息技术的不断发展,人们开始通过尝试利用技术手段改善这种环境.企业的项目不断增多,而作为高层管理者,通过层级 ...