CentOS之httpd与apache安装区别

来源:互联网 发布:怎么查看微信数据 编辑:程序博客网 时间:2024/05/17 06:03

CentOS之httpd与apache安装区别

在这里给大家分享一下我自己在安装Centos后,并进行安装WEB服务器的心得;

1,先让大家了解一下我的虚拟机;

我用的是一台绿色版的VM, 不过,这并不对我们的安装Centos有任何影响;但首先要确定,你用的centos是64位的,还是32位的IOS,当然,这估计得让你自己判断一下自己的操作系统是64位还是32位了;

2,下面介绍我的CentOS操作系统;

进入系统登陆:

如图示:

可以看到我的系统Kernel 2.6.32-278.EL6.I686 on an i686

进入系统;

$:uname -a

Linux centos 2.6.32-279.el6.i686 #1 SMP Fri Jun 22 10:59:55 UTC 2012 i686 i686 i386 GNU/Linux

于是我们可以判断,这个IOS包是可以兼容i686 i686 i386的安装包,好了,了解这么多,就是为了我们去选择下载APACHE软件包;

3.下载apache包,我选择是的httpd-2.4.4.tar.bz2 ,从命名可以看出,这是一个压缩包,而且可知道这个是apache2.0以上的;

然后,我们再来安装;

$:tar -xvf httpd-2.4.4.tar.bz2

httpd-2.4.4              httpd-2.4.4.tar.bz2 $:cd httpd-2.4.4

$:ls

ABOUT_APACHE     BuildBin.dsp   httpd.dsp       Makefile.in       ROADMAPacinclude.m4     buildconf      httpd.spec      Makefile.win      serverApache-apr2.dsw  CHANGES        include         modules           srclibApache.dsw       config.layout  INSTALL         NOTICE            supportapache_probes.d  configure      InstallBin.dsp  NWGNUmakefile     testap.d             configure.in   LAYOUT          os                VERSIONINGbuild            docs           libhttpd.dsp    READMEBuildAll.dsp     emacs-style    LICENSE         README.platforms$:./configure --prefix=/opt/apache(apache 文件要先mkdir /opt/apache)

............

$:make&&make install

..........

经过编译安装指定目录/opt/apache/,然后

$:cd /opt/apache/

$:ls

bin    cgi-bin  error   icons    logs  manualbuild  conf     htdocs  include  man   modules

$:cd bin

$:./apachectl -t

Syntax OK看到提示OK,说明apache已经成功安装;然后我们到网址上:http://虚拟主机的IP/

看到这里,说明我们apache服务器已经安装完成,当然,在安装的过程中,会遇到一些提示如:apr ,apr-util,prce等找不到的时候,我们要学会去看懂英语提示,找到这些提示这些文件源目录或文件,如果没有这些源程序(通过rpm -qa|grep apr ,apr-util,prce ),就去下载,并安装到指定的目录,以便在安装apache时通过--with--apr --with-apr-util --with-prce 找到这些文件完成apache编译安装;

下面讲HTTPD的安装,其实也是apache安装,因为我们知道,centos通常省力的安装方式是直接yum,这是一个很强的工具,我很喜欢哦;

在yum之前,我们要先配置好虚拟机的上网,

[root@CentOS2 ~]# ifconfigeth0      Link encap:Ethernet  HWaddr 00:0C:29:57:0C:DD            inet addr:192.168.1.223  Bcast:192.168.1.255  Mask:255.255.255.0          inet6 addr: fe80::20c:29ff:fe57:cdd/64 Scope:Link          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:4952 errors:0 dropped:0 overruns:0 frame:0          TX packets:2973 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000          RX bytes:6600644 (6.2 MiB)  TX bytes:211586 (206.6 KiB)          Interrupt:19 Base address:0x2000 lo        Link encap:Local Loopback            inet addr:127.0.0.1  Mask:255.0.0.0          inet6 addr: ::1/128 Scope:Host          UP LOOPBACK RUNNING  MTU:16436  Metric:1          RX packets:0 errors:0 dropped:0 overruns:0 frame:0          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)[root@CentOS2 ~]# routeKernel IP routing tableDestination     Gateway         Genmask         Flags Metric Ref    Use Iface192.168.1.0     *               255.255.255.0   U     0      0        0 eth0link-local      *               255.255.0.0     U     1002   0        0 eth0default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0[root@CentOS2 ~]#64 bytes from 220.181.111.86: icmp_seq=1 ttl=50 time=45.3 ms64 bytes from 220.181.111.86: icmp_seq=2 ttl=50 time=49.8 ms64 bytes from 220.181.111.86: icmp_seq=3 ttl=50 time=51.4 ms64 bytes from 220.181.111.86: icmp_seq=4 ttl=50 time=43.4 ms64 bytes from 220.181.111.86: icmp_seq=5 ttl=50 time=39.4 ms64 bytes from 220.181.111.86: icmp_seq=6 ttl=50 time=39.1 ms64 bytes from 220.181.111.86: icmp_seq=7 ttl=50 time=55.8 ms

$:  yum -y install httpd

看到Complete,说明已经大功告成了!然后我们来启动它;

[root@CentOS2 ~]# service httpd startStarting httpd: httpd: apr_sockaddr_info_get() failed for CentOS2httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName                                                           [  OK  ][root@CentOS2 ~]#

这里有个提示:httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

我们去查看/etc/httpd/conf/httpd.conf

[root@CentOS2 ~]# vi /etc/httpd/conf/httpd.conf

找到 #ServerName www.example.com:80把"#"去掉,改成"ServerName localhost:80".保存退出!然后再来:

[root@CentOS2 conf]# service httpd stopStopping httpd:                                            [  OK  ][root@CentOS2 conf]# service httpd startStarting httpd:                                            [  OK  ][root@CentOS2 conf]# 看到没有报错了,OK,说明 已经完成安装!

再来测试:http://虚拟主机IP/

哦,记得关了防火墙:service iptables stop!

到些,我们可以看到,这个WEB服务器已经安装成功,然后我们来总结一下,Centos下WEB服务安装区别,其实无非是一个YUM安装,一个是编译安装,但做为初学者,我建议是编译安装,这样方便我们查找配置;

YUM安装是简单快捷,但不建议,除非你对LINUX很熟悉,这样配置起来就方便多了;

文章分享结束,希望大家喜欢!

原创粉丝点击