综合

LAMP服务器环境之编译(部分)安装

导读: 

安装环境

redhat5.8(2.6.18-194.el5.i386,_)

Apache-httpd 2.2.29

MysQl mysql-5.5.44二进制通用包

PHP php-5.4.43

pcre依赖包

xcache 2.0.1

安装顺序

apr-->apr-util-->httpd-->MySQl-->php-->xcache

1,编译安装httpd

安装httpd依赖环境:apr和par-util,首选需要安装

1.1安装apr

解压apr源码包,编译安装并指定安装路径

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

make &&make install

1.2安装apr-util,安装时需指定apr安装路径

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

make && make install

1.3安装httpd服务(首先需要解决pcre依赖)

1.3.1安装httpd,需指定apr和par-util安装路径

安装选项说明:

--enable-ssl 启用https支持

--enable-so 启用动态共享库支持

--enable-deflate 压缩传输支持

--enable-proxy-scgi fastcgi支持

--with-mpm=MPM 默认MPM类型

--enable-mpms-shared=all 编译mpm模块(all表示编译所有)

--sysconfdir=/etc/httpd 配置文件路径

...(详见,.configure --help)

./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-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

make &&make install

1.3.2 添加httpd可执行文件到环境变量,及其他相关

修改pid文件路径,编译安装后默认在编译目录./logs下

vi /etc/httpd/httpd.conf

在任意位置添加PidFile "/var/run/httpd.pid"



提供SysV服务脚本

vi /etc/rc.d/init.d/httpd


#!/bin/bash

#

# httpd Startup script for the Apache HTTP Server

#

# chkconfig: - 85 15

# description: Apache is a World Wide Web server. It is used to serve \

# HTML files and CGI.

# processname: httpd

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

# config: /etc/sysconfig/httpd

# pidfile: /var/run/httpd.pid

# Source function library.

. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then

. /etc/sysconfig/httpd

fi

# Start httpd in the C locale by default.

HTTPD_LANG=${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

httpd=${HTTPD-/usr/local/apache/bin/httpd}

prog=httpd

pidfile=${PIDFILE-/var/run/httpd.pid}

lockfile=${LOCKFILE-/var/lock/subsys/httpd}

RETVAL=0

start() {

echo -n $"Starting $prog: "

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

RETVAL=$?

echo

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

return $RETVAL

}

stop() {

echo -n $"Stopping $prog: "

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

RETVAL=$?

echo

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

}

reload() {

echo -n $"Reloading $prog: "

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

RETVAL=$?

echo $"not reloading due to configuration syntax error"

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

else

killproc -p ${pidfile} $httpd -HUP

RETVAL=$?

fi

echo

}

# See how we were called.

case "$1" in

start)

start

;;

stop)

stop

;;

status)

status -p ${pidfile} $httpd

RETVAL=$?

;;

restart)

stop

start

;;

condrestart)

if [ -f ${pidfile} ] ; then

stop

start

fi

;;

reload)

reload

;;

graceful|help|configtest|fullstatus)

$apachectl [email protected]

RETVAL=$?

;;

*)

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

exit 1

esac

exit $RETVAL


为此脚本赋予执行权限:

chmod +x /etc/rc.d/init.d/httpd

加入服务列表:

chkconfig --add httpd


修改环境变量

vi /etc/profile.d/httpd.sh

添加如下内容,不需要给予该文件其他权限

export PATH=$PATH:/usr/local/apache/bin


测试httpd服务(需关闭iptables和SELinux)

启动httpd服务

service httpd start

相关资讯

发表评论
网友评论0 条评论)
暂无评论