Linux下Apache的装置与配置

发布时间:2019-08-23  栏目:LINUX  评论:0 Comments

Linux下Apache的安装与安排

本文安装的httpd版本为httpd 2.4.4
设置在此之前确认保障 Development Libraries与Development
tools安装上。安装情势参谋: 与

一、编写翻译安装
1、化解依赖关系

设置httpd 2.4.4时首先供给化解重视关系,httpd
2.4.4内需较新本子的apr和apr-util。升级情势有二种,一种是因而源代码编译安装,一种是平昔接升学级rpm包。本文选拔第一种方法来举行进级换代。在那边我们下载
apr-1.4.6.tar.bz2与apr-util-1.5.2.tar.bz2版本。为了现在不需求的忙绿,在此地鲜明要保障系统时间准确,不科学的(data自行修改)。
apr和apr-util的下载路线为:http://archive.apache.org/dist/apr/ 
(1)首先依据惯例剪切apr与apr-util到/usr/local/src下,然后开展解压操作
mv  apr-1.4.6.tar.bz2  /usr/local/src
mv  apr-util-1.5.2.tar.bz2  /usr/local/src
tar -xjvf apr-1.4.6.tar.bz2
tar -xjvf apr-util-1.5.2.tar.bz2
(2)编写翻译安装apr
cd apr-1.4.6
./configure –prefix=/usr/local/apr      #安装在/usr/local/下
命名为apr
make
manbet手机客户端3.0,make install
(3)编译安装apr-util
cd apr-util-1.5.2
 ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr
make
make install
(4)
httpd-2.4.4编写翻译进程也要借助于pcre-devel软件包,须求事先安装。此软件包系统光盘自带,因而,找到并安装就可以。
yum -y install pcre-devel
到此甘休基本上化解了依赖关系。
2、编写翻译安装httpd-2.4.4
下载httpd-2.4.4.tar.bz2下载地址为https://archive.apache.org/dist/httpd/
(1)首先依照惯例剪切httpd-2.4.4.tar.bz2到/usr/local/src下,然后举办解压操作
mv httpd-2.4.4.tar.bz2  /usr/local/src
tar -xjvf  httpd-2.4.4.tar.bz2
(2)编写翻译安装httpd
cd httpd-2.4.4
./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
解释:
–enable-so:协理动态共享模块,借使帮忙php将不能够与apache一同干活。必供给有
–enable-ssl:启用ssl效用,若是不启用将不可能选拔https
–enable-mpms-shared=all:prefork、worker、event
–with-mpm=event:event为默认
 –enable-rewrite:支持URL重写
–enable-cgi :支持cgi
–enable-cgid:httpd使用event或许worker得启用被线程格局访谈
–enable-modules=most :启用大非常多模块
–enable-mods-shared=most:启用大很多分享模块
(3)setenforce 0 关掉selinux。(不常关门)
世世代代关闭 vim /etc/selinux/config

二、后续操作
1、启动httpd
两种情势:第一种、/usr/local/apache/bin/apachectl start
其次种艺术:先修改http.pid文件地点张开配置文件扩展一行
vim /etc/httpd/httpd.conf    增加PidFile “/var/run/httpd.pid”

manbet手机客户端3.0 1

为了运转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
将上述代码参与到vim /etc/init.d/httpd中
而后为此脚本赋予推行权限:
 chmod +x /etc/rc.d/init.d/httpd
投入服务列表:
 chkconfig –add httpd
给3,5启动
chkconfig –level  3,5 httpd on
末尾加路径
将 export PATH=$PATH:/usr/local/apache/bin
vim /etc/profile.d/httpd.sh实现后再度登陆就能够了。推荐使用第三种办法

三、验证

manbet手机客户端3.0 2

安装成功!

Ubuntu Server 14.04
安装Web服务器(Linux+Apache+MySQL+PHP) 

Linux下安装配备PHP情状(Apache2) 

Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及安装

CentOS 5.9下编写翻译安装LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12)

RedHat 5.4下Web服务器架设之源码创设LAMP情形及使用PHPWind

Apache 的事无巨细介绍:请点这里
Apache 的下载地址:请点这里

正文恒久更新链接地址:

http://www.bkjia.com/Linux/1118957.htmlwww.bkjia.comtruehttp://www.bkjia.com/Linux/1118957.htmlTechArticleLinux下Apache的安装与配置
本文安装的httpd版本为httpd 2.4.4 安装在此以前确认保证 Development
Libraries与Development tools安装上。安装格局参考:与 一、编译…

留下评论

网站地图xml地图