Get the App
SLTechnology News&Howtos  ›  Servers  › 

Install apache2.4 using source package compilation

Shulou Source: shulou.com Published: 2022-06-02 14:21:48 09月11日 Update

I. Preface

In order to better understand and learn the compilation and installation of the Linux system package, I tried to compile and install apache. This paper records the process of compilation and installation and the corresponding errors and solutions, which can be read again later.

II. Environmental preparation

System version: CentOS Linux release 7.2.1511 (Core)

Kernel version: 3.10.0-327.el7.x86_64

Before compiling and installing, I also read a lot of materials on the Internet. Basically, all dependent packages need to be installed before compiling and installing. Use yum to install dependent packages such as:

Yum install-y gcc gcc++ zlib zlib-devel expat-devel pcre-devel

The above sections are some common dependent packages, expat-devel and pcre-devel are added after I reported an error during installation.

Then use the wget command to download the appropriate source code package to the specified directory:

Httpd: http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.29.tar.gz

Apr: http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gz

Apr-util: http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz

After the preparatory work is done, you can compile and install.

III. Compilation and installation

Before compiling and installing the source package of httpd, we have to compile and install the corresponding source packages of apr and apr-until.

1. Install apr

[root@localhost tmp] # tar xf apr-1.6.3.tar.gz

[root@localhost tmp] # cd apr-1.6.3

[root@localhost apr-1.6.3] #. / configure--prefix=/usr/local/apr

[root@localhost apr-1.6.3] # make&&make install

2. Install apr-util

[root@localhost tmp] # tar xf apr-util-1.6.1.tar.gz

[root@localhost tmp] # cd apr-util-1.6.1

[root@localhost apr-util-1.6.1] #. / configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr

[root@localhost apr-util-1.6.1] # make&&make install

3. Install httpd

[root@localhost tmp] # tar xf httpd-2.4.29.tar.gz

[root@localhost tmp] # cd httpd-2.4.29

[root@localhost httpd-2.4.29] #. / configure--prefix=/usr/local/apache--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util

[root@localhost httpd-2.4.29] # make&&make install

IV. Work after compilation and installation

1. Start Apache

[root@localhost~] # cd/usr/local/apache/bin/

[root@localhost bin] #. / apachectl start

If you want to run after the program is installed, you must make environment variables for the binary files in it, otherwise you can only execute it through the path, so that you have to type

A long part of the path, of course, can also use aliases, but compared with environment variables, environment variables are simple and straightforward. The system is established by the $PATH variable on the system.

The binary program path information in the system, and the binary execution file of the program compiled by ourselves is usually not in this variable. We can add it manually.

Use:

Echo 'export PATH=/usr/local/src/httpd/bin:$PATH' > / etc/profile.d/httpd.sh

In this way, you can directly use commands such as apachectl start | stop | status to manage httpd.

Apachectl start: test it by typing IP in your browser after startup

In addition to binaries, there are library files, because most applications rely on some shared files with the standard library.

Linux default to find the library file path: / lib64,/lib,/usr/lib64,/usr/lib

Edit / etc/ld.so.conf.d/httpd.conf to add a search path to this file

Write: / usr/local/httpd/lib64

Execute the ldconfig command to regenerate the library mapping

And header information to create symbolic links.

Ln-s / usr/local/httpd/include / usr/include/httpd

Ln-s / usr/local/httpd/include/* / usr/include/

There are also man documents, edit / etc/man.config, find MANPATH

MANPATH / usr/lcoal/httpd/man

Tags: Compile program variable file path binary environment system source code command information library file version process preparation work input simplicity simplicity two Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Redmi Microsoft Shulou Tech Info MySQL