UbuntuApache Virtual Host Configuration

Source: Internet
Author: User
Unlike Apache in Windows, there is usually only one configuration file, namely httpd. conf. In the local environment, the configuration file of Apache in apt-getinstallxxxLinux is/etc/apache2/apache2.conf. Apache automatically reads the configuration information of this file at startup. Some other configuration files, such as httpd. conf, are included through the Include command. In apache2.

Unlike Apache in Windows, there is usually only one configuration file, namely httpd. conf.

The local environment uses apt-get install xxx

In Linux, the configuration file of Apache is/etc/apache2/apache2.conf. Apache automatically reads the configuration information of this file at startup. Some other configuration files, such as httpd. conf, are included through the Include command.

There is the sites-enabled directory in apache2.conf, and there is a sites-available directory under/etc/apache2. In fact, this is the real configuration file, the sites-enabled directory stores only symbolic links to the files here. You can use ls/etc/apache2/sites-enabled/to confirm it.

Therefore, if multiple virtual hosts are configured on apache and the configuration files of each virtual host are stored in sites-available, it is very convenient to disable and enable the Virtual Host: when a link is established under sites-enabled to a virtual host configuration file, it is enabled. To disable a virtual host, you only need to delete the corresponding link, you do not need to modify the configuration file.

1. sudo cp/etc/apache2/sites-avaliable/000-default.conf, named test. conf

2. modify the configuration file: test. conf.

# The ServerName directive sets the request scheme, hostname and port that

# The server uses to identify itself. This is used when creating

# Redirection URLs. In the context of virtual hosts, the ServerName

# Specifies what hostname must appear in the request's Host: header

# Match this virtual host. For the default virtual host (this file) this

# Value is not decisive as it is used as a last resort host regardless.

# However, you must set it for any further virtual host explicitly.

ServerName www.test.com

ServerAdmin webmaster @ localhost

DocumentRoot/var/www/html/test/

ErrorLog/var/www/html/test/error. log

CustomLog/var/www/html/test/access. log combined

Options FollowSymLinks

DirectoryIndex index. php index.html index.htm

AllowOverride All # note that the configuration in this place will affect the enabling of. htaccess in the local directory.

Order deny, allow

Allow from All

# Available loglevels: trace8,..., trace1, debug, info, notice, warn,

# Error, crit, alert, emerg.

# It is also possible to configure the loglevel for Particle

# Modules, e.g.

# LogLevel info ssl: warn

# For most configuration files from conf-available/, which are

# Enabled or disabled at a global level, it is possible

# Include a line for only one participant virtual host. For example

# Following line enables the CGI configuration for this host only

# After it has been globally disabled with "a2disconf ".

# Include conf-available/serve-cgi-bin.conf

  

3. Create a link file:

Sudo ln-s/etc/apache2/sites-available/test. conf/etc/apache2/sites-enabled/test. conf

Or: sudo a2ensite test. conf

4. Restart the apache server

Sudo/etc/init. d/apache2 restart

5. Modify hosts (/etc/hosts)

Add 127.0.0.1 www.test.com

Access is basically normal here!

Note: If you still need to support directory-level URL rewriting, continue:

1. Terminal Operation

Sudo a2enmod

The program prompts the name of the module that can be activated. Enter: rewrite

If rewrite already load is returned

2. Modify/etc/apache2/sites-enabled/test. conf (the link points to the site configuration file)
Change the AllowOverride attribute to All and save it. (We have configured All above)

3. Reload apache

Sudo/etc/init. d/apache2 restart

Ubuntu Server 14.04 Install Web Server (Linux + Apache + MySQL + PHP) http://www.linuxidc.com/Linux/2015-06/119061.htm

Install and configure the PHP environment (Apache2) http://www.linuxidc.com/Linux/2015-05/118062.htm in Linux

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

Apache details: Click here
Apache: Click here

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2016-01/127828.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.