2. Web server (technical explanation)
1.ASP
- Microsoft: the earliest popular in China
- Embedded VB script in HTML, ASP+COM
- In ASP development, basically a page has thousands of lines of business code, the page is messy, and the maintenance cost is very high.
2.PHP
- Development speed is fast, powerful, cross-platform, simple code
- Cannot carry a large amount of visits (high concurrency)
3.JSP/Servlet:
- B/S architecture introduced by sun
- Based on java language development
- Can bear the impact of high concurrency, high performance, and high availability
B/S: Browser and server
C/S: Client and server
2.1 Tomcat server
Since java technology is used here, Tomcat is used to explain
- Tomcat has advanced technology, stable performance, and is free
2.1.1 Install Tomcat
- Official website: http://tomcat.apache.org/
- After decompression is complete, enter the directory
- The temp folder is generally used for file upload and download temporarily stored files, such as: when uploading files, read large files through the io stream, and Tomcat will read and store the files into the hard disk (temp folder) without saving In this way, the java program can run to save memory space and avoid the problem of storing a large amount of information in the memory and causing insufficient memory.
- The work folder is a program that converts the written jsp file into a Servlet (java file)
2.1.2 Start Tomcat
Start the desktop program:
If it is a Windows operating system then
- startup.bat start
- shutdown.bat shutdown
If it is a linux system
- startup.sh start
- shutdown.sh shutdown
Open the browser access port: (default 8080), it must be accessed at startup to access
http://localhost:8080/
2.1.3 Configuration
Possible problems:
- Since the Tomcat server is written in java language, it needs to be run in the java environment
- Garbled problem: need to modify conf->server.xml (server core configuration file) in the configuration file
In the server.xml configuration file:
The default port number is 8080
If you want to modify the domain name (host name):
The default host name is: localhost == 127.0.0.1
Enter C:\Windows\System32\drivers\etc
Enter the hosts file operation:
At the same time, modify the server.xml under the conf file:
The default storage of website resource files is the webapps folder
Run Tomcat again and visit the browser: http://chenhui.com
The above operation of modifying the host name (domain name) is best not to use, because modifying the Windows operating system is risky, but it is also a relatively low-level principle. (Ali interview questions)
2.1.4 Interview questions
-
Enter a domain name and press Enter, how the website is accessed, for example: www.baidu.com
-
First check whether there is a mapping of this domain name in the local C:\Windows\System32\drivers\etc\hosts configuration file
- If so, directly return the corresponding ip address, and there is a web program we need to access, which can be accessed (that is, access to the local web program)
- If not, go to the DNS server to find it, if found, return to the browser client, if not found, return 404
To understand through the diagram:
2.1.5 Publish a website
Put your own website in the webapps folder specified by the web server (Tomcat), and you can access it by entering the address in the browser
- The structure of the website
-webapps:Tomcat服务器文件夹目录
-ROOT(Tomcat自带的默认的网址)
-chenhui:自己写的网址目录名
-WEB-INF(一般有以下构成)
-classes:java程序
-lib:web应用所依赖的jar包
-web.xml(web核心配置文件)
-index.html(假设默认首页)
-static(存放一些静态资源)
-css
-js
-img
....
...