码迷,mamicode.com
首页 > 其他好文 > 详细

RedHat6.4系统下LAMP环境的搭建---(源码包编译安装)---

时间:2016-01-05 15:10:46      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:

(一)httpd(源码包安装)

安装准备:

1 安装htppd软件所依赖的软件包

yum -y install gcc gcc-c++ pcre pcre-devel apr apr-devel apr-util apr-util-devel zlib zlib-devel openssl openssl-devel

安装完成显示如下:

Installed:
  apr.x86_64 0:1.3.9-5.el6_2                    apr-devel.x86_64 0:1.3.9-5.el6_2                 
  apr-util.x86_64 0:1.3.9-3.el6_0.1             apr-util-devel.x86_64 0:1.3.9-3.el6_0.1          
  gcc.x86_64 0:4.4.7-3.el6                      gcc-c++.x86_64 0:4.4.7-3.el6                     
  openssl-devel.x86_64 0:1.0.0-27.el6           pcre-devel.x86_64 0:7.8-6.el6                    
  zlib-devel.x86_64 0:1.2.3-29.el6             

Dependency Installed:
  cloog-ppl.x86_64 0:0.15.7-1.2.el6                 cpp.x86_64 0:4.4.7-3.el6                      
  cyrus-sasl-devel.x86_64 0:2.1.23-13.el6_3.1       db4-cxx.x86_64 0:4.7.25-17.el6                
  db4-devel.x86_64 0:4.7.25-17.el6                  expat-devel.x86_64 0:2.0.1-11.el6_2           
  glibc-devel.x86_64 0:2.12-1.107.el6               glibc-headers.x86_64 0:2.12-1.107.el6         
  kernel-headers.x86_64 0:2.6.32-358.el6            keyutils-libs-devel.x86_64 0:1.4-4.el6        
  krb5-devel.x86_64 0:1.10.3-10.el6                 libcom_err-devel.x86_64 0:1.41.12-14.el6      
  libselinux-devel.x86_64 0:2.0.94-5.3.el6          libsepol-devel.x86_64 0:2.0.41-4.el6          
  libstdc++-devel.x86_64 0:4.4.7-3.el6              mpfr.x86_64 0:2.4.1-6.el6                     
  openldap-devel.x86_64 0:2.4.23-31.el6             ppl.x86_64 0:0.10.2-11.el6 

2 检查安装apache软件所需的软件包是否全部安装完成

[root@Chris ~]# rpm -q gcc gcc-c++ pcre pcre-devel apr apr-devel apr-util apr-util-devel zlib zlib-devel openssl openssl-devel

一共为12个软件包 如果都安装完成则表示可以对apache源码进行编译安装,显示如下

[root@Chris ~]# rpm -q gcc gcc-c++ pcre pcre-devel apr apr-devel apr-util apr-util-devel zlib zlib-devel openssl openssl-devel
gcc-4.4.7-3.el6.x86_64
gcc-c++-4.4.7-3.el6.x86_64
pcre-7.8-6.el6.x86_64
pcre-devel-7.8-6.el6.x86_64
apr-1.3.9-5.el6_2.x86_64
apr-devel-1.3.9-5.el6_2.x86_64
apr-util-1.3.9-3.el6_0.1.x86_64
apr-util-devel-1.3.9-3.el6_0.1.x86_64
zlib-1.2.3-29.el6.x86_64
zlib-devel-1.2.3-29.el6.x86_64
openssl-1.0.0-27.el6.x86_64
openssl-devel-1.0.0-27.el6.x86_64

下面我来给大家简单的介绍这个软件依赖包的作用

gcc              软件编译器,用来编译软件的时候使用                             (必装)
gcc-c++               让ggc软件编译器支持编译c++程序语言                        (必装)
pcre              是一个用C语言编写的正则表达式函数库                            (必装)
pcre-devel            pcre软件包的使用库                         (必装)
apr               Apache可移植运行库,用来支持apache软件跨平台安装使用的。      (必装)
apr-devel             apr软件包的使用库                                               (必装)
apr-util              apr软件工具包                         (必装)
apr-util-devel        apr软件工具包库                                                 (必装)
zlib               提供数据压缩用的函式库,用来压缩传输网页文件的                   (建议安装)
zlib-devel            zlib软件包的使用库                                 (建议安装)
openssl               是一个强大的安全套接字层密码库,用来增强apache服务器安全的       (建议安装)
openssl-devel         openssl软件的使用库                                              (建议安装)

 开始编译安装httpd-2.2.4.tar.bz23

上传httpd-2.2.4.tar.bz2文件到指定目录

