apache2.4.27 Compiling and installing

Source: Internet
Author: User
Tags fully qualified domain name

#apache 2.4 Compile and install #

1th Step: Install the GCC compiler.

Yum install-y gcc gcc-c++ openssl-devel pcre pcre-devel

Description: Openssl-devel is to let Apache support SSL Secure Sockets feature.

Because the Rewirte rewrite feature requires pcre-devel support. So install Pcre and pcre-devel software.

PCRE (perl Compatible Regular Expressions) is a Perl library that includes a Perl-compatible regular expression library. Pcre to solve the problem of using regular expressions in the C language.


or download pcre, compile and install

Tar zxvf pcre-8.31.tar.gz

CD pcre-8.31

./configure && make && make install

Description: The default installation is in the/usr/local/directory.


2nd Step: Prepare the package.

Download the latest httpd, Apr, apr-util from http://httpd.apache.org, then unzip.

Tar zxvf apr-1.5.1.tar.gz

Tar zxvf apr-util-1.5.4.tar.gz

Tar zxvf httpd-2.4.27.tar.gz


Because now the newest httpd-2.4 all need Apr, apr-util.

Apr feature: (Apache portablerun-timelibraries,apache Portable runtime) for the purposes of the same name, the main application for the upper layer provides an underlying support interface library that can be used across multiple operating system platforms.

Method One: Insert method installation

Description: Insert method installation (i.e., embedded Apr package), compile and install Apr software while compiling httpd-2.4.7.

MV apr-1.5.1 HTTPD-2.4.27/SRCLIB/APR

MV apr-util-1.5.4 Httpd-2.4.27/srclib/apr-util

CD httpd-2.4.27

./configure--prefix=/usr/local/apache2--sysconfdir=/etc/apache2/conf/--with-inculded-apr--enable-so-- Enable-rewirte--enable-ssl--enable-cgi--enable-cgid--enable-modules=most--enable-mpms-shared=all



Method Two: Step by step Installation

There are three steps of a, B and C.

A. Compiling and installing APR

CD apr-1.5.1

./configure--PREFIX=/USR/LOCAL/APR

Make && make install


B. Compiling and installing Apr-util

apr-util-1.5.4

./configure--prefix=/usr/local/apr-util--WITH-APR=/USR/LOCAL/APR

Make && make install


C. Compiling and installing httpd

[Email protected] ~]# CD httpd-2.4.27

[Email protected] httpd-2.4.7]#/configure \

PREFIX=/USR/LOCAL/APACHE2 \

sysconfdir=/etc/apache2/conf \

ENABLE-SO \

Enable-rewirte \

ENABLE-SSL \

ENABLE-CGI \

Enable-cgid \

Enable-modules=most \

Enable-modules-shared=most \

Enable-mpms-shared=all \

WITH-APR=/USR/LOCAL/APR \

With-apr-util=/usr/local/apr-util


--prefix=/usr/local/apache2: Specify the installation destination path

--sysconfdir=/etc/apache2/conf: Specify the configuration file installation location

--ENABLE-SO: Support dynamic sharing module, if not this module PHP will not work with Apache combined

--enable-rewirte: Support URL rewriting

--ENABLE-SSL: Enable SSL support

--ENABLE-CGI: Enable CGI support

--enable-cgid: Enable CGI scripts that support linear graphics MPMs

--enable-modules=most: Install most modules

--enable-modules-shared=most: Install most shared modules

--enable-mpms-shared=all: Supports all multi-channel processing methods

--WITH-APR=/USR/LOCAL/APR: Specify Apr path

--with-apr-util=/usr/local/apr-util: Specify Apr-util Path


After the configuration is complete, compile and install:

[[email protected] httpd-2.4.7]# make && make install


Compile the post-installation file structure:

1. Main configuration file:/etc/apache2/conf/httpd.conf

2. Command and script directory:/usr/local/apache2/bin

3. Home page of the default website:/usr/local/apache2/htdocs/index.html

4. Web Edition Help manual:/usr/local/apache2/manual/index.html

5, man manual:/usr/local/apache2/man

6. Extension Function Profile directory: The configuration file in the/etc/apache2/conf/extra/directory is as follows

httpd-vhosts.conf Virtual Host configuration file

httpd-default.conf Default settings configuration file

httpd-userdir.conf User home Directory Home page feature profile (similar to QQ space)

httpd-mpm.conf Working mode configuration file (process mode, thread mode parameters)

httpd-manual.conf Help booklet configuration file

httpd-ssl.conf SSL Secure Sockets configuration file

httpd-languages.conf Language configuration file

httpd-autoindex.conf Auto-index configuration file


3rd Step: Modify the httpd.conf configuration file.

Note: You need to modify 2 places.

