01)下载httpd-2.2.27.tar.gz
02)解压:tar xf httpd-2.2.27.tar.gz
然后进入解压的文件查看INSTALL和RAEDME
03)直接make会出错,然后进行编译(也会有问题,这时候yum -y install zlib zlib-devel即可解决),然后进行编译:
./configure --prefix=/application/apache2.2.27 \ 安装路径 --enable-deflate \ 压缩(为了发送给客户端的时候更快一点,但是消耗CPU) --enable-expires \ 过期 --enable-headers \ 提供对http请求头的控制 --enable-modules=most \ 激活大多数模块 --enable-so \ --with-mpm=worker \ 选择work模式(进程下的线程提供服务)还有profork模式(直接用进程提供服务,更安全稳定,但是消耗内存) --enable-rewrite 伪静态
04)make&makeinstall
05)ln -s /application/apache2.2.27/ /application/apache
06)/application/apache/bin/apachectl -t
/application/apache/bin/apachectl start
lsof -i :80
Netstat -ntlup|grep 80
Ps -ef |grep httpd
07)curl 本机ip 如果不能访问进行下面的检查与操作:
/etc/init.d/iptables stop
setenforce 0
然后看看端口起来没
08)查看配置文件
[root@qbPC ~]# cd /application/apache [root@qbPC apache]# ls bin build cgi-bin conf error htdocs icons include lib logs man manual modules [root@qbPC apache]# cd conf/ [root@qbPC conf]# ls extra httpd.conf magic mime.types original [root@qbPC conf]# grep -i documentroot httpd.conf # DocumentRoot: The directory out of which you will serve your DocumentRoot "/application/apache2.2.27/htdocs" 查看主配文件的存放数据的目录(index.html) # This should be changed to whatever you set DocumentRoot to. # access content that does not live under the DocumentRoot. 去掉注释查看主配文件 [root@qbPC conf]# grep -Ev "#|^$" httpd.conf > httpd.conf.ori [root@qbPC conf]# cd extra/ [root@qbPC extra]# ls httpd-autoindex.conf httpd-info.conf httpd-mpm.conf httpd-userdir.conf httpd-dav.conf httpd-languages.conf httpd-multilang-errordoc.conf httpd-vhosts.conf httpd-default.conf httpd-manual.conf httpd-ssl.conf
[root@qbPC conf]# cat httpd.conf.ori ServerRoot "/application/apache2.2.27"软件安装路径,也是服务器的根目录 #监听的端口 Listen 80 <IfModule !mpm_netware_module> <IfModule !mpm_winnt_module> User daemon Group daemon </IfModule> </IfModule> ServerAdmin you@example.com 管理员邮箱 DocumentRoot "/application/apache2.2.27/htdocs"默认站点目录 <Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory> <Directory "/application/apache2.2.27/htdocs"> 这个配置只对默认站点生效,如果有虚拟主机,需要复制这一段到主配文件最后,进行配置,对于option里面的indexes(没有首页展示的目录,一般去掉,不对外展示目录结构) Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> <IfModule dir_module>指定访问首页 DirectoryIndex index.html </IfModule> <FilesMatch "^\.ht">文件匹配 Order allow,deny Deny from all Satisfy All </FilesMatch> ErrorLog "logs/error_log"设置错误日志 LogLevel warn 设置日志级别 <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "logs/access_log" common </IfModule> <IfModule alias_module> ScriptAlias /cgi-bin/ "/application/apache2.2.27/cgi-bin/" </IfModule> <IfModule cgid_module> </IfModule> <Directory "/application/apache2.2.27/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory> DefaultType text/plain <IfModule mime_module> TypesConfig conf/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz </IfModule> Include conf/extra/httpd-mpm.conf Include conf/extra/httpd-vhosts.conf <IfModule ssl_module> SSLRandomSeed startup builtin SSLRandomSeed connect builtin </IfModule>
[root@qbPC var]# mkdir -p /var/html/{www,blog,bbs} [root@qbPC var]# touch /var/html/{www,blog,bbs}/index.html [root@qbPC var]# for name in www blog bbs;do echo "http://$name.my.org" > /var/html/$name/index.html;done [root@qbPC html]# cat bbs/index.html http://bbs.my.org [root@qbPC html]# cat blog/index.html http://blog.my.org [root@qbPC html]# cat www/index.html http://www.my.org
[root@qbPC conf]# ls extra httpd.conf httpd.conf.ori magic mime.types original [root@qbPC conf]# cd extra/ [root@qbPC extra]# ls httpd-autoindex.conf httpd-info.conf httpd-mpm.conf httpd-userdir.conf httpd-dav.conf httpd-languages.conf httpd-multilang-errordoc.conf httpd-vhosts.conf httpd-default.conf httpd-manual.conf httpd-ssl.conf httpd-vhosts-name.conf [root@qbPC extra]# cat httpd-vhosts.conf # # Virtual Hosts # NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin 15581737164@163.com DocumentRoot "/var/html/www" ServerName www.my.org ServerAlias my.org ErrorLog "logs/www-error_log" CustomLog "logs/www-access_log" common </VirtualHost> <VirtualHost *:80> ServerAdmin 15581737164@163.com DocumentRoot "/var/html/blog" ServerName blog.my.org ErrorLog "logs/blog-error_log" CustomLog "logs/blog-access_log" common </VirtualHost> <VirtualHost *:80> ServerAdmin 15581737164@163.com DocumentRoot "/var/html/bbs" ServerName bbs.my.org ErrorLog "logs/bbs-error_log" CustomLog "|/usr/local/sbin/cronolog /app/logs/access_bbs_%Y%m%d.log" combined </VirtualHost> [root@qbPC extra]#
03)在主配文件中打开虚拟主机
Include conf/extra/httpd-mpm.conf Include conf/extra/httpd-vhosts.conf
/application/apache/bin/apachectl -t /application/apache/bin/apachectl graceful 注:做以上操作的时候可能会有延迟和报错(fully qualified domian name FQDN),解决如下: [root@qbPC ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 httpd ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 [root@qbPC ~]# [root@qbPC conf]# vim httpd.conf #ServerName www.example.com:80 ServerName 127.0.0.1:80
05)当访问的时候会报403错误,因为没有dns解析,所以可以进行本地解析
解决:在主配文件最后加
<Directory "/var/html"> Options FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
07)到此就可以访问了
tar zxvf cronolog-1.6.2.tar.gz cd cronolog-1.6.2 ./configure make&make install pwd
02)建立日志目录
mkdir -p /app/logs
<VirtualHost *:80> ServerAdmin 15581737164@163.com DocumentRoot "/var/html/bbs" ServerName bbs.my.org ErrorLog "logs/bbs-error_log" CustomLog "|/usr/local/sbin/cronolog /app/logs/access_bbs_%Y%m%d.log" combined </VirtualHost>
/application/apache/bin/apachectl -t /application/apache/bin/apachectl graceful
在主配文件中
<FilesMatch "\.(css|js|gif|jpg|ico|swf)"> SetEvn IMAG 1 </FilesMatch> |
在虚拟主机配置文件http-vhosts.conf的日志配置中
CustomLog "|/usr/local/sbin/cronolog /app/logs/access_bbs_%Y%m%d.log" combined evn=!IMAG |
在http-vhosts.conf中
SetEvnIf Request_URI “^/check\.txt$” dontlog CustomLog "|/usr/local/sbin/cronolog /app/logs/access_bbs_%Y%m%d.log" combined evn=!dontlog |
统计访问IP
awk ‘{print $1}‘ access_bbs_20170608.log |sort |uniq -c |sort -rn -k1|head -10
awk ‘{++S[$1]} END {for (key in S) print S[key],key}‘ access_bbs_20170608.log | sort -rn -k1|head -10
=================php===================== 5.3=====> ============================= ./configure --prefix=/application/php5.3.27 --with-apxs2=/application/apache/bin/apxs --with-mysql=/application/mysql --with-xmlrpc --with-openssl --with-zlib --with-freetype-dir --with-gd --with-jpeg-dir --with-png-dir --with-iconv=/usr/local/libiconv --enable-short-tags --enable-sockets --enable-zend-multibyte --enable-soap --enable-mbstring --enable-static --enable-gd-native-ttf --with-curl --with-xsl --enable-ftp --with-libxml-dir ==========php========== 安装准备 yum install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel -y tar zxf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure --prefix=/usr/local/libiconv make make install cd ../
本文出自 “qb的博客” 博客,谢绝转载!
原文地址:http://qinbin.blog.51cto.com/11773640/1934397