Centos7.9 source code compile and install Apache

Download the Apache source package

Download the source package: https://downloads.apache.org//httpd/httpd-2.4.46.tar.gz
Use FileZilla to upload httpd-2.4.46.tar.gz to CentOS server

Download and install dependencies

Dependent package: install gcc gcc-c++ zlib-devel openssl apr apr-util. If the prce
server can connect to the Internet, you can directly yum install. The above dependencies
I have 3 packages (apr apr-util) without yum source, so I download it manually Compile and install these three dependency packages.
Download link: wget http://archive.apache.org/dist/apr/apr-1.7.0.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.5.4. tar.gz
wget https://sourceforge.net/projects/pcre/files/pcre/8.43/pcre-8.43.tar.gz
Note: Do not use version 1.6 of apr-util, because there is no error when compiling Apache, but it is reported by make A bunch of undefined reference to `XML_xxxxxxxxxx' errors, the Internet says that the latest 1.6 version cannot be used, so I used the 1.5 version)
Use FileZilla to upload the above three tar packages to the CentOS server

Install dependencies and Apache server

tar -xvfz apr-1.7.0.tar.gz
tar -xvfz apr-util-1.5.4.tar.gz # 先 全部 解 压缩
tar -xvfz pcre-8.43.tar.gz
tar -xvfz httpd-2.4.46. tar.gz

cd apr-1.7.0 #First compile and install the apr dependency
package./configure --prefix=/usr/local/apr #Specify the installation path as /usr/local/apr
make
make install #If the installation is not reported, the error is specific. See what the error is and then solve it

cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr #Specify the installation path as /usr/local/apr-util and specify The path of apr
make
make install #Installation is fine if no error is reported, if there is an error, see what the error is and then solve

cd pcre-8.43
./configure --prefix=/usr/local/prce #Specify the installation path as /usr/local/prce
make && make install #If there is no error, you can solve it if there is an error.

Start to compile and install Apache
cd httpd-2.4.46
./configure --prefix=/usr/local/apache \ #Specify the Apache installation path as /usr/local/apache, and other functions that need to be enabled when written by yourself
–with-apr= /usr/local/apr
–with-apr-util=/usr/local/apr-util
–with-prce=/usr/local/prce

make
make install #The installation has no error, the installation is complete

Start the Apache service

Insert picture description here
Before starting, modify the configuration file
cd /usr/local/apache
vim conf/httpd.conf to
find #ServerName www.example.com:80 and remove the # sign.
Start to start the Apache service
cd bin/
./apachectl -k start
lsof -i:80 #Check whether the httpd service is started
http://192.168.43.120:80/ #Web page test to check whether the service is normal, it works! This means Apache is installed success.

Guess you like

Origin blog.csdn.net/MssGuo/article/details/115312244