Apache [阿帕奇] 是世界使用排名第一的Web服务器软件。
它可以运行在几乎所有广泛使用的计算机平台上, 由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。
它快速、可靠并且可通过简单的API扩充,将Perl/Python等解释器编译到服务器中。
1、apache推荐的2种安装方式
1)yum安装
yum install httpd
2)源码编译安装
[root@shell ~]# [root@shell ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.4 (Santiago) [root@shell ~]# [root@shell ~]# yum repolist [root@shell ~]# [root@shell ~]# ip addr show 1: lo:mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:15:0e:12 brd ff:ff:ff:ff:ff:ff inet 192.168.64.133/24 brd 192.168.64.255 scope global eth0 inet6 fe80::20c:29ff:fe15:e12/64 scope link valid_lft forever preferred_lft forever [root@shell ~]# [root@shell ~]# yum grouplist "Development Tools" [root@shell ~]# yum groupinstall "Development Tools" #安装开发工具包 [root@shell ~]# rpm -qa httpd [root@shell ~]# [root@shell ~]# wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.46.tar.gz #下载apache包 [root@shell ~]# tar zxf httpd-2.4.46.tar.gz -C /usr/local/src/ #解压 [root@shell ~]# cd /usr/local/src/ [root@shell src]# cd httpd-2.4.46 [root@shell httpd-2.4.46]# ./configure --prefix=/usr/local/httpd #编译 此时发现如下报错: checking for APR... no configure: error: APR not found . Please read the documentation …… 去网上查找解决方案得知,是apache在编译过程中缺少若干依赖导致的报错 解决方案如下: 需要安装三个依赖包,即可进行apache的安装 >[root@shell httpd-2.4.46]# wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz [root@shell httpd-2.4.46]# wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz [root@shell httpd-2.4.46]# wget ftp://ftp.pcre.org/pub/pcre/pcre-8.10.zip # tar -zxf apr-1.4.5.tar.gz # cd apr-1.4.5 # ./configure --prefix=/usr/local/apr # make && make install # cd .. # tar -zxf apr-util-1.3.12.tar.gz # cd apr-util-1.3.12 # ./configure --prefix=/usr/local/apr-until --with-apr=/usr/local/apr/bin/apr-1-config # make && make install # cd .. # cd apr-util-1.3.12 # unzip -o pcre-8.10.zip # cd pcre-8.10 # ./configure --prefix=/usr/local/pcre # make && make install # cd .. 接下来再次进行编译apache: [root@shell httpd-2.4.46]# ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-until --with-pcre=/usr/local/pcre # make # make install #安装 # ln -s /usr/local/httpd/bin/apachectl /etc/init.d/httpd #将启动命令链接到/etc/init.d中,方便启动服务 # vi /usr/local/httpd/conf/httpd.conf #按照红框处指导进行修改 找到下面的代码部分,进行修改 # # ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If your host doesn't have a registered DNS name, enter its IP address here. # #ServerName www.example.com:80 ServerName 192.168.64.133:80 #修改此处为自己的服务器地址即可 # # Deny access to the entirety of your server's filesystem. You must # explicitly permit access to web content directories in other # blocks below. # # # /etc/init.d/httpd restart #重启apache # yum install links #安装浏览器 # links 192.168.64.133 #访问web [root@shell ~]# curl 192.168.64.133 #访问webAllowOverride none Require all denied It works!
[root@shell ~]#
2、apache 安装后的验证
使用谷歌浏览器进行访问:

3、结论
源码编译apache,圆满成功,奥耶