Centos7 install apache server

Official website address: http://httpd.apache.org/ , take version 2.4.43 as an example

Click Download to enter the relevant Download page

Here's another way to download: wget Download

First we download dependency

yum groupinstall "Development Tools" -y
yum install libtool -y
yum install expat-devel pcre pcre-devel openssl-devel -y

openssl is the cornerstone of web security communication. Without openssl, our information is running naked

Run the following command to download and extract the source packages of Apache, Apr and Apr util
The source package version will continue to be upgraded. You can view the available source package versions from the httpd source installation package and apr source installation package pages, and replace the source package version in the command with the version to be installed.

wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.43.tar.gz
wget https://mirrors.aliyun.com/apache/apr/apr-1.6.5.tar.gz
wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz

Extract them to usr/local/src directory

tar xvf httpd-2.4.43.tar.gz -C /usr/local/src
tar xvf apr-1.6.5.tar.gz -C /usr/local/src
tar xvf apr-util-1.6.1.tar.gz -C /usr/local/src

Run the following command to move the folder of Apr and Apr util to the srclib folder of Apache

cd /usr/local/src
mv apr-1.6.5 httpd-2.4.43/srclib/apr
mv apr-util-1.6.1 httpd-2.4.43/srclib/apr-util

Run the following command in turn to compile the source code

cd /usr/local/src/httpd-2.4.43
./buildconf
./configure --prefix=/usr/local/apache2 \
--enable-ssl \
--enable-so \
--with-mpm=event \
--with-included-apr \
--enable-cgi \
--enable-rewrite \
--enable-mods-shared=most \
--enable-mpms-shared=all
make && make install

Run the following command in turn to set the PATH environment variable

echo "export PATH=$PATH:/usr/local/apache2/bin" > /etc/profile.d/httpd.sh
source /etc/profile.d/httpd.sh

Run httpd -v to see the version number of Apache

Server version: Apache/2.4.43 (Unix)
Server built: Jun 11 2020 14:45:40

Add Apache startup profile
1 run vi /usr/lib/systemd/system/httpd.service Command to open Apache's startup configuration file
2 press the i key and write the following in the configuration file

[Unit] 
Description=The Apache HTTP Server 
After=network.target 

[Service] 
Type=forking 
ExecStart=/usr/local/apache2/bin/apachectl -k start 
ExecReload=/usr/local/apache2/bin/apachectl -k graceful 
ExecStop=/usr/local/apache2/bin/apachectl -k graceful-stop 
PIDFile=/usr/local/apache2/logs/httpd.pid 
PrivateTmp=false

[Install] 
WantedBy=multi-user.target

3 press Esc, then enter: wq and enter to save and close the Apache startup profile

Run the following command to start the Apache service and set the service to start automatically

systemctl start httpd
systemctl enable httpd

The default listening port of httpd is 80. Enter netstat - lntp to check whether the startup is successful


Browser input address

Description installation successful

Tags: Apache yum OpenSSL SSL

Posted on Thu, 11 Jun 2020 04:18:17 -0400 by knight