温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

centos6.5下Apache 安装

发布时间:2020-06-24 13:07:34 来源:网络 阅读:703 作者:梦里天空蓝 栏目:开发技术

1.下载apache  www.apache.org 找到相应的地址复制后 weget即可,也可以用下面这个


wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.23.tar.gz
tar -xf httpd-2.4.23.tar.gz
./configure 
--prefix=/application/apache2.4.23
--enable-deflate 
--enable-expires
--enable-header 
--enable-modules=most 
--enable-rewrite
--enable-so
--with-mpm=worker

解释一下上面的参数:

--prefix 安装路径

--enable-modules=most 使用大部分常用模块

--enable-rewrite 重写模块

--with-mpm=work 运行方式为一个主进程若干个子线程,还可以配置为进程,配置为进程的优点是更稳定,但是同时也更慢,更耗费cpu资源,当前主流都是把apache作为静态服务器使用所以使用work就可以了。如果你要和php等程序做配合可以设置为进程方式工作。


2.进行到这一步的时候出现了错误提示找不到apr,逐回到apache.org下载 apr和apr-util


wget http://mirrors.cnnic.cn/apache/apr/apr-1.5.2.tar.gz

./configure --prefix=/application/apr
make
make install

wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.5.4.tar.gz 

./configure --prefix=/application/apr-util --with-apr=/application/apr
make
make install


3.重新安装apache,进入apache解压缩目录


./configure 
--prefix=/application/apache2.4.23
--enable-deflate 
--enable-expires
--enable-header 
--enable-modules=most 
--enable-rewrite
--enable-so
--with-mpm=worker
--with-apr=/application/apr --with-apr-util=/application/apr-util


4.继续报错

checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

这是因为没有安装zlib包,逐 yum 安装之

yum install zlib-devel


5.ok 装好后继续 make apache 这次没有问题了 继续 make install 至此安装完毕


6.修改/application/apache2.4.23/conf/httpd.conf 

找到#ServerName
去掉# 更改为: 
ServerName localhost:80

7.启动apache

/application/apache2.4.23/bin/httpd -k start


8.测试一下

curl 本机ip 如果 返回 it works 证明apache已经可以正常运行了


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI