一箫一剑平生意,负尽狂名十五年。这篇文章主要讲述appache优化相关的知识,希望能为你提供帮助。
配置:
虚拟机恢复初始化
配置VM1网卡
配置永久IP地址(关闭防火、关闭安全linux)
使用远程连接软件
挂载好磁盘到mnt目录
配置好yum仓库
将压缩包添加
文章图片
解压
tar xf apr-1.6.2.tar.gz
tar xf apr-util-1.6.0.tar.gz
tar -xjf httpd-2.4.29.tar.bz2
mv apr-1.6.2 httpd-2.4.29/srclib/apr
mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
安装服务
yum -y install \\
gcc \\
gcc-c++ \\
make \\
pcre-devel\\
expat-devel\\
perl \\
zlib-devel\\
zlib
cd httpd-2.4.29
./configure\\
--prefix=/usr/local/httpd\\
--enable-so\\
--enable-rewrite\\
--enable-charset-lite\\
--enable-cgi
make & & make install
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
vi /etc/init.d/httpd
#
chkconfig: 35 85 21 //35级别自动运行 第85个启动 第21个关闭
#
description: Apache is a World Wide Web server
文章图片
chkconfig --add httpd
vi /usr/local/httpd/conf/httpd.conf
ServerName
ln -s /usr/local/httpd/conf/httpd.conf /etc/
ln -s /usr/local/httpd/bin/* /usr/local/bin/
systemctl stop firewalld.service
setenforce 0
service httpd start
netstat -anpt | grep 80
--------------------------------------------------------------------------------------------------
从-----------配置AWstats日志分析软件--------开始做
apachectl -D DUMP_MODULES | grep cgi //确认加载了cgi模块
ls /usr/local/httpd/modules/ | grep cgi //确认是否编译过cgi模块
文章图片
vi /usr/local/httpd/conf/httpd.conf //手动加载
搜索mod_cgid.so
将框中前面的#号去掉
文章图片
LoadModule cgid_module modules/mod_cgid.so
LoadModule cgi_module modules/mod_cgi.so
文章图片
cd / tar xzvf awstats-7.6.tar.gz 解压
mv awstats-7.6 /usr/local/awstats 移动
-------------------------------------------------------------------------------------------
doc访问
cd /usr/local/httpd/conf/
vim httpd.conf
搜索Include
文章图片
复制一行 再下面添加 将前面#号去掉
文章图片
cd extra/
添加配置 文件
vim vhosts.conf
Alias /doc/
"/usr/share/doc/"
< Directory
"/usr/share/doc">
Options Indexes
MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
< /Directory>
文章图片
Options Indexes Multivieus FollcwSymLinks Al loucverride None Order allow, deny Allow from all Require all granted rootGlocalhost conf Itt " style="visibility: visible; width: 465px; " data-type="inline">
重启服务
Systemctl restart httpd
访问
文章图片
--------------------------------------------------------------------------------------------------
Share
Alias /share/
"/usr/share/doc/"
< Directory
"/usr/share/doc/">
Options Indexes
MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
AuthName
"Wellcom!!"
AuthType Basic
AuthUserFile
/usr/local/httpd/user
require valid-user
#Require all granted
< /Directory>
文章图片
[root@localhost extra]" " style="visibility: visible; width: 570px; " data-type="inline">
文章图片
-------------------------------------------------------------------------------------------------
-------AWstats可以同时分析多个站点的数据---
vi /etc/hosts 编辑配置文件
将192.168.1.100虚拟机地址 添加到配置文件
文章图片
过滤
grep "ServerName" /etc/httpd.conf //在配置文件中定义主机名为www.benet.com
文章图片
切换目录
cd /usr/local/awstats/tools/
查看APPache配置路径
cat /usr/local/httpd/conf/httpd.conf
进行配置
./awstats_configure.pl //自动配置脚本,根据提示填写APPache配置路径
http配置文件路径 /usr/local/httpd/conf/httpd.conf
文章图片
Running os detected: Linux, BSD or Lhlix ---> 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): " style="visibility: visible; width: 570px; " data-type="inline">
默认y
文章图片
/usr/local/http?/conf/httpd.conf check and complete web server config file ? /usr/local/httpd/conf/httpd.con? Warning: You Apache config file contains directives to writecomann log files This means that some features cant work (os, browsers and keywords detection). Do you want me to setup Apache to write ?canbined? log files [y/N] ? y Add Alias /awstatsclasses " /usr/local/awstats/wweroot/classes/" Add Alias /awstatscss " /usr/local/awstats/wwaroot/css/" Add Alias /awstatsicons " /usr/local/awstats/wwwroot/icon/" Add scriptAlias /awstats/ " /usr/local/?estats/wweroot/cgi-bin/" Add (Directory> directive Awstats directives added to Apache config file. Update mdel config file File austats.mdel.conf updated. Need to create a new config file ? to build a nee Awstats config/profile Do you want me file (required if first install) [y/n] ? y " style="visibility: visible; width: 570px; " data-type="inline">
命名 ??www.benet.com??
文章图片
输入www.benet.com 默认回车
文章图片
" %.benet.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/austats/awstats.Mwu.benet.ccm.conf Config file /etc/aastats/awstats.vaw€.benet.ccxn.conf created. ---> Restart web server with /sbin/service httpd restart Add update process inside a scheduler Sorry, configure.pl does not support autmatic add to cron yet. You can do it manually by adding the follm€ing comand to your cron: /usr/local/awstatsmweroot/cgi-bin/awstats.pl -update Or if you have several config files and prefer having only one conrnand: /usr/local/awstats/tools/awstats_updateall.pl non Press ENTER to continue... A SIMPLE config file has been created: You should have a look inside to check and change manually main parameters. You can then manually update your statistics for with ccxnmand: > perl austats.pl -update -config=Mw€.benet.cm You can also read your statistics for benet.ccxn with URL: > http://localhost/awstats/dnstats.pl benet. cml " style="visibility: visible; width: 570px; " data-type="inline">
----------------------------------------------------------------------------------------
----访问日志的网址-----
vi /etc/awstats/awstats.www.benet.com.conf //修改程序的主配置文件 ??www.benet.com?? 是上面的 转换日志格式哪里
LogFile="/usr/local/httpd/logs/access_log" //修改日志文件位置,第50行
原配置文件
文章图片
修改后配置文件
文章图片
DirData="https://www.songbingjia.com/var/lib/awstats" //220行 手动建立每次抓取的数据存放位置
mkdir /var/lib/awstats
cd
/usr/local/httpd/logs/
rm -f *log
service
httpd restart //重新生成日志文件
查看
文章图片
cd /usr/local/awstats/tools/
chmod +x awstats_updateall.pl
./awstats_updateall.pl now //手动采集/跟新一次数据
文章图片
编辑配置文件
vim /etc/httpd.conf 到最后一行
文章图片
修改配置文件
文章图片
重启服务
systemctl restart httpd
如果这里访问不到
等1分钟在打开浏览器会成功访问
访问http://192.168.1.100/awstats/awstats.pl?config=www.benet.com
文章图片
------注意---需要检查以下虚拟目录授权----
vi /etc/httpd.conf
< Directory
"/usr/local/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "kgc.cn"
AuthType Basic
AuthUserFile /usr/local/httpd/user
require valid-user
#Require all granted
< /Directory>
文章图片
service httpd restart
添加用户密码
用户jack 密码为1
文章图片
文章图片
------------以下通过配置页面自动跳转优化统计页面访问----------
vi /usr/local/httpd/htdocs/aw.html
< html>
< head>
< meta http-equiv=refresh content="0; url=http://192.168.1.100/awstats/awstats.pl?config=www.benet.com">
< /head>
< body> < /body>
< /html>
文章图片