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

[经验分享] apache安装(适用于初学者)

[复制链接]

尚未签到

发表于 2018-11-20 08:07:50 | 显示全部楼层 |阅读模式
应用系统是centos 6.x  httpd 2.2 (apache2.4版本对apr版本要求在1.4以上,

  [root@lanmp httpd-2.2.31]# rpm -q apr
  apr-1.3.9-5.el6_2.x86_64
yum安装的是1.3.9版主,安装2.4版本需要源码包安装apr)


为了不影响实验效果,提前可以把selinux 和iptables 关闭  

[root@localhost ~]# chkconfig iptables off
[root@localhost ~]# chkconfig ip6tables off
[root@localhost ~]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@localhost ~]# /etc/init.d/ip6tables stop
ip6tables: Setting chains to policy ACCEPT: filter         [  OK  ]
ip6tables: Flushing firewall rules:                        [  OK  ]
ip6tables: Unloading modules:                              [  OK  ]


[root@localhost ~]# sed -i "s/LINUX=.*/LINUX=disabled/g" /etc/selinux/config
[root@localhost ~]# grep -i --color linux /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX=disabled
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
SELINUXTYPE=targeted
更改完selinux后要想生效需要重启一下服务器,reboot或者shutdown -r now



yum install  gcc gcc-c++ zlib-devel pcre pcre-devel apr apr-deve
这些是支持包 为了防止报错 提前yum 一下
  

  

  1,下载
  #cd /usr/local/src/
  #wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.31.tar.gz(2.2版本)
  

  2,解压
  # tar zxvf httpd-2.2.31.tar.gz
  

  3,配置编译参数
  # cd httpd-2.2.31
  # ls
  ABOUT_APACHE  config.layout  httpd.spec      LICENSE        README.platforms
  acinclude.m4  configure      include         Makefile.in    README-win32.txt
  Apache.dsw    configure.in   INSTALL         Makefile.win   ROADMAP
  build         docs           InstallBin.dsp  modules        server
  BuildAll.dsp  emacs-style    LAYOUT          NOTICE         srclib
  BuildBin.dsp  httpd.dep      libhttpd.dep    NWGNUmakefile  support
  buildconf     httpd.dsp      libhttpd.dsp    os             test
  CHANGES       httpd.mak      libhttpd.mak    README         VERSIONING
  #./configure  --prefix=/usr/local/apache2  --with-included-apr   --enable-so  --enable-deflate=shared  --enable-expires=shared --enable-rewrite=shared --with-pcre
  --prefix=/usr/local/apache2  指定安装位置  --with-included-apr 可以跨平台
  --enable-deflate=shared  --enable-expires=shared --enable-rewrite=shared --with-pcre表示以动态共享的模式安装   --with-pcre 表示正则相关的一个库
  

  4, 编译安装
  # make && make install && echo $?
  

  5 测试
  # /usr/local/apache2/bin/apachectl start  (启动服务)
  # /usr/local/apache2/bin/apachectl stop    (停止当前服务)
  # /usr/local/apache2/bin/apachectl graceful   (只加载配置文件)
  # ps aux | grep httpd
  root     20367  0.1  0.1   4396  1696 ?        Ss   18:07   0:00 /usr/local/apache2/bin/httpd -k start
  daemon   20368  0.0  0.1   4396  1120 ?        S    18:07   0:00 /usr/local/apache2/bin/httpd -k start
  daemon   20369  0.0  0.1   4396  1120 ?        S    18:07   0:00 /usr/local/apache2/bin/httpd -k start
  daemon   20370  0.0  0.1   4396  1120 ?        S    18:07   0:00 /usr/local/apache2/bin/httpd -k start
  daemon   20371  0.0  0.1   4396  1120 ?        S    18:07   0:00 /usr/local/apache2/bin/httpd -k start
  daemon   20372  0.0  0.1   4396  1120 ?        S    18:07   0:00 /usr/local/apache2/bin/httpd -k start
  root     20381  0.0  0.0   6056   796 pts/0    S+   18:09   0:00 grep httpd
  #netstat -lnp |grep 80
  tcp        0      0 :::80                       :::*                        LISTEN      20367/httpd
  

  

  到这里apache就安装完毕了 可以在IE里面输入ip地址访问一下 ,如果报错请检查一下selinux和iptables或者检测服务是否开启
  
  
  # /usr/local/apache2/bin/apachectl -l   (查看静态模块)
  # /usr/local/apache2/bin/apachectl -M   (查看动态模块)
  命令是不是很长啊 我们做一些修改 编辑path文件然后自定义
[root@lanmp httpd-2.2.31]#vim /etc/profile.d/path.sh
[root@lanmp httpd-2.2.31]# cat !$
cat /etc/profile.d/path.sh
#!/bin/bash
export PATH=$PATH:/usr/local/apache2/bin
[root@lanmp httpd-2.2.31]#. /etc/profile.d/path.sh 或者 source  /etc/profile.d/path.sh


  # ls /usr/local/apache2/modules/     (动态配置文件)
  httpd.exp  mod_deflate.so  mod_expires.so  mod_rewrite.so
  # ls /usr/local/apache2/bin/httpd    (静态配置文件)
  /usr/local/apache2/bin/httpd
  

  

  

  [root@lanmp httpd-2.2.31]# apachectl start    (启动服务)
  [root@lanmp httpd-2.2.31]# apachectl stop    (关闭服务)
  
  [root@lanmp httpd-2.2.31]# apachectl -l     (查看静态模块)
  [root@lanmp httpd-2.2.31]# apachectl -M     (查看动态模块)
  
  [root@lanmp httpd-2.2.31]# apachectl -t      (检测配置文件)
  
  [root@lanmp httpd-2.2.31]# ls /usr/local/apache2/conf/httpd.conf  (语法配置文件)
  [root@lanmp httpd-2.2.31]# vim /usr/local/apache2/htdocs/index.html (网页内容)
  这些要熟记哦




运维网声明 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-637140-1-1.html 上篇帖子: 使用百度云加速防apache的ab测试 下篇帖子: 解决apache日志产生"internal dummy connection"方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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