LAMP-apache编译安装

apache编译安装笔记

系统环境:Centos6.6  64位

apache版本2.4.23

下载apache文件http://httpd.apache.org/download.cgi#apache24

一、准备工作:

先安装依赖组件pcre和openssl-devel

yum -y install pcre-devel

yum -y install openssl-devel

下载、安装apr和apr-util组件

apr下载地址:http://apr.apache.org/download.cgi

1.安装apr

tar xf apr-1.5.2.tar.bz2

cd  apr-1.5.2

./configure --prefix=/usr/local/apr   #指定安装路径为/usr/local/apr

make

make install

2.安装apr-util

tar xf apr-util-1.5.4.tar.bz2

cd apr-util-1.5.4

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

make

make install

#指定安装路径:--prefix=/usr/local/apr-util

#告知软件所依赖的apr的安装路径:--with-apr=/usr/local/apr

二、安装httpd

#tar xf httpd-2.4.23.tar.bz2

#cd httpd-2.4.23

#./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd  --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util  --with-mpm=event

#make

#make install

安装完成!

# 各编译参数详解

--prefix:#安装路径

--sysconfdir:#指定配置文件路径

--enable-so:#DSO兼容,DSO=Dynamic Shared Object,动态共享对象,可实现模块动态生效

--enable-ssl:#支持SSL/TLS,可以实现https访问

--enable-cgi:#支持CGI脚本(默认对非线程的MPM模式开启)

--enable-rewrite:#启用Rewrite功能

--enable-deflate:#支持压缩

--with-z:#使用指定的zlib库,不指定路径会自动寻找

--with-pcre:#使用指定的PCRE库,不指定路径会自动寻找

--with-apr:#指定apr安装路径

--with-apr-util:#指定apr-util安装路径

--enable-modules:#支持动态启用的模块,可选参数有“all”,“most”,“few”,“reallyall”

--enable-mpms-shared:#支持动态加载的MPM模块,可选“all”

--with-mpm:#设置默认启用的MPM模式

httpd的MPM有:prefork,worker,event

httpd2.4编译安装的默认MPM为:event

三、启用之前需要配置:

启动httpd之前必须先关闭:selinux

使用:getenforce 查看状态

Enforcing

使用:setenforce 0 关闭

保持状态为Permissive即可:[[email protected] httpd-2.4.23]# getenforce

Permissive

使用vim /etc/selinux/config

将  SELINUX=permissive

添加主机名称:

在配置文件:/etc/httpd/httpd.conf 里面添加

ServerName localhost:80

在/usr/local/apache/目录下,使用bin/apachectl start启动

关闭防火墙:service iptables stort  即可访问。

更改pid文件目录:

修改vim /etc/httpd/httpd.conf

添加:#PidFile "/var/run/httpd.pid"   先用#注释这条命令

使用[email protected] apache]# bin/apachectl stop   #关闭apachectl

使用:[[email protected] apache]# netstat -tnlp     #验证80端口是否关闭

成功关闭之后进入vim /etc/httpd/httpd.conf把之前注释的命令启用

查看ls /var/run/ 文件夹是否有httpd.pid文件

启动,停止设置:

创建编辑文件:vim /etc/init.d/httpd

写入内容:

#/etc/init.d/httpd  文件

#!/bin/bash

#

# httpd        Startup script for the Apache HTTP Server

#

# chkconfig: - 85 15

# description: The Apache HTTP Server is an efficient and extensible  \

#       server implementing the current HTTP standards.

# processname: httpd

# config: /etc/httpd/conf/httpd.conf

# config: /etc/sysconfig/httpd

# pidfile: /var/run/httpd/httpd.pid

#

### BEGIN INIT INFO

# Provides: httpd

# Required-Start: $local_fs $remote_fs $network $named

# Required-Stop: $local_fs $remote_fs $network

# Should-Start: distcache

# Short-Description: start and stop Apache HTTP Server

# Description: The Apache HTTP Server is an extensible server

#  implementing the current HTTP standards.

### END INIT INFO

# Source function library.

. /etc/rc.d/init.d/functions   #读取函数

