|
Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。当前Apache版本为2.4,本文主要描述基于CentOS 6.5以源码方式安装Apache httpd。 一、编译安装的优势
二、httpd的版本
三、httpd 2.4的新特性
四、编译安装httpd 2.4
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<code class="hljs haml"><code class="hljs applescript">1、修改端口号 修改端口号使得与2.2版本使用不同的端口,可以同时运行,修改后如下 # cat /etc/httpd24/httpd.conf |grep Listen |grep -v ^# Listen 80802、启动与停止 # /usr/local/apache/bin/apachectl start # netstat -nltp|grep 80 tcp 0 0 :::8080 :::* LISTEN 17365/httpd # /usr/local/apache/bin/apachectl status Not Found The requested URL /server-status was not found on this server. 通过修改httpd.conf,增加如下配置 # grep server-stat /etc/httpd24/httpd.conf -A5 <location server-status=""> SetHandler server-status # Order deny,allow # Deny from all Allow from 192.168.21.157 192.168.21.10 </location> # /usr/local/apache/bin/apachectl restart # /usr/local/apache/bin/apachectl status Apache Server Status for localhost (via 127.0.0.1) Server Version: Apache/2.4.9 (Unix) Server MPM: prefork .......... # /usr/local/apache/bin/apachectl stop3、配置自启动文件 可以通过复制2.2版本的启动文件,修改相关路径后将2.4版作为单独服务运行,如下 注启动文件pid文件位置要配置成与/usr/local/apache/bin/apachectl -V看到的pid位置一致 查看pid位置 # /usr/local/apache/bin/apachectl -V|grep pid -D DEFAULT_PIDLOG="logs/httpd.pid" # cp /etc/init.d/httpd /etc/init.d/httpd24 # vi /etc/init.d/httpd24 # diff /etc/init.d/httpd /etc/init.d/httpd24 26,27c26,27 < if [ -f /etc/sysconfig/httpd ]; then < . /etc/sysconfig/httpd --- > if [ -f /etc/httpd24 ]; then > . /etc/httpd24 42,46c42,46 < apachectl=/usr/sbin/apachectl < httpd=${HTTPD-/usr/sbin/httpd} < prog=httpd < pidfile=${PIDFILE-/var/run/httpd/httpd.pid} < lockfile=${LOCKFILE-/var/lock/subsys/httpd} --- > apachectl=/usr/local/apache/bin/apachectl > httpd=${HTTPD-/usr/local/apache/bin/httpd} > prog=httpd24 > pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid} > lockfile=${LOCKFILE-/var/lock/subsys/httpd24} # service httpd24 start Starting httpd24: [ OK ] # service httpd24 status httpd (pid 15641) is running... # netstat -nltp|grep 80 tcp 0 0 :::80 :::* LISTEN 15677/httpd ###2.2版httpd tcp 0 0 :::8080 :::* LISTEN 15641/httpd ###2.4版httpd 可以通过复制apachectl文件生成服务脚本 # cp /usr/local/apache/bin/apachectl /etc/init.d/httpd249 # service httpd249 start # service httpd249 status ELinks: Connection refused ###该方式无法查看到状态 [root@orasrv1 bin]# netstat -nltp|grep 80 tcp 0 0 :::8080 :::* LISTEN 15999/httpd 最后将配置文件添加到服务,以下为http24为例 # chkconfig --add httpd24 # chkconfig httpd24 on</code></code> |
六、配置man手册
六、配置man手册|
1
2
|
<code class="hljs haml"><code class="hljs applescript"><code class="hljs lua"> vi /etc/man.config MANPATH /usr/local/apache/man</code></code></code> |
七、验证
七、验证|
1
2
3
|
<code class="hljs haml"><code class="hljs applescript"><code class="hljs lua"><code class="hljs xml"># echo "This is a apached 2.4.9 version">>/usr/local/apache/htdocs/index.html # curl http://192.168.21.10:8080 </code></code></code></code> |
It works!
It works!
This is a apached 2.4.9 version
(责任编辑:IT)