1. Modify/etc/hosts, add a line

127.0.0.1 Apserver www.example.com


2. Modify/etc/apache2/conf/httpd.conf to modify the following code

Owner of the User Apache//process (170 rows). Find this line and change the daemon to Apache.

Group Apache//process genus (171 rows). Find this line and change the daemon to Apache.

ServerName the domain name of the www.example.com:80//website (201 lines). Locate this row, and enable this row


Note: 1, apserver, www.example.com are host names.

2. If you do not enable ServerName this line, there will be a warning when you start the service, which may cause the Apache service not to start properly.


4th Step: Manually start the service:

Cd/usr/local/apache2/bin

Ls

./apachectl Start//Start Apache service, Apachectl is a script file

./apachectl Stop//Stop Apache Service

./APACHECTL Status//view Apache service status


Check process status: PS Aux|grep httpd

Cha Duankou Status: ss-atunlp|grep:80 or netstat-atunlp|grep:80 or lsof-i:80


5th Step: Configure the environment variables for Apache:

1. Edit the environment variable file.

Vi/etc/profile Add the following content

Path= "$PATH:/usr/local/apache2/bin"


2. Load the environment variable file.

Source/etc/profile


3. Start the service test manually:

Description: After you add a new PATH environment variable, you can run the script in any directory.

Cd

Apachectl stop

Apachectl start



6th step: Configure the Startup script: (preferred)

Method One: Set the boot startup (preferred) with the compiled and installed script file

1. Prepare the startup script file:

Cd/usr/local/apache2/bin

CP-PV Apachectl/etc/init.d/apache

Vi/etc/init.d/apache Modify the following content

#!/bin/sh//Find this row and add the next line of content

# Chkconfig:-85 15//Allow Chkconfig management

#上行的-Minus is the control of the default RunLevel (by default, 2 to), 85 is the serial number of the boot file name S85apache, and 15 is the serial number in the K15apache file name that is not started. Startup file path: Ls/etc/rc.d/rc3.d/s85apache.


2, set the boot to boot, and verify

chmod +x/etc/init.d/apache//Add x Executable permissions

Chkconfig Apache on//set to boot

Chkconfig Apache--list//View boot boot settings status

Service Apache stop//Stop Apache Services

Service Apache start//start Apache Services


Cha Duankou Status: netstat-atunlp|grep:80

Access to the local test site: Curl 127.0.0.1


3, (choose to do, not do) to the Apache-related files and directories to create soft links.

[Email protected] httpd-2.4.7]# cd/usr/sbin/

[Email protected] sbin]# ln-s/usr/local/apache2/bin/*.

Create a soft link for a log file

[Email protected] sbin]# ln-s/usr/local/apache2/logs/var/log/apache

Here, apache-2.4.27 compiles the installation and configures the experiment complete.


------------------------------------------------

Method Two: Configure the startup script:

[[email protected] httpd-2.4.7]# CP Build/rpm/httpd.init/etc/init.d/apache//Use init script to manage httpd

[Email protected] httpd-2.4.7]# Vim/etc/init.d/apache

HTTPD=${HTTPD-/USR/SBIN/HTTPD} modified to HTTPD=${HTTPD-/USR/LOCAL/APACHE2/BIN/HTTPD}

Pidfile=${pidfile-/var/run/${prog}.pid} modified to Pidfile=${pidfile-/usr/local/apache2/logs/${prog}.pid}

Lockfile=${lockfile-/var/lock/subsys/${prog}}

Retval=0

# Check for 1.3 configuration

Check13 () {

Conffile=/etc/apache2/conf/httpd.conf modified into conffile=/etc/apache2/conf/httpd.conf

[[email protected] httpd-2.4.7]# chmod 755/etc/init.d/apache//Increase execution rights

[[email protected] httpd-2.4.7]# chkconfig Apache on//Set Apache to service boot

[[email protected] httpd-2.4.7]# chkconfig Apache--list//view Apache boot settings status

[Email protected] httpd-2.4.7]# cd/usr/sbin/

[Email protected] sbin]# ln-s/usr/local/apache2/bin/*.

Create a soft link for a log file

[Email protected] sbin]# ln-s/usr/local/apache2/logs/var/log/apache


If you start httpd, it appears.


Starting Httpd:AH00557:httpd:apr_sockaddr_info_get () failed for Apserver

AH00558:httpd:Could not reliably determine the server ' s fully qualified domain name, using 127.0.0.1. Set the ' ServerName ' directive globally to suppress this message

[OK]


You will need to modify 2 places:


1. Modify/etc/hosts, add a line

127.0.0.1 Apserver


2. Modify/etc/apache2/conf/httpd.conf, add a line at the end

ServerName Apserver


Note: Apserver is the machine name

""


apache2.4.27 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.