一) apache编译安装
yum -y groupinstall "开发工具" ##或者 yum -y groupinstall "Development tools"
yum -y install gcc-c++ make* apr* pcre*
./configure --prefix=/usr/local/httpd \
--enable-so --enable-rewrite \
--enable-charset-lite --enable-cgi
make && make install
## 可调整为 make -j4 && make install ## make -j$(nproc) && make install
file 命令, stat 命令
file /usr/local/httpd/bin/apachectl
chkconfig --add httpd
chkconfig
二)
## httpd 配置虚拟主机 virtualhost
基于域名的虚拟主机 Name-based Virtual Hosts
基于IP的虚拟主机 P-based Virtual Hosts
基于端口的虚拟主机
httpd.conf 第个虚拟主机,一个 .conf 文件,是比最佳实践。 best practice
488 Include conf/extra2/*.conf
2.1) 基于域名的虚拟主机
@ IN NS ns1.qm5678.com.
ns1 IN A 192.168.126.150
ftp150 IN A 192.168.126.150
web151 IN A 192.168.126.151
share150 IN A 192.168.126.150
主配置文件。 加个include指令。
485 #Include conf/extra/httpd-vhosts.conf
486 Include conf/extra2/*.conf
[root@primary /usr/local/httpd/conf/extra2]# cat ftp150.qm5678.com.conf
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
ServerName ftp150.qm5678.com
DocumentRoot /data/ftp150.qm5678.com
[root@primary /usr/local/httpd/conf/extra2]# cat share150.qm5678.com.conf
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
ServerName share150.qm5678.com
DocumentRoot /data/share150.qm5678.com
Options Indexes # 意义, 允许 浏览目录。
259
260 DirectoryIndex index.html index.htm index.php
261
/test1015/index.html 则直接显示 index.html 内容
/test1015/index.html 文件缺少 “Options Indexes” 表示可以浏览目录
/test1015/index.html 文件缺少 报错403 # curl -i http://1.1.1.1/
2.2) 基于IP的虚拟主机。
[root@primary /usr/local/httpd/conf/extra2]# cat ftp150.qm5678.com.conf
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
ServerName 192.168.126.51
DocumentRoot /data/ftp150.qm5678.com
[root@primary /usr/local/httpd/conf/extra2]# cat share150.qm5678.com.conf
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
ServerName 192.168.126.52
DocumentRoot /data/share150.qm5678.com
2.3) 基于端口的虚拟主机
[root@primary /root]# cat .vimrc
:set nu
:set ignorecase
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
ServerName ftp150.qm5678.com
DocumentRoot /data/ftp150.qm5678.com
[root@primary /usr/local/httpd/conf/extra2]# cat share150.qm5678.com.conf
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
ServerName share150.qm5678.com
DocumentRoot /data/share150.qm5678.com
## curl 命令,模拟浏览器访问100次
for i in `seq 1 100`; do curl http://ftp150.qm5678.com:81 ; done
三)awstat 安装
chmod +x awstats_updateall.pl
chmod +x awstats_configure.pl
./awstats_configure.pl
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=ftp150.qm5678.com
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
3、登录awstats日志统计页面,URL输入:ip-address/awstats/awstats.pl?config=www.qm.com
ftp150.qm5678.com/awstats/awstats.pl?config=ftp150.qm5678.com