killerxf 发表于 2017-12-25 06:18:10

linux应用之apache的源码安装(centos)

linux应用之apache的源码安装(centos)

[*]第一部分:前期准备 需要下载的东西
[*]
[*]下载 Apache 源码包下载地址: http://httpd.apache.org/download.cgi                           我下载的httpd-2.4.20.tar.gz
[*]
[*]下载 Apr                     下载地址 :http://archive.apache.org/dist/apr/apr-1.5.0.tar.gz      我下载的是 apr-1.5.0.tar.gz
[*]
[*]下载 Apr-Util               下载地址:http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz   我下载的是 apr-util-1.5.4.tar.gz
[*]
[*]注意事项:wgetvim   gcc gcc-c++   cmake这几个也是安装 Apache 所需要的小环境 。有的小环境,一般 Cnetos自带,我个人建议还是手动的再用 yum install安装 或者 更新一下。
[*]那么好了,接下来开始安装吧!
[*]
[*]第一步:解压下载好的 Apache 包
[*]
[*]#   tar -zxvf httpd-2.4.20.tar.gz
[*]
[*]//进入目录编译解压的原文件
[*]
[*]# ./configure --prefix=/usr/local/apache2/          #配置安装目录
[*]
[*]1.正常执行 (说明你的Linux安装过Apache,或者已经安装过所需的依赖包)
[*]
[*]2.不正常执行、会出现以下错误信息
[*]
[*]configure:
[*]checking for APR... no
[*]configure: error: APR not found.Please read the documentation.
[*]
[*]解决方案:就是安装 刚刚下载好的 Apr。Apache在安装时需要一些准备环境、这里需要安装另外一个 Apr(Apache portable runtime)
[*]
[*]第二步:解压下载好的 Apr 包
[*]
[*]#   tar -zxvf apr-1.5.1.tar.gz
[*]
[*]//进入目录编译解压的原文件
[*]
[*]# ./configure --prefix=/usr/local/apr/               #配置安装目录
[*]
[*]//安装目录配置完成就 make && make install在指定地址生成目录和文件
[*]
[*]# make && make install
[*]
[*]第三步:解压下载好的 Apr-util 包
[*]
[*]# tar -zxvfapr-util-1.5.4.tar.gz
[*]
[*]//进入目录编译解压的原文件
[*]
[*]# ./configure --prefix=/usr/local/apr-util/               #配置安装目录
[*]
[*]//报错   看到错误信息   现在自己就知道了吧   --with-apr
[*]
[*]# ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/
[*]
[*]//安装目录配置完成就 make && make install在指定地址生成目录和文件
[*]
[*]# make && make install
[*]
[*]第四步:继续安装 Apache
[*]
[*]//切换到 Apache源文件
[*]
[*]# ./configure --prefix=/usr/local/apache24/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
[*]
[*]//还会出现下面的错误    原因是:还是缺少环境 PCRE
[*]
[*]checking for pcre-config... false
[*]configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
[*]
[*]解决方案:下载地址http://jaist.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz       下载最新版本我下载的是 pcre-8.39.tar.gz
[*]
[*]# wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz
[*]
[*]# tar -zxvf pcre-8.39.tar.gz
[*]
[*]# ./configure --prefix=/usr/local/pcre/
[*]# make && make install
[*]
[*]第五步:继续安装 Apache
[*]
[*]# ./configure --prefix=/usr/local/apache24/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
[*]# make && make install
[*]
[*]第六步:测试 Apache
[*]
[*]centos7使用systemctl代替chkconfig管理服务,防火墙也由iptables更换成了firewalld
[*]
[*]首先用systemctl关闭防火墙:
[*]
[*]systemctl stop firewalld.service
[*]
[*]systemctl disable firewalld.service
[*]
[*]开启 Apache 服务             停止 stop
[*]
[*]# cd /usr/local/apache24/bin/
[*]
[*]# ./apachectl start
[*]
[*]第七步:在客户端浏览器输入自己的 IP 地址,看看能够成功访问 Apache。
[*]
[*]成功显示 It Works!就代表 服务器已成功启动~\(≧▽≦)/~啦啦啦。
[*]
[*]在自己一步步的操作下,很高心成功啦。也不枉费读者们耐心的看完! 谢 谢 点 赞!
[*]
[*]
[*]
[*]
[*]
[*]
[*]附加: 如果在 安装 Apache 的时候,使用的是这个命令,则你就可以 进行一下操作了。
[*]
[*]./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-cgi --enable-ssl --enable-rewrite --with-ssl=/usr/local/openssl --with-pcre=/usr/local/pcre --with-z=/usr/local/zlib --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-ssl=/usr/local/openssl --enable-modules=most --enable-mpms-shared=all --with-mpm=event
[*]
[*]
[*]因为安装Apache服务器是选择安装了支持openssl,顺便研究了一下如何在apache中配置openss
[*]
[*]首先在/etc/httpd/http.conf文件中修改:
[*]
[*]ServerName为www.example.com:80
[*]
[*]去掉LoadModule ssl_module modules/mod_ssl.so前的#号
[*]
[*]去掉LoadModule socache_shmcb_module modules/mod_socache_shmcb.so前的#号
[*]
[*]去掉Include /etc/httpd/extra/httpd-ssl.conf前的#号
[*]
[*]生成服务器证书:
[*]
[*]1.生成服务器用的私钥文件server.key
[*]
[*]openssl genrsa -out server.key 1024
[*]
[*]2.生成未签署的server.csr
[*]
[*]openssl req -new -key server.key -out server.csr
[*]
[*]程序提示输入一系列参数,包括国别、省名、市名。。。,按照提示输入即可
[*]
[*]3.签署服务器证书文件server.crt
[*]
[*]openssl req -x509 -days 365 -key server.key -in server.csr -out server.crt
[*]
[*]然后将生成的server.key、server.csr、server.crt拷贝到/etc/httpd目录下
[*]
[*]/usr/local/apache/bin/apachectl restart
[*]
[*]浏览器访问:http://192.168.1.75/ 此时浏览器会提示安装证书,安装后显示页面It works!,证明ssl模块已正常工作。
  posted on 2016-12-17 13:21 madtank 阅读(...) 评论(...)编辑 收藏
页: [1]
查看完整版本: linux应用之apache的源码安装(centos)