设为首页 收藏本站
查看: 605|回复: 0

[经验分享] 编译安装apache

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-7-31 07:11:55 | 显示全部楼层 |阅读模式
  首先注明下面的操作都是在root下执行或者使用sudo命令。
  1)去http://httpd.apache.org/download 下载apache源码
  2)解压到/usr/src,在下载目录执行tar -zxvf httpd-x.x.x.tar.gz -C /usr/src  (我用的是httpd-2.4.3.tar.gz)
  3)进入目录/usr/src/httpd-2.4.3,执行:./configure --prefix=/usr/local/apache2 --with-mpm=worker --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atomics --enable-mods-shared=most --enable-so --enable-rewrite --enable-ssl
  4)出现configure: error: APR not found。解决办法:
  4.1)去apr下载地址 http://apr.apache.org/ 下载源码
  4.2)解压到/usr/src,在下载目录执行tar -zxvf apr-x.x.x.tar.gz -C /usr/src/  (我用的是apr-1.4.6.tar.gz)
  4.3)进入目录/usr/src/apr-1.4.6,执行./configure --prefix=/usr/local/apr;make;make install
  5)再次进入目录/usr/src/httpd-2.4.3,增加参数--with-apr=/usr/local/apr/,重新执行:./configure --prefix=/usr/local/apache2 --with-mpm=worker --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atomics --enable-mods-shared=most --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr/
  6)出现configure: error: APR-util not found .解决办法
       6.1)去apr-util下载地址 http://apr.apache.org/ 下载源码
       6.2)解压到/usr/src,在下载目录执行tar -zxvf apr-util-x.x.x.tar.gz -C /usr/src/  (我用的是apr-util-1.5.1.tar.gz)
  6.3)进入目录/usr/src/apr-util-1.5.1,执行./configure --prefix=/usr/local/apr-util;make;make install
  7)再次进入目录/usr/src/httpd-2.4.3,增加参数--with-apr-util=/usr/local/apr-util/,重新执行:./configure --prefix=/usr/local/apache2 --with-mpm=worker --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atomics --enable-mods-shared=most --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
  8)出现configure: error: pcre-config for libpcre not found.解决办法:
       8.1)去pcre下载地址 http://pcre.org/ 下载源码
  8.2)解压到/usr/src,在下载目录执行tar -zxvf pcre-x.x.tar.gz -C /usr/src/  (我用的是pcre-8.31.tar.gz)
  8.3)进入目录/usr/src/pcre-8.31,执行./configure --prefix=/usr/local/pcre;make;make install
  9)再次进入目录/usr/src/httpd-2.4.3,增加参数--with-pcre=/usr/local/pcre,重新执行:./configure --prefix=/usr/local/apache2 --with-mpm=worker --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atomics --enable-mods-shared=most --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
  10)出现configure: WARNING: OpenSSL version is too old;checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures;解决办法:
  10.1)openssl源码下载地址http://www.openssl.org/source/  下载源码
  10.2)解压到/usr/src,在下载目录执行tar -zxvf openssl-x.x.x.tar.gz -C /usr/src/  (我用的是openssl-1.0.1c.tar.gz)
  10.3)进入目录/usr/src/openssl-1.0.1c,执行./config --prefix=/usr/local/openssl;make;make install
  11)再次进入目录/usr/src/httpd-2.4.3,增加参数--with-ssl=/usr/local/openssl,重新执行:./configure --prefix=/usr/local/apache2 --with-mpm=worker --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atomics --enable-mods-shared=most --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --with-ssl=/usr/local/openssl ;make ;make install;
  成功执行。
  12)启动apache,进入/usr/local/apache2/bin目录,执行命令sudo ./httpd -k stop/start/restart 或者 sudo apachectl start/stop/restart(apachectl是执行脚本)
  13)设置httpd在任何目录下都可以运行,打开vim /etc/environment,增加配置/usr/local/apache2/bin
  14)设置apache开机自动启动,首先拷贝apachectl到目录/etc/init.d/,执行命令sudo cp apachectl /etc/init.d/ ;然后执行sudo update-rc.d apachectl defaults
  15) 在root下执行apachectl start/stop失败,报错:httpd: Could not reliably determine the server's fully qualified domain name。
        解决办法:(1)进入apache的安装目录:(视个人安装情况而不同) [iyunv@server ~]# cd /usr/local/apache/conf

       (2)编辑httpd.conf文件,搜索"#ServerName",添加ServerName localhost:80
           (3)重新启动apache 即可。执行apachectl restart
  16)遇到报错:Permission denied: make_sock: could not bind to address 0.0.0.0:80
  网上搜到的解决办法如下:
  httpd文件的权限必须是4755并且归属root用户…..简单的说,s能让普通用户作为文件属主/组运行,因为有些程序只有文件属主/组才能运行的,如 /usr/bin/ping,ping命令只能由      root运行,为了让普通用户也能运行,就必须加上s位,你可试验一下:
  先去除s:chmod 755 ping
      用普通用户运行ping,你会发现权限不足。
      加上s:chmod 4755 ping
      再运行就正常了。
  ps:对shell脚本设置无效!只对应用程序有效!
  17)去浏览器输入127.0.0.1,可以显示apache自带的网页It works。该网页的默认目录是在/usr/local/apache2/htdocs/。apache到此就安装OK了。
  参考网址:
  http://www.iyunv.com/huzhiwei/archive/2012/07/19/2599854.html
  http://johnly.blog.iyunv.com/742359/152153
  http://1556359.blog.iyunv.com/1546359/513833
  http://callaly.net/blog/archives/94.html
  http://hi.baidu.com/azazd666/item/5a4581f4160177df6225d26f

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-92421-1-1.html 上篇帖子: apache工作模式:prefork和worker 下篇帖子: ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: Incompatible namespaceIDs
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表