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

[经验分享] Linux 编译安装apache及应用

[复制链接]

尚未签到

发表于 2018-11-17 10:29:45 | 显示全部楼层 |阅读模式
  Linux  下简单配置apache
   本文操作系统是centos7,安装的httpd的版本是2.4,下载的源码包是httpd-2.4.27.tar.bz2,依赖是apr-devel-1.4.8.tar.bz2,pcre-devel-8.32.tar.bz2,apr-util-devel-1.5.2.tar.bz2
  
  软件安装一般分为源码编译安装、yum安装和rpm包安装。本文介绍源码安装。
  源码编译安装分为三部分:configure脚本 ;make;make install
  1.下载源码:×××,依赖下载地址:依赖下载
  2.相关依赖,安装apache需要首先安装Development Tools
[root@localhost(yuaning) ~]# yum grouplist Development Tools   (查看有没有安装)  
[root@localhost(yuaning) ~]# yum groupinstall “Development Tools”    (安装组Development Tools)
  然后依次安装apr-devel,apr-util-devel,pcre-devel
[root@localhost(yuaning) ~]#  tar xvf apr-devel-1.4.8.tar.bz2   #解压  
[root@localhost(yuaning) ~]#  ls
  
apr-devel-1.4.8    apr-devel-1.4.8.tar.bz2
  
[root@localhost(yuaning) ~]#  cd apr-devel-1.4.8
  
[root@localhost(yuaning) ~]#  ./configure --prefix=/app/apr      #--prefix=/PATH: 指定默认安装位置
  
[root@localhost(yuaning) ~]#  make -j 4       # -j 4 调用cpu的个数,根据自己的配置而定
  
[root@localhost(yuaning) ~]#  make install       #其他两个雷同,不做演示
  这三个依赖也可以用yum安装
[root@localhost(yuaning) ~]# yum install apr-devel -y  
[root@localhost(yuaning) ~]# yum install apr-util-devel -y
  
[root@localhost(yuaning) ~]# yum install pcre-devel -y
  3.解压,tar xvf httpd...
[root@localhost(yuaning)  ~]# ls  
httpd-2.2.34.tar.bz2
  
[root@localhost(yuaning)  ~]# tar xvf httpd-2.2.34.tar.bz2
  
[root@localhost(yuaning)  ~]# ls
  
httpd-2.2.34  httpd-2.2.34.tar.bz2
  
[root@localhost(yuaning)  ~]#  ./configure --prefix=/app/apache --sysconfdir=/etc/apache #--sysconfdir=/PATH配置文件默认位置
  
[root@localhost(yuaning)  ~]#  make -j 4
  
[root@localhost(yuaning)  ~]#  make install
  安装过程还是三步,现在说一下具体的选项:






            •   --prefix=/PATH: 指定默认安装位置
            •   --sysconfdir=/PATH 配置文件默认位置
            •   --enable-so:支持动态共享模块,如果支持php将不能与apache一起工作,必须要有
            •   --enable-ssl:启用ssl功能,如果不启用将无法使用https
            •   --enable-mpms-shared=all:prefork、worker、event
            •   --with-mpm=event:event为默认
            •   --enable-rewrite:支持URL重写
            •   --enable-cgi :支持cgi
            •   --enable-cgid:httpd使用event或者worker得启用被线程方式访问
            •   --enable-modules=most :启用大多数模块
            •   --enable-mods-shared=most:启用大多数共享模块





  4. 添加环境变量(选做)
  path后面加上安装位置,否则每次开启服务的时候都会加上很长路径。如下
[root@localhost(yuaning) ~]# vim /etc/profile.d/cyn.sh  
export PATH=$PATH:/app/apache/bin
  
[root@localhost(yuaning) profile.d]# source cyn.sh
  5.启动服务
[root@localhost(yuaning) ~]# ls /app/apache/bin/  
ab         apxs      dbmmanage  envvars-std  htcacheclean  htdigest  httpd      logresolve
  
apachectl  checkgid  envvars    fcgistarter  htdbm         htpasswd  httxt2dbm  rotatelogs
  
[root@localhost(yuaning) ~]# apachectl start        #这是正常启动
  有时候启动服务的的时候会报错,如下
[root@localhost(yuaning) ~]# apachectl start  
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain.
  
Set the 'ServerName' directive globally to suppress this message
  有时候启动服务会报错,错误的原因有很多。例如下面这个,因为servername引起的错误
[root@localhost(yuaning) ~]# vim /etc/apache/httpd.conf  
#ServerName www.example.com:80
  
ServerName localhost:80
  有时候,还会因为端口占用引起错误
[root@localhost(yuaning) ~]# apachectl start  
apache2 address already in use:make_sock:could not bind to address [::]:80
  
[root@localhost(yuaning) ~]# netstat -lnp|grep 80
  
tcp6       0      0 :::80                   :::*                    LISTEN      21619/httpd     #进程httpd的id是21619
  
[root@localhost(yuaning) ~]# kill 21619      #杀死进程
  
[root@localhost(yuaning) ~]# apachectl start     #重新启动服务
  还有可能是因为防火墙的原因
[root@localhost(yuaning) htdocs]# iptables -F    #清除防火墙即可  6.添加欢迎页面
  到这里你在浏览器地址栏输入你的本地IP会出现 It work !字样,说明你的apache简单配置完成了。你也可以自己添加,如下
[root@localhost(yuaning) htdocs]# vim /app/apache/htdocs/index.html  
i am cyn !           #HTML文档,自行添加
DSC0000.jpg

  只能是本机的浏览器才能访问,要想其他人也可访问,把你的Linux搞到云服务器上配置个公网IP即可。



运维网声明 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-636121-1-1.html 上篇帖子: apache中的php模块安装 下篇帖子: Linux Apache web服务器 配置详细教程
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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