源码安装Apache
[root@Oracle ~]# yum -y install gcc gcc++ zlib zlib-devel
[root@Oracle ~]# wget http://apache.fayea.com/httpd/httpd-2.2.27.tar.gz
[root@Oracle ~]# rpm -qa |grep httpd
httpd-2.2.15-39.el6.centos.x86_64
httpd-manual-2.2.15-39.el6.centos.noarch
httpd-tools-2.2.15-39.el6.centos.x86_64
[root@Oracle ~]# rpm -e --nodeps httpd-2.2.15-39.el6.centos.x86_64 httpd-manual-2.2.15-39.el6.centos.noarch httpd-tools-2.2.15-39.el6.centos.x86_64
[root@Oracle ~]# rpm -qa |grep httpd
[root@Oracle ~]#
[root@Oracle ~]# tar -zxf httpd-2.2.27.tar.gz
[root@Oracle ~]# cd httpd-2.2.27
[root@Oracle httpd-2.2.27]# ./configure --prefix=/usr/local/apache2 --enable-rewrite --enable-so --enable-headers --enable-expires --with-mpm=worker --enable-modules=most --enable-deflate
--prefix=/usr/local/apache2 | #指定apache的安装路径,默认安装路径为/usr/local/apache2 |
--enable-rewrite | #提供URL规则的重写 |
--enable-so | #激活apache服务的DSO(Dynamic Shared Objects动态共享目标),即在以后可以以DSO的方式编译安装共享模块,这个模块本身不能以DSO方式编译。 |
--enable-headers | #提供允许对HTTP请求头的控制。 |
--enable-expires | #通过配置文件控制HTTP的“Expires:”和“Cache-Control:”头内容,即对网站图片、js、css等内容,提供客户端浏览器缓存的设置。这个是apache调优的一个重要选项之一。 |
--with-mpm=worker | #选择apache mpm的模式为worker模式。为worker模式原理是更多的使用线程来处理请求,所以可以处理更多的并发请求。而系统 资源的开销小玉基于进程的MPM prefork。如果不指定此参数,默认的模式是prefork进程模式。这个是apache调优的一个重要选项之一。 |
--enable-deflate | #提供对内容的压缩传输编码支持,一般是html、js、css等内容的站点。使用此参数会打打提高传输速度,提升访问者访问的体验。在生产环境中,这是apache调优的一个重要选项之一。 |
[root@Oracle httpd-2.2.27]# make && make install
[root@Oracle httpd-2.2.27]# ls -al /usr/local/apache2/
total 68
drwxr-xr-x. 15 root root 4096 Dec 12 21:42 .
drwxr-xr-x. 15 root root 4096 Dec 12 21:42 ..
drwxr-xr-x. 2 root root 4096 Dec 12 21:42 bin
drwxr-xr-x. 2 root root 4096 Dec 12 21:42 build
drwxr-xr-x. 2 root root 4096 Dec 12 21:42 cgi-bin
drwxr-xr-x. 4 root root 4096 Dec 12 21:42 conf
drwxr-xr-x. 3 root root 4096 Dec 12 21:42 error
drwxr-xr-x. 2 root root 4096 Dec 12 21:42 htdocs
drwxr-xr-x. 3 root root 4096 Dec 12 21:42 icons
drwxr-xr-x. 2 root root 4096 Dec 12 21:42 include
drwxr-xr-x. 3 root root 4096 Dec 12 21:42 lib
drwxr-xr-x. 2 root root 4096 Dec 12 21:42 logs
drwxr-xr-x. 4 root root 4096 Dec 12 21:42 man
drwxr-xr-x. 14 root root 12288 Dec 12 21:42 manual
drwxr-xr-x. 2 root root 4096 Dec 12 21:42 modules
[root@Oracle httpd-2.2.27]#
[root@Oracle httpd-2.2.27]# cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
http://192.168.18.131/
[root@Oracle httpd-2.2.27]# echo "/usr/local/apache2/bin/apachectl start">>/etc/rc.local
Apache配置文件:
[root@Oracle ~]# egrep -v ‘^[ ]*#|^$‘ /usr/local/apache2/conf/httpd.conf | nl 1 ServerName localhost:80 2 ServerRoot "/usr/local/apache2" 3 Listen 80 4 <IfModule !mpm_netware_module> 5 <IfModule !mpm_winnt_module> 6 User daemon 7 Group daemon 8 </IfModule> 9 </IfModule> 10 ServerAdmin [email protected] 11 DocumentRoot "/usr/local/apache2/htdocs" 12 <Directory /> 13 Options FollowSymLinks 14 AllowOverride None 15 Order deny,allow 16 Deny from all 17 </Directory> 18 <Directory "/usr/local/apache2/htdocs"> 19 Options Indexes FollowSymLinks 20 AllowOverride None 21 Order allow,deny 22 Allow from all 23 </Directory> 24 <IfModule dir_module> 25 DirectoryIndex index.html 26 </IfModule> 27 <FilesMatch "^\.ht"> 28 Order allow,deny 29 Deny from all 30 Satisfy All 31 </FilesMatch> 32 ErrorLog "logs/error_log" 33 LogLevel warn 34 <IfModule log_config_module> 35 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 36 LogFormat "%h %l %u %t \"%r\" %>s %b" common 37 <IfModule logio_module> 38 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio 39 </IfModule> 40 CustomLog "logs/access_log" common 41 </IfModule> 42 <IfModule alias_module> 43 ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/" 44 </IfModule> 45 <IfModule cgid_module> 46 </IfModule> 47 <Directory "/usr/local/apache2/cgi-bin"> 48 AllowOverride None 49 Options None 50 Order allow,deny 51 Allow from all 52 </Directory> 53 DefaultType text/plain 54 <IfModule mime_module> 55 TypesConfig conf/mime.types 56 AddType application/x-compress .Z 57 AddType application/x-gzip .gz .tgz 58 </IfModule> 59 <IfModule ssl_module> 60 SSLRandomSeed startup builtin 61 SSLRandomSeed connect builtin 62 </IfModule> [root@Oracle ~]#
本文出自 “炉火纯青” 博客,请务必保留此出处http://alipay.blog.51cto.com/7119970/1589296
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。