LAMP部署-- 一.编译安装Apache

LAMP组件介绍

  • LAMP是指Linux、Apache,Mysql以及PHP的简称,目前许多生产环境的都是用的LAMP架构,在网络应用和开发环境方面,LAMP组合是非常棒的,它们的结合提供了强大的功能。
  • Linux作为底层的操作系统,提供了灵活且安全的应用平台,为其他的组件稳定运行提供了保障;
  • Apache作为web服务器,提供了功能强大、稳定与支撑能力突出的web平台;
  • Mysql也是一款优秀的数据库软件;
  • PHP是一种开发脚本语言,可以嵌入HTML中,适用于web开发;

准备工作

操作系统:RHEL 6.5

相关软件包:百度网盘 密码:bty7

一、Apache安装

  1. 解压http、apr、apr-util((支持Apache上层应用跨平台,提供底层接口库))软件包至/opt下
    tar xzvf http-2.4.2.tar.gz -C /opt
    tar xzvf apr-1.4.6.tar.gz -C /opt  
    tar xzvf apr-util-1.4.1.tar.gz -C /opt
  2. 进入软件包目录,复制apr、apr-util包至httpd目录下
    cd /opt
    cp -R apr-1.4.6 /opt/httpd-2.4.2/srclib/apr
    cp -R apr-util-1.4.1 /opt/httpd-2.4.2/srclib/apr-util
  3. 安装 gcc 、 gcc-c++ 、 make 、 pcre、pcre-devel 四个包
    yum install gcc gcc-c++ make pcre pcre-devel -y 
  4. 进入httpd目录下,configure配置
    cd /opt/httpd-2.4.2
    #配置
    ./configure \
    --prefix=/usr/local/apache \
    --enable-so \
    --enable-rewrite \
    --enable-mods-shared=most \
    --with-mpm=worker \
    --disable-cgid \
    --disable-cgi
    #编译及安装
    make && make install
  5. 过滤掉注释行(#)并复制httpd服务文件至/etc/init.d/
grep -v "#" /usr/local/apache/bin/apachectl > /etc/init.d/httpd
  1. 编辑httpd文件
vi /etc/init.d/httpd 
#在文件最前面插入下面的行
\#!/bin/sh
\# chkconfig:2345 85 15
\# description:Apache is a World Wide Web server.
  1. 给httpd文件添加执行权限
chmod +x /etc/init.d/httpd
  1. 添加httpd服务,并设置为init3、init5时开机自启动
chkconfig --add httpd
chkconfig --level 35 httpd on
  1. 建立/etc/httpd.conf文件的软链接,便于后期管理
ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf
  1. 修改配置文件httpd.conf
vim /etc/httpd.conf
Listen:IP             #监听IP地址,这里修改为自己的本地IP地址
ServerName:主机名.域名          #服务器名称
  1. 查询80端口,检查httpd服务是否已经启动
netstat -natp | grep 80

www站点目录为:/usr/local/apache/htdocs/

局域网中测试apache服务时请关闭防火墙

setenforce 0
service iptables stop

最终测试:

LAMP部署-- 一.编译安装Apache
至此,Apache服务已经部署完毕,请见下一章部署Mysql服务。

猜你喜欢

转载自blog.51cto.com/10316297/2114681