于一 发表于 2018-11-17 12:29:15

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

LAMP组件介绍


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

一、Apache安装


[*]解压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

[*]进入软件包目录,复制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

[*]安装 gcc 、 gcc-c++、 make、 pcre、pcre-devel 四个包  

yum install gcc gcc-c++ make pcre pcre-devel -y
[*]进入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  


[*]过滤掉注释行(#)并复制httpd服务文件至/etc/init.d/
  

grep -v "#" /usr/local/apache/bin/apachectl > /etc/init.d/httpd  


[*]编辑httpd文件
  

vi /etc/init.d/httpd   

  #在文件最前面插入下面的行
  #!/bin/sh
  #chkconfig:2345 85 15
  #description:Apache is a World Wide Web server.



[*]给httpd文件添加执行权限
  

chmod +x /etc/init.d/httpd  


[*]添加httpd服务,并设置为init3、init5时开机自启动
  

chkconfig --add httpd  
chkconfig --level 35 httpd on
  


[*]建立/etc/httpd.conf文件的软链接,便于后期管理
  

ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf  


[*]修改配置文件httpd.conf
  

vim /etc/httpd.conf  

  Listen:IP             #监听IP地址,这里修改为自己的本地IP地址
  ServerName:主机名.域名          #服务器名称



[*]查询80端口,检查httpd服务是否已经启动
  

netstat -natp | grep 80  


  www站点目录为:/usr/local/apache/htdocs/
  局域网中测试apache服务时请关闭防火墙
  

setenforce 0  
service iptables stop
  

最终测试:

  至此,Apache服务已经部署完毕,请见下一章部署Mysql服务。


页: [1]
查看完整版本: LAMP架构部署-- 一.编译安装Apache