Apache
apache目录结构
服务目录 /usr/local/httpd
主配置文件 /usr/local/httpd/confi/httpd.conf
网页目录 /usr/local/httpd/htdocs
服务脚本 /usr/local/httpd/bin/apachectl
执行程序 /usr/local/httpd/bin/httpd
访问日志 /usr/local/httpd/log/access.log
错误日志 /usr/local/httpd/log/error.log
常用的全局配置参数
ServerRoot:服务目录
ServerAdmin:管理员邮箱
User:运行服务的用户身份
Group:运行服务的组身份
ServerName:网站服务器的域名
DocumentRoot:网页文档的根目录
Listen:监听的IP地址、端口号
PidFile:保存httpd进程PID号的文件
DirectoryIndex:默认的索引页文件
常用的全局配置参数(续)
ErrorLog:错误日志文件的位置
CustomLog:访问日志文件的位置
LogLevel:记录日志的级别,默认为warn
Timeout:网络连接超时,默认为300秒
KeepAlive:是否保持连接,可选On或Off
MaxKeepAliveRequests:每次连接最多请求文件数
KeepAliveTimeout:保持连接状态时的超时时间
Include:需要包含进来的其他配置文件
1.编译安装apache
1. 确认httpd是否已经安装 rpm-qa httpd
2. 卸载 rpm-e httpd
3. 编译安装环境 yum -y install gcc gcc-c++
4. 源码编译安装 tar zxf httpd-2.2.17.tar.gz -C /usr/src/
cd /usr/src/httpd-2.2.17
5. 定义路径 启用动态加载模块支持 启用网页地址重写字符集支持
./configure–prefix=/usr/local/httpd–enable-so–enable-rewrite–enable-charset-lite–enable-cgi
6. 编译make && make install
7. 优化执行路径ln -s /usr/local/httpd/bin/* /usr/local/bin
httpd -v = /usr/local/httpd/bin/httpd -v
8. 站点配置文件
#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
#//确认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 ##//允许建立日志文件
# Add 'Alias /awstatsclasses"/usr/local/awstats/wwwroot/classes/"'
# Add 'Alias /awstatscss"/usr/local/awstats/wwwroot/css/"'
# Add 'Alias /awstatsicons"/usr/local/awstats/wwwroot/icon/"'
# Add 'ScriptAlias /awstats/"/usr/local/awstats/wwwroot/cgi-bin/"'
# Add '<Directory>' directive
# AWStats directives added to Apache configfile.
# -----> 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 #//允许建立配置文件
#-----> 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.cbyl.com #//监控站点的域名
-----> Define config file path
#In which directory do you plan to store your config file(s) ?
#Default: /etc/awstats
#Directory path to store config file(s) (Enter for default):
#> //默认的配置文件存储路径,回车继续
#-----> Create config file '/etc/awstats/awstats.www.cbyl.com.conf'
# Config file/etc/awstats/awstats.www.cbyl.com.conf created.
#-----> Restart Web server with '/sbin/service httpd restart'
#-----> Add update process inside a scheduler
#Sorry, 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=www.cbyl.com
#Or if you have several config files and prefer having only one command:
#/usr/local/awstats/tools/awstats_updateall.pl now
#Press ENTER to continue... 提示用户手动添加计划任务,回车继续
#A SIMPLE config file has been created: /etc/awstats/awstats.www.cbyl.com.conf
#You should have a look inside to check and change manually main parameters.
#You can then manually update your statistics for 'www.cbyl.com' with command:
#> perl awstats.pl -update -config=www.cbyl.com
#You can also read your statistics for 'www.cbyl.com' with URL:
#> http://localhost/awstats/awstats.pl?config=www.cbyl.com
#Press ENTER to finish... 回车结束
9. 虚拟主机基于端口
vim /usr/local/httpd/conf/extra/httpd-vhosts.conf ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190930144802497.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0NhcHRpYW5H,size_16,color_FFFFFF,t_70)
10. 进入/usr/local/httpd/conf/httpd.conf打开虚拟主机
11. 修改端口
12. 进入/usr/local/httpd/htdocs/创建docs文件夹,在里面分别新建两个文件夹,
13. 在两个文件夹里分别写入一个网页
14. 重启服务,到浏览器访问
15. 基于IP
Vim/usr/local/httpd/conf/extra/httpd-vhosts.conf
16. 访问
17. 基于DNS
18.安装DNS
19. 配置vim /etc/named.conf
20. 进入/var/named/创建文件,编辑文件
21 页面监控
解压文件到/usr/local/awstats/
22. 进入文件夹,给awstats_configure.pl给可执行权限1,运行awstats_configure.pl
23. 填入配置文件路径
24. 填入监控网站
25 访问的网址192.168.8.186/awstats/awstats.pl?config=www.baidu.com
26. 创建配置文件
/var/lib/awstats
给awstats_updateall.pl写入可执行权限
写入./ awstats_updateall.pl now会更新文件
27. 报错,找不到日志文件
打开文件,vim /usr/local/httpd/conf/extra/httpd-vhosts.conf查看日志文件路径,复制路径
28. 打开文件 /etc/awstats/awstats.www.baidu.com.conf我们的路径是/usr/local/httpd/把你的日志路径和这个一起写进去写进去
29. 重新读取
30. 建立计划任务
-
启动任务
-
访问awstat
- 建立自动跳转html网页
vim/usr/local/httpd/htdocs/docs/baidu/aws.html
- 用户授权限制
1.创建用户认证数据库
/usr/local/httpd/bin/htpasswd
-c /usr/local/httpd/conf/.awspwd webadmin
//创建密码文件并创建用户webadmin
/usr/local/httpd/bin/htpasswd
-c /usr/local/httpd/conf/.awspwd webuser
//在现有的密码文件中再创建新用户webuser
2.在主配置文件中田间用户授权信息
AuthName
“AWStats Directory” 授权名
AuthType Basic 验证类型为基本认证
AuthUserFile /usr/local/httpd/conf/.awspwd 用户认证文件路径
require valid-user webadmin,webuser 允许登陆的用户 - 创建用户认证web用户
- 访问