dsfsfs 发表于 2018-11-18 13:33:07

Linux rhel 6.4 apache编译安装以及简单配置过程(1)

Linux rhel6.4 编译安装apache过程(1)
  

  注:以下摘取的都是安装过程中执行的命令,命令反馈没有贴出来以"......"代替。观看的时候注意执行命令时所在的目录。

  

  安装平台

  # cat /etc/redhat-release

  Red Hat Enterprise Linux Server release 6.4 (Santiago)
  

  需要的工具版本以及下载地址
  1.httpd-2.4.25.tar.gz
  (http://httpd.apache.org/download.cgi#apache24)
  2.apr-1.5.2.tar.gz
  (http://apr.apache.org/download.cgi)
  3.apr-util-1.5.4.tar.gz
  (http://apr.apache.org/download.cgi)
  4.pcre-8.40.tar.gz
  (https://ftp.pcre.org/pub/pcre/)
  

  下载好以后将这些工具上传到Linux的/media目录下。(我上传使用了winSCP工具)
  

  解压缩
  # cd /media/
  # tar zxvf apr-1.5.2.tar.gz -C /opt/
  ......
  # tar zxvf apr-util-1.5.4\ .tar.gz -C /opt/
  ......
  # tar zxvf pcre-8.40.tar.gz -C /opt/
  ......
  # tar zxvf httpd-2.4.25.tar.gz -C /opt/
  ......
  

  解压好后进入/opt目录,查看一下解压的结果
  # cd /opt/
  # ls
  apr-1.5.2apr-util-1.5.4httpd-2.4.25pcre-8.40rh
  

  检查一下是否有Linux自带的httpd服务,如果有需要关闭相关的服务并用rpm卸载httpd相关的包。
  # rpm -qa | grep httpd
  #
  我这里并之前并没有安装httpd相关的包。
  

  安装httpd还需要gcc-c++
  # yum -y install gcc-c++*
  ......
  

  安装apr apr-util以及pcre三个工具,如果不安装这三个工具编译httpd的时候会报错,提示需要这三个工具。
  安装apr

  # cd apr-1.5.2/
  # ls
  ......

  # ./configure --prefix=/usr/local/apr
  ......
  # make
  ......
  # make install
  ......
  继续安装apr-util
  # cd /opt/apr-util-1.5.4/
  # ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
  ......
  # make
  ......

  # make install
  ......
  继续安装pcre
  # cd /opt/pcre-8.40/
  # ./configure --prefix=/usr/local/pcre
  ......
  # make
  ......
  # make install
  ......

  

  这三个工具编译安装好后就可以继续httpd的安装了
  # ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
  (安装httpd并给出三个工具的路径)
  ......
  # make
  ......
  # make install
  ......
  

  编译结束后如果没有报error的话,安装基本就结束了。
  尝试下启动apache
  启动:
  # /usr/local/apache/bin/apachectl start
  AH00557: httpd: apr_sockaddr_info_get() failed for chengmanyu.test
  AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
  (上面的问题并不影响使用,在接下来的配置中我们设置一下主机名就可以避免这个提示)
  

  如果没有什么报错,那么apache已经开始运行了,我们检测一下我们的劳动成果。
  先关掉本机的防火墙
  # service iptables stop
  iptables: Flushing firewall rules:                        
  iptables: Setting chains to policy ACCEPT: filter         
  iptables: Unloading modules:                              
  

  然后用在同一个域中的其他主机或在本机的浏览器中输入apache所在主机的 ip:80(ip+:80),浏览器跳转页面显示
  it works!
  到这里apache的安装已经完成了,但是现网中这样并不能直接使用还需要一些简单的设置。



页: [1]
查看完整版本: Linux rhel 6.4 apache编译安装以及简单配置过程(1)