Lamp-apache Compiling and installing

Source: Internet
Author: User
Tags install openssl

Apache Compiling installation Notes

System environment: Centos6.6 64-bit

Apache version 2.4.23

Download Apache file Http://httpd.apache.org/download.cgi#apache24


First, the preparatory work:

Install dependent components Pcre and Openssl-devel first

Yum-y Install Pcre-devel

Yum-y Install Openssl-devel


Download, install APR and Apr-util components

apr:http://apr.apache.org/download.cgi

1. Install 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. Installing 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



Second, installation 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

Installation is complete!


# Detailed compilation parameters

--prefix: #安装路径

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

--enable-so: #DSO兼容, Dso=dynamic shared object, dynamically sharing objects, enabling module dynamics to take effect

--enable-ssl: #支持SSL/tls to enable HTTPS access

--ENABLE-CGI: #支持CGI脚本 (default on non-threaded MPM mode)

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

--enable-deflate: #支持压缩

--with-z: #使用指定的zlib库, do not specify path will automatically find

--with-pcre: #使用指定的PCRE库, do not specify path will automatically find

--WITH-APR: #指定apr安装路径

--with-apr-util: #指定apr-util Installation path

--enable-modules: #支持动态启用的模块, optional parameters are "all", "most", "few", "Reallyall"

--enable-mpms-shared: #支持动态加载的MPM模块, optional "all"

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

HTTPD's mpm are: prefork,worker,event

httpd2.4 the default MPM for the compiled installation is: Event



Third, need to configure before enabling:

Must be closed before starting httpd: SELinux

Use: Getenforce View status

Enforcing

Use: Setenforce 0 off

Keep the status permissive: [[email protected] httpd-2.4.23]# Getenforce

Permissive

Using Vim/etc/selinux/config

Will Selinux=permissive


Add host Name:

Add in config file:/etc/httpd/httpd.conf

ServerName localhost:80

Under the/usr/local/apache/directory, start with Bin/apachectl start

Turn off the firewall: service iptables stort can be accessed.



To change the PID file directory:

Modify Vim/etc/httpd/httpd.conf

Add: #PidFile "/var/run/httpd.pid" First use the # Comment this command

Use [email protected] apache]# Bin/apachectl stop #关闭apachectl

Use: [[email protected] apache]# NETSTAT-TNLP #验证80端口是否关闭

After successful shutdown, enter vim/etc/httpd/httpd.conf to enable the previously commented command

See if the ls/var/run/folder has a httpd.pid file



Start, stop setting:

Create Edit file: vim/etc/init.d/httpd

Write content:

#/etc/init.d/httpd file


#!/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: $network $named $local _fs $remote _fs

# 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文档 (config file)

. /ETC/SYSCONFIG/HTTPD #读到该目录下

Fi


# Start httpd in the C locale by default.

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


# This would 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 this some modules may not

# work correctly with a thread-based MPM; Notably PHP would 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文件路径, which is the path defined in the previous step

LOCKFILE=${LOCKFILE-/VAR/LOCK/SUBSYS/HTTPD} #锁文件

Retval=0

STOP_TIMEOUT=${STOP_TIMEOUT-10}


# The semantics of these-functions differ from the the-the-same apachectl does

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

# When isn't running is also a failure. So we just do it the the-the-scripts

# is 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 ten 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 "$" 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



Add execute permission to the file: chmod +x/etc/init.d/httpd

Use command: Service httpd restart can be restarted



Boot auto Start:

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

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

Chkconfig--httpd on #更改状态


Enable the httpd command:

New file: vim/etc/profile.d/httpd.sh

Write content: Export path= $PATH:/usr/local/apache/bin

Using command validation: Echo $PATH



To change the MPM module:

Editor: vim/etc/httpd/httpd.conf

The default is to use the event module: LoadModule mpm_event_module modules/mod_mpm_event.so

Using Httpd-m #查看默认使用的模块


Open/etc/httpd/extra/httpd-mpm.conf Configurable MPM


This article is from the "CENTOS6 use Xtrabackup" blog, be sure to keep this source http://9052426.blog.51cto.com/9042426/1877809

Lamp-apache Compiling and installing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.