Objective 1. create an IP-based Vm for the overall test of a Project 2. create a user-based VM to test your code and start creating the VM directory structure sudo/home/wwwcd/home/wwwsudomkdir192.168.0.251191090.252cd192.168.0.251sudomkdircgi-binhtdocslogsd
Target
1.
Create an IP-based Vm for overall testing of a project
2.
Create a user-based Vm for testing your code
Start
Create the directory structure of the VM
Sudo/home/www
Cd/home/www
Sudo mkdir 192.168.0.20.192.168.0.252
Cd 192.168.0.133
Sudo mkdir cgi-bin htdocs logs db
Cd ../192.168.0.252
Sudo mkdir cgi-bin htdocs logs db
Tree/home/www
/Home/www
| -- 192.168.0.20.
| -- Cgi-bin
| -- Db
| -- Htdocs
| '-- Logs
'-- 192.168.0.252
| -- Cgi-bin
| -- Db
| -- Htdocs
'-- Logs
1.
To create two IP-based virtual hosts on 192.168.0.252 and 192.168.0.252, the directories 192.168.0.20.and 192.168.0.252 are created under/home/www respectively.
2.
The cgi-bin subdirectory is used to store CGI scripts.
3.
The database subdirectory is used to store the SQLite database.
4.
The htdocs subdirectory is used to store site documents.
5.
The logs subdirectory is used to store site logs.
Create a VM management account and Set Directory Permissions
Sudo useradd-g www-data-d/home/www/192.168.0.20.wuser1
Sudo useradd-g www-data-d/home/www/192.168.0.252 wuser2
Sudo passwd wuser1
Sudo passwd wuser2
Sudo chown-R wuser1.www-data/home/www/192.168.0.133
Sudo chown-R wuser2.www-data/home/www/192.168.0.252
1.
Assign the administrator of the 192.168.0.20.vm to wuser1, assign the administrator of the 192.168.0.252 VM to wuser2, and allow them to log on through ssh.
2.
The master groups of wuser1 and wuser2 are both set to www-data. The convenience of this setting is: if the site contains the Apache process writeable content, you only need to add the group writeable permission.
Configure Virtual Network Interface and host name resolution
Run the following command:
Sudo vim/etc/network/interfaces
Add the following configuration
Auto eth0: 1
Iface eth0: 1 inet static
Address 192.168.0.20.
Netmask 255.255.255.0
Network 192.168.0.0
Broadcast 192.168.0.255
Gateway 192.168.0.1
Auto eth0: 2
Iface eth0: 2 inet static
Address 192.168.0.252
Netmask 255.255.255.0
Network 192.168.0.0
Broadcast 192.168.0.255
Gateway 192.168.0.1
Run the following command to restart the network service:
Sudo/etc/init. d/networking restart
Add the following lines to the/etc/hosts file:
192.168.0.20.web1.example.com web1
192.168.0.252 web2.example.com web2
Configure Apache
S1. create a new file 192.168.0.20.in the/etc/apache2/sites-available/directory and add the following configuration
/Etc/apache2/sites-available/192.168.0.20.
DocumentRoot "/home/www/192.168.0.20./ htdocs /"
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
ScriptAlias/cgi-bin // home/www/192.168.0.133/cgi-bin/
AllowOverride None
Options + ExecCGI-MultiViews + SymLinksIfOwnerMatch
Order allow, deny
Allow from all
ErrorLog/home/www/192.168.0.20./ logs/error. log
CustomLog/home/www/192.168.0.20./ access. log combined