Software Environment:
Install Ubuntu 16.04-server in 1.virtualbox
2.WINDOW7 under Installation Xshell5
When the above installation is good,
1. Set the VirtualBox network to bridge the NIC and start Ubuntu.
2. Use the Ifconfig command to view the IP for 192.168.1.104
3. Open Xshell and create a new connection. It is possible to connect to Ubuntu normally.
4. Then sudo apt-cache search apache2 to find out if there is an installation package,
5.sudo apt-get Install apache2 installation
6.apache2-v View version 2.4.18, run A2enmod rewrite to open the Apache rewrite module (a2dismod close rewrite module).
7. Use Curl-i 127.0.0.1 to respond to some header information
8. Open the browser in Windows, using 192.168.1.104 Access, will open the Apache2 Default Web site root directory/var/www/html index.html file, a brief introduction of Apache
9. Enter the/etc/apache2 directory, apache2.conf is the main configuration file, which includes the following files and directories
80. Sudo vim ports.conf, you can modify the Apache listening port, such as the change to 8080.
11. At the same time change the sites-enabled/000-default.conf in 80 to 8080
Service apache2 Restart restart Apache, Access 192.168.1.104:8080 in Windows Explorer, or you can open the index.html above.
13. Down to modify the site root directory. Restore the above modified port to 80. Create a folder in your home directory that you want to use as the root directory, for example:/home/jerry/php-test
14. Enter the sites-enabled directory, CP 000-default.conf php-test.conf, copy a configuration file and annotate the statements in 000-default.conf. sudo vim php-test.conf,. Modified to:
15. After saving php-test.conf and restarting Apache, cp/var/www/html/index.html/home/jerry/php-test/, Access 192.168.1.104 in Windows Explorer to open index.html page
16. Start setting up the virtual domain name, open the Windows Hosts file, add a line 192.168.1.104 www.test.cn save, Access www.test.cn prompt to reject the connection, ping in cmd www.test.cn Although the 192.168.1.104 can be parsed, the connection times out. Configure/etc/hosts in Ubuntu, add a line 127.0.0.1 www.test.cn, save, use Curl-i www.test.cn is accessible. But I do not know why the Windows with IP address can be accessed, using the virtual domain name but refused the request.
17. On-line search and repeated attempts, summed up: First shut down the virtual machine, the VirtualBox network connection is modified to a NAT connection. With the virtual machine open, Ifconfig discovers that the IP address becomes 10.0.2.15, this address is set by the virtual machine, even if the configuration/etc/network/interfaces is static ip,/etc/init.d/networking Restart Restart the network will not change the IP. And Xshell is unable to connect to Ubuntu.
18. You need to use the port forwarding feature provided by VirtualBox, which is only used in NAT mode. Shut down the virtual machine and configure
19. Modify the Windows hosts to change the 192.168.1.104 of the 16th setting to 127.0.0.1. Access www.test.cn after saving. You can open the index.html normally. First, www.test.cn resolves to the 127.0.0.1:80,virtualbox and forwards to the 80 port of the virtual machine, which is the Web site root directory. Xshell Connection address becomes 127.0.0.1:2222
20. Done
Apache2.4 changing the default root directory and configuring the virtual domain name