[LNMPA搭建四]Apache详细安装步骤

来源:互联网 发布:战地2 for mac 百度云 编辑:程序博客网 时间:2024/05/22 08:23

1.参考网址

主要参考网址:
http://blog.csdn.net/leshami/article/details/50144179

2.安装目录结构

这里写图片描述

3.准备工作

  1. 进入安装目录

    cd /data/soft/mkdir apache
  2. 下载依赖包:

    wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gzwget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
  3. 下载apache 源码包:

    wget http://archive.apache.org/dist/httpd/httpd-2.4.9.tar.gz

4.扩展库安装(2.4版本必须)

  1. apr扩展安装

    tar -xvf apr-1.5.2.tar.gzmkdir aprcd apr-1.5.2./configure --prefix=/data/soft/apache/aprmakemake install

    错误说明:(./configure)

    rm: cannot remove `libtoolT’: No such file or directory

    解决方案:

    编辑configure这个文件,将 RMcfgfile” 那行注释掉 ,然后重新编译即可。

  2. arp-util 扩展安装

    tar -xvf apr-util-1.5.4.tar.gz    mkdir apr-utilcd apr-util-1.5.4 ./configure --prefix=/data/soft/apache/apr-util  --with-apr=/data/soft/apache/aprmakemake install

5.Apache安装

tar -xvf httpd-2.4.9.tar.gzmkdir apache2.4cd httpd-2.4.9./configure --prefix=/data/soft/apache/apache2.4 --with-apr=/data/soft/apache/apr --with-apr-util=/data/soft/apache/apr-util --sysconfdir=/data/conf/apache --enable-so --enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork --with-z=/data/soft/nginx/zlib --with-pcre=/data/soft/nginx/pcre --enable-ssl --with-ssl=/data/soft/nginx/opensslmakemake install

以下为几个主要的配置项

--sysconfdir=/etc/httpd24  指定配置文件路径        --enable-so  启动模块动态装卸载        --enable-ssl 编译ssl模块 --with-ssl=/data/soft/nginx/openssl  指明的openssl安装目录目录        --enable-cgi 支持cgi机制(能够让静态web服务器能够解析动态请求的一个协议)        --enable-rewrite  支持url重写           --with-zlib  支持数据包压缩               --with-pcre=/data/soft/nginx/pcre        --with-apr=/data/soft/apache/apr 指明的apr安装目录目录        --with-apr-util=/data/soft/apache/apr-util  指明的apr-util安装目录        --enable-modules=most      启用的模块        --enable-mpms-shared=all   以共享方式编译的模块        --with-mpm=prefork         指明httpd的工作方式为prefork

可能出现的错误:

错误一:ARP not find 解决方案:执行第四步骤

这里写图片描述

错误二:undefined SSLv2_client_method
undefined SSLv3_client_method

解决方案:

yum install openssl-devel

配置改为如下:

./configure --prefix=/data/soft/apache/apache2.4 --with-apr=/data/soft/apache/apr --with-apr-util=/data/soft/apache/apr-util --sysconfdir=/data/conf/apache --enable-so --enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork --with-z=/data/soft/nginx/zlib --with-pcre=/data/soft/nginx/pcre --enable-ssl --with-ssl

这里写图片描述

6.配置启动脚本及更改端口

cp /data/soft/apache/apache2.4/bin/apachectl /etc/init.d/httpdcd /etc/init.d/vi httpd

在第一行#!/bin/sh下一行添加如下几行

## chkconfig: 2345 10 90# description: Activates/Deactivates Apache Web Server#

让Apache服务加入到开机启动指令管理的服务列表中

chkconfig --add httpd

设置成开机启动

 chkconfig httpd on vi /data/soft/apache/apache2.4/conf/httpd.conf

Listen 80 改为 Listen 8080
ServerName www.example.com 改为 ServerName localhost

 service httpd start

浏览器浏览 http://ip:8080/ 显示 It works! 表示安装成功
本人本篇的研究笔记资料:链接:http://pan.baidu.com/s/1bpvMsQN 密码:gfsu

1 0
原创粉丝点击