第五章Web网站服务
- 格式:docx
- 大小:33.49 KB
- 文档页数:6
第五章Web网站服务1.Apache HTTP Server 基于标准的HTTP网络协议,提供网页浏览服务,开源软件,正式名称为httpd。
2.Apache:A Patchy Server即基于原有web服务程序的代码修改后形成的服务器程序3.Apache的主要特点:1)开放源代码2)跨平台应用:所有的UNIX操作系统都可以运行Apache,大多数windows系统也可运行。
3)支持各种网页编程语言:PERL、PHP、Python、Java等4)模块化设计:为Apache服务器带来良好的扩展性,便于添加Apache本身没有的功能5)运行非常稳定6)良好的安全性:这是开源软件的共性。
4.Apache的主要版本:1)1.X 最高版本是1.3,兼容老版本2)2.X 最新版本为2.217更适用于新共建的网站服务器5.httpd.conf配置文件全局配置项:ServerRoot:设置httpd服务器的根目录,默认为(/usr/local/httpd)Listen:设置httpd服务监听的网络端口号,默认为80User:设置运行httpd进程时的用户身份,默认为daemonGroup:设置运行httpd进程时的组身份,默认为daemonServerAdmin:httpd服务器管理员邮箱地址。
ServerName:设置Web站点的完整主机名(如:)DocumentRoot:设置网站根目录,网页文档在系统中的实际存放路径。
DirectoryIndex:默认首页文件,可设置多个首页文件,以空格分隔。
ErrorLog:错误日志文件路径,默认:logs/error_logLogLevel:设置记录日志级别,默认为Warn(警告)CustomLog:访问日志文件的路径、日志类型,默认:logs/access_log common PidFile:保存httpd进程号(PID)的文件,默认:logs/httpd.pidCharsetDefault:站点中的网页默认使用的字符集编码。
UTF-8、gb2312等Include:包含配置文件的内容6.区域配置项<Directory /> #……定义目录区域的开始Options FollowSynLinks #……控制选项,允许使用符号链接AllowOverride None #……不允许隐含控制文件中的覆盖配置 Order deny,allow #……访问控制策略的应用顺序Deny fron all #……禁止任何人访问此区域</Directory> #……定于目录区域的结束7.AWStats日志分析系统,可完成自动化的日志分析与统计工作安装及配置httpd服务器(源代码软件安装)1、准备工作[root@localhost ~]#rpm -e httpd --nodeps #……nodeps忽略依赖关系卸载2、解压安装包[root@localhost ~]#tar zxvf httpd-2.2.17.tar.gz –C /usr/src/ 3、配置安装包1)[root@localhost ~]#cd /usr/src/httpd-2.2.17/2)[root@localhost httpd-2.2.17]#./configure--prefix=/usr/local/httpd --enalbe-so --enable-rewrite--enable-charset-lite --enable-cgi选项解释:)./configure:运行配置文件)--prefix=:指定服务程序按安装路径(安装到哪里))--enable-so:启用动态加载模块支持,是httpd具备进一步扩展功能的能力)--enable-rewrite:启用网页地址重写功能,网站目录迁移维护时只需要修改配置文件路径选项即可)--enable-charset-lite:启动字符集支持,支持各种字符集编码的网页)--enable-cgi:启用CGI脚本程序支持,便于扩展网站的应用访问能力4、编译安装包[root@localhost httpd-2.2.17]#make5、安装软件包[root@localhost httpd-2.2.17]#make install小提示:第四、五步骤可以合并为:[root@localhost httpd-2.2.17]#make&&make install6、优化执行路径(创建软连接)[root@localhost ~]#ln –s /usr/local/httpd/bin/* /usr/local/bin/7、查看程序版本(创建软连接之后)[root@localhost ~]#httpd -v8、添加httpd服务为系统服务[root@localhost ~]#cp /usr/local/httpd/bin/apachectl/etc/init.d/httpd[root@localhost ~]#vim /etc/init.d/httpd修改:如下(添加两条命令)#chkconfig:35 85 15#description:zhe shi http server!!#……该行为服务描述,可随意写(但必须得写)[root@localhost ~]#chkconfig --add httpd #……将httpd添加为系统服务[root@localhost ~]#chkconfig --list httpd #……查看httpd启动状态httpd 0:关闭 1:关闭 2:关闭 3:启用 4:关闭 5:启用 6:关闭9、配置主配文件[root@localhost ~]#vim /usr/local/httpd/conf/httpd.conf 修改:ServerName :80 #……去掉前面的注释符号“#”10、检查配置文件语法是否正确[root@localhost ~]#/usr/local/httpd/bin/apachectl -t11、启动httpd服务:[root@localhost ~]#/etc/init.d/httpd start或者:[root@localhost ~]#service httpd start12、查看httpd启动状态[root@localhost ~]#netstat -anpt | grep httpdtcp 0 0 :::80 :::* LISTEN26977/httpd13、网页的默认位置:/usr/local/httpd/htdocs/目录中,index.html文件。
14、在服务器查看默认网站首页内容[root@localhost ~]#cat /usr/local/httpd/htdocs/index.html 、<html><body><h1>It works!</h1></body></html>15、客户机验证访问:没有DNS解析,所以在浏览器中用ip地址访问默认首页http://192.168.1.1 #……服务器ip地址为192.168.1.1部署AWStats分析系统1、解压AWStsts软件[root@localhost ~]#unzip awstats-7.0.zip[root@localhost ~]#mv awstats-7.0 /usr/local/awstats2、为要统计的站点建立配置文件[root@localhost ~]#cd /usr/local/awstats/tools/[root@localhost ~]#./awstats_configure.pl 之后进入交互式配置过程。
省略部分内容显示-----> Running OS detected: Linux, BSD or Unix-----> Check for web server installEnter full config file path of your Web server.Example: /etc/httpd/httpd.confExample: /usr/local/apache2/conf/httpd.confExample: c:\Program files\apache group\apache\conf\httpd.confConfig 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 filesThis 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/profilefile (required if first install) [y/N] ? y-----> Define config file name to createWhat is the name of your web site or profile analysis ?Example: Example: demoYour web site, virtual server or profile name:>-----> Define config file pathIn which directory do you plan to store your config file(s) ?Default: /etc/awstatsDirectory path to store config file(s) (Enter for default):>-----> Create config file '/etc/awstats/.conf'Config file /etc/awstats/.conf created.-----> Restart Web server with '/sbin/service httpd restart'-----> Add update process inside a schedulerSorry, configure.pl does not support automatic add to cron yet.You can do it manually by adding the following command to your cron: /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update-config=Or if you have several config files and prefer having only one command: /usr/local/awstats/tools/awstats_updateall.pl nowPress ENTER to continue...3、修改站点统计配置文件[root@localhost ~]#vim /etc/awstats/.conf 修改:省略前面注释部分LogFile=“/usr/local/httpd/logs/access_logs”DirData=”/var/lib/awstats”后边不用配置了,省略……4、执行日志分析:[root@localhost ~]#/usr/local/awstats/tools/awstats_updateall.pl now 5、设置周期性计划任务[root@localhost ~]#crontab -e*/5 * * * * /usr/local/awstats/tools/awstats_upteall.pl now[root@localhost ~]#/etc/init.d/crond start #……启动计划任务计划配置项[root@localhost ~]#chkconfig --level 35 crond on #……运行级别3和5 6、简化AWStats系统访问:[root@localhost ~]#vim /usr/local/httpd/htdocs/awb.html<html><head><meta http-equiv=refresh content=”0;url=/awstats/awstats.pl”></head><body></body></html>6、访问AWStats分析系统http:///awb.html如果没有第5步的操作,访问awstats分析系统完整路径为:/awstats/awstats.pl。