Compile and install Apache and publish multiple virtual hosts

Source: Internet
Author: User

You can customize software functions during compilation and installation, optimize compilation parameters, and improve performance.
Compiling and installing software in Linux is roughly divided into three steps:
1: configuration before Compilation
2: Compile
3. Installation
This time we used apache installation for the experiment. We first downloaded the software package to linux.
Download URL: http://www.apache.org/#search on the Internet: What I use here is
Httpd-2.2.17.tar.gz
Next let's start installing httpd-2.2.17.tar.gz
I will first create a directory under the root to store our Installation File/www
 
Decompress the httpd-2.2.17.tar.gz package to the/www directory.
 
Go to the/www directory and create an apache directory to store the apache installation file.
 
View the http-2.2.17 directory we can see the following file

Before compiling, check whether the gcc compiler is installed.
 
Prompt that the gcc package is not installed. We need to install gcc first.
Here we use the yum Method for installation, because there are too many dependencies in the rpm package.
For more information about yum configuration, see my other documents.

Then let's check if gcc is installed.

Next, let's prepare for the configuration.
[Root @ localhost httpd-2.2.17] #./configure -- prefix =/www/apache -- enable-so -- enable-rewrite
-- Prefix =/www/apache specifies the location where apache is installed.
-- Enable-so is a compilation dynamic loading module (DSO) that supports httpd binary files. This module enables the functional modules of Apache to be separately compiled from the core and dynamically loaded during runtime.
-- Enable-rewrite supports address rewriting. To use Version 1.0, change it to -- enable-module = rewrite.
Check if any error is prompted. If yes, the problem is solved,
For more options, see:
-- Enable-mod-shared = most tells the compiler to dynamically compile all standard modules into DSO modules.
-- Enable-module = most
Most can be used to compile modules that are not commonly used by default. most commonly used modules can be dynamically compiled.
-- Enable-mod-shared = all means to dynamically load all modules.
If not, then [root @ localhost httpd-2.2.17] # make
Check if any error is prompted. If yes, the problem is solved,
If not, then [root @ localhost httpd-2.2.17] # make install
(We can also [root @ localhost httpd-2.2.17] # make install)
After that, we can view the/www/apache directory to see that many files are generated.
 
Now let's start the apache service and test it.

After the apache service is successfully installed, we will release multiple websites in this linux system in three ways.
1: use multiple ports to publish multiple websites
2: Use multiple IP addresses to publish multiple websites
3: deploy multiple websites with different hosts
Now let's prepare a few simple web pages. We should note that the directory of the compiled and installed apache website should be placed in the apache installation directory htdocs. Otherwise, an error such as an error is prompted.
[Root @ localhost apache] # vim conf/httpd. conf is about 106 lines.

 
The corresponding log file directory and file will be used later.

The main configuration file of apache installed with the rpm package is apache/conf/httpd. conf under the installation home directory.
All configuration documents are available in the httpd. conf file, but the compilation and installation are different.
We need to check the configuration file [root @ localhost apache] # vim conf/httpd. conf
 
We need to remove the # Before # Include conf/extra/httpd-vhosts.conf, his virtual host we should
Installation Directory apache/conf/extra/httpd-vhosts.conf implementation in this configuration file
1: use multiple ports to publish multiple websites
The configuration file to be modified is as follows:
[Root @ localhost apache] # vim conf/httpd. conf
About 40 rows
About 389 rows
Then edit the [root @ localhost apache] # vim conf/extra/httpd-vhosts.conf
Modify the configuration file:

Then we restart the service.
[Root @ localhost apache] # bin/apachectl stop
[Root @ localhost apache] # bin/apachectl start
Test with a client:

 

2: Use multiple IP addresses to publish multiple websites
First, bind multiple IP addresses to a network card.
We can temporarily BIND:
Method 1: [root @ localhost ~] # Ifconfig eth0: 1 192.168.8.9 netmask 255.255.255.0 up
Restart the network service.
Method 2: If you want the bound IP address to take effect permanently, copy the eth0 configuration file.
[Root @ localhost ~] # Cp/etc/sysconfig/network-scripts/ifcfg-eth0/etc/sysconfig/network-scripts/ifcfg-eth0: 1
 
The configuration file to be modified is
 
 
 
This article is from the "Red Rooster" blog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.