if [ -f /etc/sysconfig/httpd ]; then   #判断该目录下如有httpd文档(配置文件)

. /etc/sysconfig/httpd          #读到该目录下

fi

# Start httpd in the C locale by default.

HTTPD_LANG=${HTTPD_LANG-"C"}   #如果该变量有值HTTPD_LANG就用原来的值,没有就用"C"的值

# This will prevent initlog from swallowing up a pass-phrase prompt if

# mod_ssl needs a pass-phrase from the user.

INITLOG_ARGS=""   #这个变量值为空

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server

# with the thread-based "worker" MPM; BE WARNED that some modules may not

# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.

apachectl=/usr/local/apache/bin/apachectl    #定义apachectl程序文件路径

httpd=${HTTPD-/usr/local/apache/bin/httpd}    #定义httpd程序文件路径

prog=httpd

pidfile=${PIDFILE-/var/run/httpd.pid}    #pid文件路径,也就是上一步定义的路径

lockfile=${LOCKFILE-/var/lock/subsys/httpd}   #锁文件

RETVAL=0

STOP_TIMEOUT=${STOP_TIMEOUT-10}

# The semantics of these two functions differ from the way apachectl does

# things -- attempting to start while running is a failure, and shutdown

# when not running is also a failure.  So we just do it the way init scripts

# are expected to behave here.

start() {

echo -n $"Starting $prog: "

LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS

RETVAL=$?

echo

[ $RETVAL = 0 ] && touch ${lockfile}

return $RETVAL

}

# When stopping httpd, a delay (of default 10 second) is required

# before SIGKILLing the httpd parent; this gives enough time for the

# httpd parent to SIGKILL any errant children.

stop() {

status -p ${pidfile} $httpd > /dev/null

if [[ $? = 0 ]]; then

echo -n $"Stopping $prog: "

killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd

else

echo -n $"Stopping $prog: "

success

fi

RETVAL=$?

echo

[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}

}

reload() {

echo -n $"Reloading $prog: "

if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then

RETVAL=6

echo $"not reloading due to configuration syntax error"

failure $"not reloading $httpd due to configuration syntax error"

else

# Force LSB behaviour from killproc

LSB=1 killproc -p ${pidfile} $httpd -HUP

RETVAL=$?

if [ $RETVAL -eq 7 ]; then

failure $"httpd shutdown"

fi

fi

echo

}

# See how we were called.

case "$1" in

start)

start

;;

stop)

stop

;;

status)

status -p ${pidfile} $httpd

RETVAL=$?

;;

restart)

stop

start

;;

condrestart|try-restart)

if status -p ${pidfile} $httpd >&/dev/null; then

stop

start

fi

;;

force-reload|reload)

reload

;;

graceful|help|configtest|fullstatus)

$apachectl [email protected]

RETVAL=$?

;;

*)

echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"

RETVAL=2

esac

exit $RETVAL

给该文件添加执行权限:chmod +x /etc/init.d/httpd

使用命令:service httpd restart  即可重启

开机自动启动:

chkconfig --add httpd   #加入服务列表

chkconfig --list httpd   #查看默认状态

chkconfig --httpd on     #更改状态

启用httpd自带命令:

新建文件: vim/etc/profile.d/httpd.sh

写入内容:export PATH=$PATH:/usr/local/apache/bin

使用命令验证:echo $PATH

更改MPM模块:

编辑:vim/etc/httpd/httpd.conf

默认使用的是event模块:LoadModule mpm_event_module modules/mod_mpm_event.so

使用httpd -M   #查看默认使用的模块

打开/etc/httpd/extra/httpd-mpm.conf可配置mpm

时间: 2024-10-19 00:24:50

LAMP-apache编译安装的相关文章

Linux lamp环境编译安装

1.安装准备: 1)httpd-2.0.52.tar.gz 2)mysql-4.1.12.tar.gz 3)libxml2-2.6.27.tar 4)freetype-2.1.10.tar 5)gd-2.0.33.tar 6)jpegsrc.v6b.tar 7)libpng-1.2.16.tar 8)zlib-1.2.3.tar 9)freetds-0.64.tar.gz 10)php-4.3.9.tar.gz 11)phpMyAdmin292.tar.gz 12)ZendOptimizer-3

