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

How to use bar charts in Vue and modify the configuration yourself

1. Import echart in HTML file <!-- Import echa...

Detailed explanation of the basic usage of the img image tag in HTML/XHTML

The image tag is used to display an image in a we...

JavaScript example code to determine whether a file exists

1. Business Scenario I have been doing developmen...

Perfect solution to Google Chrome autofill problem

In Google Chrome, after successful login, Google ...

Introduction to JavaScript built-in objects

Table of contents 1. Built-in objects 2. Math Obj...

Detailed explanation of the use of shared memory in nginx

In the nginx process model, tasks such as traffic...

mysql5.5 installation graphic tutorial under win7

MySQL installation is relatively simple, usually ...

How to create dynamic QML objects in JavaScript

1. Dynamically create objects There are two ways ...

React Class component life cycle and execution order

1. Two ways to define react components 1. Functio...

CentOS 7.x docker uses overlay2 storage method

Edit /etc/docker/daemon.json and add the followin...

JS ES new feature of variable decoupling assignment

Table of contents 1. Decoupled assignment of arra...

5 solutions to CSS box collapse

First, what is box collapse? Elements that should...