ApacheService Introduction and compilation and installation detailed
First,ApacheIntroduction
Apache HTTP Server (Apache), an open source Web server for the Apache Software Foundation, is currently the most widely used Web server in the world and is known for its cross-platform, efficient and stable Can run on almost any widely used computer platform. Apache is characterized by simple, fast, stable performance, and can be used as a proxy server.
Apache is developed in C language based on the modular design of the Web application, the overall appearance of the code is more readable than the PHP code, its core code is not many, most of the functions are divided into various modules, each module is loaded on demand when the system starts.
Supports SSL technology and supports multiple virtual hosts. Apache is a structure based on the prefork mode of the process (and also the thread-based worker pattern), which consumes more system overhead than threads, and is less suited to multiprocessor environments, so when an Apache web site is scaled up, Typically, you increase the server or expand the cluster nodes instead of increasing the processor.
Second,Apachethe characteristics
Apacheweb Server Software has the following features:
1. Support for the latest http/1.1 communication protocol
2. A simple and powerful file-based configuration process
3. Support for Universal Gateway Interface
4. Support IP-based and domain-based virtual hosts
5. Support HTTP authentication in multiple ways
6. Integrated Perl processing module
7. Integrated Proxy Server Module
8. Support real-time monitoring of server status and custom server logs
9. Support server-side include directive (SSI)
10. Support Secure Socket Layer (SSL)
11. Provide tracking of user session process
12. Support FastCGI
13. Javaservlets can be supported by a third-party module
third, compile and installApacheStep and parameter explanation
The compilation and installation of the source code generally consists of 3 steps:
Configuration (configure), typically dependent on the GCC compiler, BINUTILS,GLIBC. Configure software features, check the compilation environment, generate makefile files
Compile (make)
Install (make install)
Apr and apr-utils:http://apr.apache.org/download.cgi
pcre:http://sourceforge.net/projects/pcre/files/pcre/8.32/
[[Email protected] ~] #yum-y install gcc
[[Email protected] ~] wget http://archive.apache.org/dist/httpd/httpd-2.4.7.tar.gz
[email protected] ~]tar XF httpd-2.4. 7.tar.gz
[Email protected] ~]# CD httpd-2.4.7
[Email protected] httpd-2.4.7]#/configure \
>--prefix=/usr/local/apache \ Specify the installation directory
>--WITH-APR=/USR/LOCAL/APR \ Specify the installation directory for dependent files
>--with-apr-util=/usr/local/apr-util \ Specify the installation directory for dependent files
>--enable-deflate \ compress text files to increase speed and save bandwidth
>--enable-expires \ Let browser cache, reduce server pressure, improve access speed
>--enable-headers \ activating HTTP headers
>--enable-modules=most \ activates most modules
>--enable-so \ let Apache core load DSO, but do not actually compile any dynamic modules;
>--with-mpm=worker \ let Apache work in worker mode
>--enable-rewrite activating pseudo-static function
Checking for chosen layout ... Apache
Checking for working mkdir-p ... yes
Checking for grep that handles long lines and-e .../bin/grep
Checking for egrep .../bin/grep-e
Checking build system Type ... X86_64-unknown-linux-gnu
Checking host system Type ... X86_64-unknown-linux-gnu
Checking target system Type ... X86_64-unknown-linux-gnu
Configure
Configure:configuring Apache Portable Runtime Library ...
Configure
Checking for APR ... no
Configure:error:APR not found. Please read the documentation. There's an error here .
[[Email protected] ~]# tar XF apr-1.4.6.tar.gz Unzip and install the dependent package
[[Email protected] ~] #cd/apr-1.4.6
[Email protected] apr-1.4.6]#./configure
[[email protected] apr-1.4.6]# make && make install
[Email protected] apr-1.4.6]# CD.
[[Email protected] ~]# tar xf apr-util-1.4.1 Unzip and install Tool component dependency Package
[Email protected] ~]# CD apr-util-1.4.1
[Email protected] apr-util-1.4.1]#/configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr
[[email protected] apr-util-1.4.1]# make && make install
[[Email protected] ~]# tar XF pcre-8.34.tar.gz Unzip and install this regular expression library dependency package
[Email protected] ~]# CD pcre-8.34
[Email protected] pcre-8.34]#./configure
Checking for a bsd-compatible install .../usr/bin/install-c
Checking whether build environment is sane ... yes
Checking for a thread-safe mkdir-p .../bin/mkdir-p
..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ... .. ....... ..... omit several
Checking for dirent.h ... yes
Checking windows.h usability ... no
Checking Windows.h presence ... no
Checking for windows.h ... no
Configure:error:You Need a C + + compiler for C + + support. Error here need to install gcc-c++ software
[Email protected] pcre-8.34]# yum-y install gcc-c++
[Email protected] pcre-8.34]#./configure
[[email protected] pcre-8.34]# make && make install
... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ... .. ..... ..... omit several
LN-SF pcre_version.3/usr/local/share/man/man3/pcre32_version.3
MAKE[3]: Leaving directory '/root/pcre-8.34 '
MAKE[2]: Leaving directory '/root/pcre-8.34 '
make[1]: Leaving directory '/root/pcre-8.34 ' These proofs appear compile installation complete
[[Email protected] ~]# tar XF zlib-1.2.3.tar.gz Install dependent library file or yum install zlib zlib-devel
[Email protected] ~]# CD zlib-1.2.3
[Email protected] zlib-1.2.3]#./configure
Checking for GCC ...
Building Static Library libz.a version 1.2.3 with GCC.
Checking for Unistd.h ... Yes.
Checking whether to use vs[n]printf () or s[n]printf () ... using vs[n]printf ()
Checking for vsnprintf () in stdio.h ... Yes.
Checking for return value of vsnprintf () ... Yes.
Checking for errno.h ... Yes.
Checking for mmap support ... Yes.
[Email protected] zlib-1.2.3]# vim Makefile
Change the Cflags=-o3-duse_mmap of the 21st row to Cflags=-o3-duse_mmap-fpic
or use sed-i ' s/cflags=-o3-duse_mmap/cflags=-o3-duse_mmap-fpic/g ' Makefile
Note: If you do not modify the installation of HTTPD software, the following error will be reported:
Collect2:ld returned 1 exit status
Make[4]: * * * [mod_deflate.la] Error 1
MAKE[4]: Leaving directory '/root/httpd/httpd-2.4.7/modules/filters '
Make[3]: * * * [shared-build-recursive] Error 1
MAKE[3]: Leaving directory '/root/httpd/httpd-2.4.7/modules/filters '
make[2]: * * * [shared-build-recursive] Error 1
MAKE[2]: Leaving directory '/root/httpd/httpd-2.4.7/modules '
make[1]: * * * [shared-build-recursive] Error 1
MAKE[1]: Leaving directory '/root/httpd/httpd-2.4.7 '
Make : * * * [all-recursive] Error 1
[[email protected] zlib-1.2.3]# make && make install
[Email protected] zlib-1.2.3]# CD.
[email protected] ~]# CD httpd-2.4.7
[Email protected] httpd-2.4.7]#/configure--prefix=/usr/local/apache2--with-apr=/usr/local/apr--with-apr-util=/ Usr/local/apr-util--enable-deflate--enable-expires--enable-headers--enable-modules=most--enable-so--with-mpm= Worker--enable-rewrite
[[email protected] httpd-2.4.7] #make && make install
[[email protected] httpd-2.4.7]#/usr/local/apache2/bin/apachectl start Apache
By this point, Apache is already installed.
[[email protected] httpd-2.4.7]#/usr/local/apache2/bin/apachectl-l can view the installed modules
[[email protected] httpd-2.4.7]#/usr/local/apache2/bin/apachectl-t Check the configuration file syntax is incorrect
Iv. creation ofhttpdstart the script and set the boot1, copyApachethe boot file to/etc/init.dbelow and renamed
[email protected] ~]# cp/usr/local/apache2/bin/apachectl/etc/init.d/httpd
2, modifying the copied startup file
[email protected] ~]# vim/etc/init.d/httpd
#!/bin/bash Add two lines of text below this line
# chkconfig:35
# * refers to the 3 and 5 levels to open the service 70: Refers to the start-up service in 70-bit, 30 refers to the shutdown of the service in 30-bit, generally start the order of service and shutdown sequence and 100.
# Description:apache description information, here # no longer try the comment
3, set boot from start
[Email protected] ~]# chkconfig--add httpd
[Email protected] ~]# chmod +x/etc/init.d/httpd
[Email protected] ~]# chkconfig httpd on
[Email protected] ~]# systemctl restart httpd
Apache Service Introduction and compilation installation detailed