Apache 编译安装2.2

一.Apache介绍 1.Apache是什么?   Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一.它快速.可靠并且可通过简单的API扩充,将Perl/Python等解释器编译到服务器中.同时Apache音译为阿帕奇,是北美印第安人的一个部落,叫阿帕奇族,在美国的西南部.Apache源于NCSA server服务. 1.1 Apache的应用场合   1>使用Apache运行静态HTM

apache编译安装

实验环境: centos6.3 2.6.32-431.20.3.el6.i686 用到的包: APR 1.5.1 APR-util 1.5.3 httpd-2.4.9 操作步骤: 第一步:根据依赖关系,先解压.编译安装apr1.5.1 # tar xf apr-1.5.1.tar.bz2 -C /home # cd /home/apr-1.5.1 # ./configure --prefix=/usr/local/apr # make && make install 第二步:解压.编译安装

LAMP环境编译安装

MySQL编译安装#安装编译代码需要的包yum -y install make gcc-c++ cmake bison-devel  ncurses-devel#mysql安装 wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.32.tar.gztar -zxvf mysql-5.6.32.tar.gzcd mysql-5.6.32cmake \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

LAMP--2.Apache 编译安装

apache 官网下载地址:http://www.apache.org/dyn/closer.cgi .建议使用国内开源镜像地址:http://mirrors.aliyun.com/apache/httpd/httpd-2.2.31.tar.bz2  或 http://mirrors.sohu.com/apache/httpd-2.2.31.tar.bz2 .所谓的apache,真正的名字是 httpd. 下载 [[email protected] ~]# cd /usr/local/src [

apache 编译安装与做nagios前端展示

apache编译安装篇 安装apache需安装以下的几个包,apr apr-util,pcre等,当然这几个包也可以使用由系统本身自带的包,但是这里我们编译安装这几个包. 2.下载安装apr, 把文件放到/usr/local/src目录下, tar -zxvf  apr-1.5.2.tar.gz cd  apr-1.5.2 ./configure --prefix=/usr/local/apr/ make make install 3.下载安装 apr-utils tar -zxvf apr-u

apache编译安装 httpd 2.2 httpd 2.4

#apache编译安装#httpd 2.2 , httpd 2.4 #!/bin/sh #apache编译安装 #httpd 2.2 , httpd 2.4 #centos #rpm -e httpd* Ve=2.2 [ $1 = 2.4 ] && Ve=2.4 || Ve=2.2 #设置安装版本2.2或2.4 #目录 Ddir=/it/tools #定义下载目录 Sdir=/www/server #定义安装目录 Adir=$Sdir/apache$Ve [ ! -d $Ddir ] &a

基于lamp环境编译安装zabbix

环境:lamp 系统:centos 6 前提:编译安装软件需要安装开发环境,关闭iptables和selinux # yum groupinstall "Development Tools"  "Server Platform Development" 一.编译安装httpd httpd2.4需要apr.apr-util依赖包 1.编译安装apr.apr-util # tar xf apr-1.5.0.tar.bz2  # cd apr-1.5.0 # ./conf

LAMP之编译安装

在linux中由于存在yum这种包管理方式,使得安装部署软件变得十分简单易用,但在某些特定情况下,由于有特殊需求,需要基于编译这种方式来定制化安装所需要的软件,以能特供自己所需的功能,此处我们来基于编译实现LAMP环境,来揭开编译安装这种听起来高大上的安装方式. 首先来交代一下实验环境 系统:CentOS 7.2 IP地址::172.16.38.100 httpd版本:httpd-2.4.10 php版本:php-5.4.40 mysql版本:mysql-5.5.33 一.编译安装httpd:

LAMP环境编译安装问题总结

apache: 问题: 安装apache的时候入到 error: mod_deflate has been requested but can not be built due to prerequisite failures的错误. 解决: 没有安装zlib包.运行命令: yum install zlib-devel PHP: 问题: 编译安装php出错mcrypt.h not found. Please reinstall libmcrypt yum install libmcrypt li