LAMP搭建2:Apache安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LAMP搭建2:Apache安装相关的知识,希望对你有一定的参考价值。

1.进入/usr/local/src/目录下去下载Apache的安装包httpd-2.2.29.tar.gz

[[email protected] support-files]# cd /usr/local/src

[[email protected] src]# ls

httpd-2.2.9.tar.gz

2.解压安装包

[[email protected] src]# tar zxvf httpd-2.2.9.tar.gz

3.进入安装目录

[[email protected] src]# cd httpd-2.2.9

[[email protected] httpd-2.2.9]# ls

ABOUT_APACHE      CHANGES        include         modules           srclib

acinclude.m4      config.layout  INSTALL         NOTICE            support

Apache.dsw        configure      InstallBin.dsp  NWGNUmakefile     test

apachenw.mcp.zip  configure.in   LAYOUT          os                VERSIONING

build             docs           libhttpd.dsp    README

BuildAll.dsp      emacs-style    LICENSE         README.platforms

BuildBin.dsp      httpd.dsp      Makefile.in     ROADMAP

buildconf         httpd.spec     Makefile.win    server

4.查看安装说明文件INSTALL可以看到安装步骤

……

$ ./configure --prefix=PREFIX

$ make

$ make install

$ PREFIX/bin/apachectl start

……

5.使用下面的参数配置安装选项,回车即可

[[email protected] httpd-2.2.9]# ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre

其中:

--prefix 指定安装目录

--with-include-apr 依赖包apr,支持httpd,可以跨平台运作

--with-pcre 正则相关的库

shared表示以动态共享的方式安装

有错改错,缺少什么库就安装:

如checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

yum install  zlib-devel

6.直到配置没有问题然后开始编译

[[email protected] httpd-2.2.9]# echo $?

0

[[email protected] httpd-2.2.9]# make

7.编译没问题然后开始安装

[[email protected] httpd-2.2.9]# echo $?

0

[[email protected] httpd-2.2.9]# make install

8.安装成功

[[email protected] httpd-2.2.9]# echo $?

0

[[email protected] httpd-2.2.9]# ls /usr/local/apache2/

bin    cgi-bin  error   icons    lib   man     modules

build  conf     htdocs  include  logs  manual

9.现在还不能直接运行,需要编辑Apache主配置文件httpd.conf:

[[email protected] httpd-2.2.9]# vim /usr/local/apache2/conf/httpd.conf

将ServerName改为localhost:80,去掉前面的注释符#

……

# ServerName gives the name and port that the server uses to identify itself.

# This can often be determined automatically, but we recommend you specify

# it explicitly to prevent problems during startup.

#

# If your host doesn‘t have a registered DNS name, enter its IP address here.

#

ServerName localhost:80

……

10.将Apache加入系统环境变量:

[[email protected] support-files]# vim /etc/profile.d/path.sh

#!/bin/bash

export PATH=$PATH:/etc/init.d/:/usr/local/mysql/bin/:/usr/local/apache2/bin/

[[email protected] support-files]# source /etc/profile.d/path.sh

11.检查配置是否正确,正确则启动Apache

[[email protected] httpd-2.2.9]# apachectl -t

Syntax OK

[[email protected] httpd-2.2.9]# apachectl start

httpd (pid 22581) already running

12.查看Apache的进程和端口

[[email protected] httpd-2.2.9]# ps aux|grep httpd

[[email protected] httpd-2.2.9]# netstat -lnp


以上是关于LAMP搭建2:Apache安装的主要内容,如果未能解决你的问题,请参考以下文章

LAMP搭建第一步:安装Apache

LAMP搭建 --mariadb安装和Apache安装

LAMP环境的搭建----Apache安装

Centos7.4源码搭建LAMP环境

搭建LMAP架构之 Apache配置(上篇)

web应用之LAMP源码环境部署