Build environment: Windows+vmware (Ubuntu) +apache2. (same IP, different domain name)
1: Install apache2 under the VMware Virtual machine Ubuntu (how to install Baidu can be found);
2:apache2 related configuration file under/etc/apache2
Apache2.conf is a global configuration file and a master profile
CONF.D General Configuration
Envvars Storing environment variables
httpd.conf User Configuration Files
Mods-available available modules that are installed
mods-enabled modules that are enabled
Ports.conf the port number of the HTTPD service
Sites-available Available Virtual hosts
Sites-enabled enabled Virtual hosts
3: About the virtual host, refer to http://baike.baidu.com/view/7383.htm?fr=ala0_1_1;
4: Start the configuration of the virtual machine: The default access path for Apache2 is/var/www, which you can see in the/etc/apache2/sites-available/000-default.conf file
ServerAdmin localhost
Documentroot/var/www
Sites-availeable is a Web site configuration file, Sites-enable is a link to sites-availeable (do not tube).
5: Create a new virtual file: Create a new two folder under the /var/www folder: A and B, create a new b.html in the new a.html,b under the A folder. As the service directory at the time of the visit.
6: First create two files in the/etc/apache2/sites-available folder test_a.conf and test_b.conf (see the file suffix in the/etc/apache2/apache2.conf configuration file Includeoptional mods-enabled/*.conf).
Enter sudo gedit/etc/apache2/sites-available/test_a.conf on the terminal (Ctrl+alt+t entry); Enter the edit file:
Refer to the contents of the 000-default.conf (modify the Red section after copying the content):
test_a.conf:
<virtualhost 192.168.238.2>
ServerAdmin ******@******
DocumentRoot /var/www/a
ServerName www.test_a.com
<directory/>
Options FollowSymLinks
AllowOverride All
</Directory>
<directory /var/www/a>
Options Indexes followsymlinks MultiViews
AllowOverride All
Order Allow,deny
Allow from all
</Directory>
scriptalias/cgi-bin//usr/lib/cgi-bin/
<directory "/usr/lib/cgi-bin" >
AllowOverride All
Options +execcgi-multiviews +symlinksifownermatch
Order Allow,deny
Allow from all
</Directory>
Errorlog ${apache_log_dir}/wperror.log
# Possible values Include:debug, info, notice, warn, error, crit,
# Alert, Emerg.
LogLevel warn
Customlog ${apache_log_dir}/access.log combined
alias/doc/"/usr/share/doc/"
<directory "/usr/share/doc/" >
Options Indexes multiviews FollowSymLinks
AllowOverride All
Order Deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0:: 1/128
</Directory>
</VirtualHost>
test_a.conf: Modify/var/www/a to/var/www/b, www.test_a.com to www.test_b.com.
DocumentRoot: to access the directory; ServerName: The domain name to access.
7: To here the configuration of the virtual host is complete, just mentioned that the sites-enable folder is a link to access sites-availeable, so just the new test_a.conf he test_b.comf the same establishment connection: /c7>
In terminal input: sudo a2ensite test_a.conf and sudo a2ensite test_b.conf. Enter the Sites-enable folder to see two more linked files.
8: Start the apache:sudo/etc/init.d/apache2 start,
We open the browser in Ubuntu virtual machine, enter 192.168.238.2, see if it can be opened (generally not, no IP address assigned);
Enter terminal, input sudo ifconfig eth0:1 192.168.238.2 ,
Launch Apache again, browser input 192.168.238.2, have it!!
Then enter the domain name try: www.test_a.com or www.test_b.com did not respond??
Modify the Hosts file: Terminal input sudo gedit/etc/hosts join
192.168.238.2 www.test_a.com
192.168.238.2 www.test_b.com
Access again in the browser: Www/test_a.com into our new/var/www/a folder, and the same www.test_b.com into the/var/www/b folder.
9: On the host (accessed in Windows):
(1): First in the cmd terminal input ping 192.168.238.2 try to spell through. (If you can ping the words, open the 192.168.238.2 in the browser in Windows and try to see what can be seen).
(2): Can not ping the words will be shut down Ubuntu firewall: in Ubuntu terminal input: sudo ufw disable (shut down the firewall) (Http://blog.sina.com.cn/s/blog_ 483e43060101p603.html).
Enter 192.168.238.2 again in the browser to see it!!!
(3): Domain access, you need to set up hosts to access new virtual hosts (www.test_a.com and www.test_b.com) through the domain name in Windows.
The location in Windows is C:\Windows\System32\drivers\etc folder under the manual open is not modifiable, the specific modification scheme is:
Find Notepad in Windows start, right-click---> Run as Administrator, select File in open Notepad, open, locate the Hosts file under the C:\Windows\System32\drivers\etc folder to open, Add two lines to it:
192.168.238.2 www.test_a.com
192.168.238.2 www.test_b.com Save!
Finally access the www.test_a.com in the browser, appear in Ubuntu browser to visit the www.test_a.com effect!!!!
To this virtual host configuration complete!!!
Resources:
http://xuchengji.blog.51cto.com/160472/387247;
Http://blog.sina.com.cn/s/blog_483e43060101p603.html.
Virtual host building (UBUNTU+APACHE2)