[root@Chris ~]# ll | grep httpd-2.2.4.tar.bz2 
-rw-r--r--. 1 root root 4930375 11月 21 21:34 httpd-2.2.4.tar.bz2

4 解压httpd-2.2.4.tar.bz2压缩文件

[root@Chris ~]# tar xf httpd-2.2.4.tar.bz2 

5 cd到解压httpd文件夹中,并查看解压的文件

[root@Chris ~]# cd httpd-2.2.4
[root@Chris httpd-2.2.4]# ls
ABOUT_APACHE      buildconf      emacs-style     LAYOUT        NOTICE            server
acinclude.m4      CHANGES        httpd.dsp       libhttpd.dsp  NWGNUmakefile     srclib
Apache.dsw        config.layout  httpd.spec      LICENSE       os                support
apachenw.mcp.zip  configure      include         Makefile.in   README            test
build             configure.in   INSTALL         Makefile.win  README.platforms  VERSIONING
BuildBin.dsp      docs           InstallBin.dsp  modules       ROADMAP

6 开始使用./configure命令编译安装apache软件源码包。对即将安装的软件进行配置,检查当前的环境是否满足要安装软件的依赖关系

./configure参数:

[root@Chris httpd-2.2.4]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --enable--module-ssl --enable-cgi --enable-cgid --enable-rewrite --enable-modules=most --enable-mpms-shared=most --with-mpm=worker --with-zlib

验证./configure软件配置检查是否成功!如果输入echo $?命令  输出的显示为0  那么就表示源码配置检查通过,则可以进行下一步安装

[root@Chris httpd-2.2.4]# echo $?
0

 7 apache源码包检查通过以后,下面我就开始进行编译安装啦!

[root@Chris httpd-2.2.4]# make && make install

输入命令以后可能要等待一段时候,我们最后输入echo $?命令  输出的显示为0 则表示安装完成!

[root@Chris httpd-2.2.4]# echo $?
0

8 源码安装完成以后,开启apache服务

[root@Chris httpd-2.2.4]# /usr/local/apache/bin/apachectl start
httpd: apr_sockaddr_info_get() failed for Chris
httpd: Could not reliably determine the servers fully qualified domain name, using 127.0.0.1 for ServerName
[root@Chris httpd-2.2.4]#

通过查看端口,查看apache服务器是否开启成功

[root@Chris httpd-2.2.4]# netstat -ltnp |grep :80
tcp        0      0 :::80                       :::*                        LISTEN      16640/httpd         

 

开启Apache服务器的防火墙的80端口

 

9 开启系统防火墙的80端口,使外网的人可以访问

[root@Chris httpd-2.2.4]# iptables -t filter -I INPUT -p tcp --dport 80 -j ACCEPT

保存当前的防火墙配置

[root@Chris httpd-2.2.4]# /etc/rc.d/init.d/iptables save
iptables:将防火墙规则保存到 /etc/sysconfig/iptables:[确定]
[root@Chris httpd-2.2.4]# 

重启防火墙服务使配置生效

[root@Chris httpd-2.2.4]# service iptables restart
iptables:清除防火墙规则:[确定]
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:正在卸载模块:[确定]
iptables:应用防火墙规则:[确定]

 

关闭SeLinux(生产环境不建议关闭)

10 Linux系统中的selinux功能可能会影响我们对于网站服务器的配置,所以为了方便大家的实验,建议关闭

[root@Chris ~]# vi /etc/selinux/config

注释:#SELINUX=enforcing

添加:SELINUX=disabled

最终修改后显示结果如下:

技术分享
[root@Chris ~]# vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
技术分享

保存退出即可!到了这里我们就把selinux给禁用啦。

 

修改Apche服务的PID文件路径(重要)

这一步关系到开机apache启动脚本是否能够成功

11 编辑apache配置文件

[root@Chris httpd-2.2.4]# vi /etc/httpd/httpd.conf

添加如下代码:PidFile "/var/run/httpd.pid"

# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk.  If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile.
#
ServerRoot "/usr/local/apache"
PidFile "/var/run/httpd.pid"

保存并重启Apache服务器,

[root@Chris httpd-2.2.4]# /usr/local/apache/bin/apachectl restart
httpd: apr_sockaddr_info_get() failed for Chris
httpd: Could not reliably determine the servers fully qualified domain name, using 127.0.0.1 for ServerName
httpd not running, trying to start
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

ps:如果在重启httpd服务出现以上错误的话,那么就表示你的httpd进程PID没有关闭,需要关闭以后在重启httpd服务器

 

 

 

创建启动脚本设置Apache服务开机自动启动

 

RedHat6.4系统下LAMP环境的搭建---(源码包编译安装)---

标签:

原文地址:http://www.cnblogs.com/liwenxuan/p/5102129.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!