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

The basic use of html includes links, style sheets, span and div, etc.

1. Links Hypertext links are very important in HTM...

A brief discussion on the use of React.FC and React.Component

Table of contents 1. React.FC<> 2. class xx...

Example of MySQL slow query

Introduction By enabling the slow query log, MySQ...

Analysis of implicit bug in concurrent replication of MySQL 5.7

Preface Most of our MySQL online environments use...

HTML 5 Reset Stylesheet

This CSS reset is modified based on Eric Meyers...

Do you know the weird things in Javascript?

Our veteran predecessors have written countless c...

Example of how to upload a Docker image to a private repository

The image can be easily pushed directly to the Do...

Detailed explanation of the function and usage of DOCTYPE declaration

1. Browser rendering mode and doctype Some web pa...

Linux /etc/network/interfaces configuration interface method

The /etc/network/interfaces file in Linux is used...

The linkage method between menu and tab of vue+iview

Vue+iview menu and tab linkage I am currently dev...