Detailed tutorial on Apache source code installation and virtual host configuration

Detailed tutorial on Apache source code installation and virtual host configuration

Install Apache from source

1. Upload the Apache source code to install the required software packages

insert image description here

2. Installation:

Installation Order
apr—>apr-util—>pcre—>httpd
Install the compilation environment

yum -y install gcc gcc-c++

apr compilation and installation

tar xzf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apr
make && make install

Compile and install apr-util

tar xzf apr-util-1.5.1.tar.gz
cd apr-util-1.5.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
make && make install

pcre compilation and installation

tar xzf pcre-8.32.tar.gz
cd pcre-8.32
./configure --prefix=/usr/local/pcre
make && make install

httpd compilation and installation

tar zxf httpd-2.4.41.tar.gz 
cd httpd-2.4.41
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/ --enable-so --with-mpm=prefork
make && make install

Configure IP-based virtual hosts to add IP to the host

Temporary addition (restart network card invalid)
[root@localhost ~]# ifconfig eth0:0 192.168.153.155
[root@localhost ~]# ifconfig eth0:1 192.168.153.156
View the effect

insert image description here

Permanently add a copy of the network card configuration file and edit it

insert image description here
insert image description here

Restart the network card to view the results

insert image description here

Create two virtual hosts' website root directories and test pages
[root@localhost ~]# mkdir /opt/1806A
[root@localhost ~]# mkdir /opt/1806B
[root@localhost ~]# echo "1806A" > /opt/1806A/index.html
[root@localhost ~]# echo “1806B” > /opt/1806B/index.html

Modify the main Apache configuration file

Location: /usr/local/apache/conf/httpd.conf

insert image description here

Authorize the two website root directories of the virtual host

insert image description here

Otherwise, an access denied error will be reported with a status code of 403.

insert image description here

Uncomment the line containing the virtual host.

insert image description here

Edit the virtual host configuration file

Location: /usr/local/apache/conf/extra/httpd-vhosts.conf

insert image description here

Start Apache service

insert image description here

View the effect

insert image description here
insert image description here

This concludes this article on the detailed tutorial on Apache source code installation and virtual host configuration. For more relevant Apache virtual host configuration content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Apache virtual host configuration: Secondary directory access jumps to other root folders
  • Binding of one apache server IP (such as 127.0.0.1) and multiple domain names (virtual hosts)
  • How to configure Apache virtual host example summary
  • Detailed explanation of local Apache configuration of domain name-based virtual hosts
  • Apache source code installation detailed process record

<<:  MySQL Query Cache and Buffer Pool

>>:  Detailed explanation of HTML form elements (Part 2)

Recommend

Using HTML+CSS to track mouse movement

As users become more privacy-conscious and take m...

Vue realizes the function of book shopping cart

This article example shares the specific code of ...

How to implement form validation in Vue

1. Installation and use First, install it in your...

Detailed steps for installing Tomcat, MySQL and Redis with Docker

Table of contents Install Tomcat with Docker Use ...

Introduction to ApplicationHost.config (IIS storage configuration area file)

For a newly created website, take ASP.NET MVC5 as...

Detailed explanation of Vue Notepad example

This article example shares the specific code of ...

A brief introduction to the general process of web front-end web development

I see many novice students doing front-end develop...

Use of Linux usermod command

1. Command Introduction The usermod (user modify)...

MySql5.7.21 installation points record notes

The downloaded version is the Zip decompression v...

Sample code for implementing rolling updates of services using Docker Swarm

1. What is Docker Swarm? Docker Swarm is a cluste...

Use of Zabbix Api in Linux shell environment

You can call it directly in the Linux shell envir...

Introduction to network drivers for Linux devices

Wired network: Ethernet Wireless network: 4G, wif...

How to use the debouce anti-shake function in Vue

Table of contents 1. Anti-shake function 2. Use d...

MySQL SQL statement to find duplicate data based on one or more fields

SQL finds all duplicate records in a table 1. The...