Configuration of the Ubuntu 12.04 virtual Host (1) Open etc/hosts file
Increase:
127.0.0.1 study.ubuntu.com
127.0.0.1 hello.ubuntu.com
127.0.0.1 test.ubuntu.com
(2) Establishment of three project catalogs
sudo mkdir-p/wwwroot/{study,hello,test}
Build a index.html in every project
(3) Configuring Apache virtual Host
To switch to the Apache configuration directory:
cd/etc/apache2/sites-available/
Copy three copies of configuration files:
sudo CP Default Study sudo CP Default Hello sudo CP Default test
To modify a configuration file:
Vim Hello
Content:
ServerName hello.ubuntu.com Add
Documentroot/wwwroot/hello modification
<Directory/wwwroot/hello/> modification
Startup configuration file:
[Email protected]:/etc/apache2/sites-available$ CD. /sites-enabled/[email protected]:/etc/apache2/sites-enabled$ llls: Initialization of month string error total usage8drwxr-xr-x2Root root40967? + -: A./drwxr-xr-x7Root root40967? + -: at.. /lrwxrwxrwx1Root root -7? + -: A the-default. /sites-available/Default[email protected]:/etc/apache2/sites-enabled$
You need to create three soft connections, respectively, pointing to the three configuration files that you just copied.
sudo Ln -S. /sites-available/Hello hellosudoln -S. /sites-available/test testsudoln -S: /sites-available/study Study
Restart Apache:sudo Service apache2 restart
You will then be able to access
Hello.ubuntu.com
Study.ubuntu.com
Test.ubuntu.com
Configuration of Ubuntu 12.04 virtual Hosting