Set Apache Virtual Host in Ubuntu14.04LTS

Source: Internet
Author: User
Tags website server
A vm is usually used to provide website services with multiple domain names on a single IP address. It is useful if someone wants to run multiple websites on a single IP address of a single VPS. In this tutorial, let me show you how to set up a VM on the Apache web server of Ubuntu14.04LTS. Note that this tutorial is only applicable to Ubuntu14.04 32-bit versions. I don't guarantee that it can also work in other lower Ubuntu versions or Ubuntu derivative versions (although the process may be similar ).

Virtual HostIt is often used to provide website services with multiple domain names on a single IP address. It is useful if someone wants to run multiple websites on a single IP address of a single VPS.

In this tutorial, let me show you how to set up a VM on the Apache web server of Ubuntu 14.04 LTS. Note that this tutorial is only applicable to Ubuntu14.04 32-bit versions.

I don't guarantee that it can also work in other lower Ubuntu versions or Ubuntu derivative versions (although the process may be similar ).

Solution

In this tutorial, I will use Ubuntu 14.04 32-bit LTS and build two test websites named"Unixmen1.localAndUnixmen2.local". My testing machines are192.168.1.250/24AndServer. unixmen. local. You can change the virtual domain name as needed.

Install Apache website Server

Before installing the apache server, update our Ubuntu Server:

  1. Sudo apt-get update

Then, run the following command to install the apache network server:

  1. Sudo apt-get install apache2

After installing the apache server, let's use this URLHttp: // ip address of your server/To test whether the website server works normally.

As you can see, the apache server is already working.

-------------------------------------- Split line --------------------------------------

Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04Http://www.linuxidc.com/Linux/2013-06/86250.htm

Compile and install LAMP (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm in CentOS 5.9

Source code construction of Web Server Architecture in RedHat 5.4 LAMP environment and application PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm

LAMP source environment to build WEB Server Linux + Apache + MySQL + PHP http://www.linuxidc.com/Linux/2013-05/84882.htm

Build http://www.linuxidc.com/Linux/2014-05/101087.htm in LAMP + Xcache Environment

-------------------------------------- Split line --------------------------------------

Set VM 1. create virtual directory

Now, let's continue to install the VM. As I mentioned earlier, I want to create two new virtual hosts named"Unixmen1.localAndUnixmen2.local".

Create a public folder to store the data of the two virtual hosts.

First, let's create a directory for the unixmen1.local site:

  1. Sudo mkdir-p/var/www/unixmen1.local/public_html

Next, create a directory for the for unixmen2.local site:

  1. Sudo mkdir-p/var/www/unixmen2.local/public_html
2. Set the owner and permissions

The preceding directory only has root permissions. We need to modify the ownership of these two directories to common users, not just root users.

  1. Sudo chown-R $ USER: $ USER/var/www/unixmen1.local/public_html/
  2. Sudo chown-R $ USER: $ USER/var/www/unixmen2.local/public_html/

"$ USERThe variable points to the current login user.

Set the read and write permissions to the root directory (/var/www) and its subdirectories of the apache Web page, so that everyone can read files from the directory.

  1. Sudo chmod-R 755/var/www/

In this way, we have created some folders to save network-related data and assign necessary permissions and users.

4. Create a sample page for the VM

Now, we add a sample page to the website. Step 1: Let's give the VMUnixmen1.localCreate an Example page.

Create an Example page for the unixmen1.local VM,

  1. Sudo vi/var/www/unixmen1.local/public_html/index.html

Add the following content:

  1. Www. unixmen1.local
  2. Welcome To Unixmen1.local website

Save and close the file.

Similarly, add the sample page to the second VM.

  1. Sudo vi/var/www/unixmen2.local/public_html/index.html

Add the following content:

  1. Www. unixmen2.local
  2. Welcome To Unixmen2.local website

Save and close the file.

For more details, refer to the highlights on the next page.: Http://www.linuxidc.com/Linux/2014-06/102871p2.htm

Related Article

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.