Ubuntu Server 14.04 Apache2.4 Virtual Host configuration and module override configuration

Source: Internet
Author: User

Environment: Ubuntu Server 14.04 Apache2.4

1. Virtual Host Configuration

In apache2.4, the directory of the virtual host is /etc/apache2/sites-available configured through, by default, Apache has a default virtual host file called 000-default.conf. We will copy the contents of the 000-default.conf file into our new virtual host configuration file.

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/yiidemo.conf    

Edit the configuration file to point to the directory you just set.

sudo vim  /etc/apache2/sites-available/yiidemo.conf

The edited configuration is as follows (with additional comments removed):

 <directory/home/hehongwei/wwwroot> options Indexes followsymlinks allowoverride None require all granted</directory> <virtualhost *:80> ServerName Www.yiidemo.local serveradmin [email protected] documentroot/home/hehongwei/wwwroot ErrorLog ${apache_log_dir}/error.log CustomLog ${apache_log_dir}/access.log combined</VirtualHost>  

To restart the Apache server:

sudo service apache2 restart

After you modify the virtual host file, disable the default virtual host configuration (000.default.conf), and then enable the new virtual host configuration as shown below.

000-default.conf (**这一步不是必须的**)sudo a2ensite  yiidemo.conf

In this step, the yiidemo.conf configuration file is activated. His role is to produce a link /etc/apache2/sites-enabled/ to, why do it, because actually apache2 loads all the configuration files in that directory. a2dissiteand with a2ensite These two actions, we can better manage our virtual hosting.

Restart the APACHE2 server:

sudo service apache2 restart  

2. Load rewrite module [hide portal file]

sudo a2enmod rewrite//Open extension

And then modify something:

sudo vi/etc/apache2/sites-enabled/000-default

Modify all of the allowoverride None to allowoverride all.

Ubuntu Server 14.04 Apache2.4 Virtual Host configuration and module override configuration

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.