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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

4.1 配置

./configure \
--prefix=/usr/local/apache \
--enable-so \
--enable-rewrite \
--enable-mods-shared=most \
--with-mpm=worker \
--disable-cgid \
--disable-cgi

4.2 编译及安装

make && make install
  1. 过滤掉注释行(#)并复制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

最终测试:

技术分享图片
至此,Apache服务已经部署完毕,请见下一章部署Mysql服务。

以上是关于LAMP部署-- 一.编译安装Apache的主要内容,如果未能解决你的问题,请参考以下文章

LAMP部署-- 二.编译安装Mysql

LAMP架构部署-- 三.编译安装PHP

基于ansible部署lamp架构(源码安装)

LAMP环境部署:Apache源码安装+MySQL二进制安装+PHP源码安装+Nginx源码安装

Web服务器群集——源码部署搭建LAMP平台上线wordpress博客上线

CentOS6系统编译部署LAMP(Linux, Apache, MySQL, PHP)环境