1. What is a web server?
A web server is essentially a software that responds to user requests by delivering files such as HTML, images, CSS, and JavaScript. These files are then visualized through a web browser and appear to us as a web page.2. How to request files from a web server
A web server delivers files requested by the user through a URL. A URL is structured as follows.Web Root Path
When running a server with Python, the directory from which the server is executed becomes the web root directory. Only files within subdirectories of this root can be requested. Files located above the root directory cannot be accessed through the web server—this restriction is in place for security reasons.
If the web server's root path were set to the actual root directory ("/") of the server, it could potentially expose all files on the system. Therefore, in a production environment, it's essential to configure the server to allow access only to appropriate directories.
Ports and URL Requests
The default port for the HTTP protocol is 80, and for HTTPS, it is 443.
If the port is not specified in a URL, the browser will use the default port based on the protocol.https://www.google.com
can omit the port.
If you're using a port other than 80 or 443, you must explicitly specify it in the URL.
3. Static Pages vs. Dynamic Pages
Static Page
-
Delivers unchanging resources such as HTML, images, CSS, and JavaScript
-
The web server (e.g., Apache, Nginx, http.server) responds directly
Dynamic Page
-
Renders different content depending on user input (e.g., message boards, search results)
-
Requires a Web Application Server (WAS)
-
Uses dynamic languages and frameworks such as PHP, JSP, Python Flask, Node.js, etc.
4. Web Server Architecture: 3-Tier Structure
A web server system is typically composed of the following three-tier structure:
-
Web Server
-
Handles static file delivery
-
Examples: Nginx, Apache, Python http.server
-
-
WAS (Web Application Server)
-
Handles dynamic request processing
-
Examples: Tomcat, Flask, Express, Spring Boot, etc.
-
-
Database (DB)
-
Stores data and processes queries
-
Examples: MySQL, PostgreSQL, MongoDB, etc.
dockerCMD
file is being executed in the background to run a pre-built web server (LAMP) inside a virtual machine (container).sudo docker ps -a
: Displays a list of all containers, regardless of whether they are currently running.sudo docker rm -f [ID/name]
: Forcefully stops and removes the specified container.Runs a new Docker container.
-p "1018:80"
: Connects port 1018 on the host machine to port 80 inside the container.
--name studentWeb
: Assigns the name studentWeb to the container.
-v ${PWD}/webApp:/app
: Maps the webApp
folder on your local machine to /app
inside the container.
→ Since Apache uses /app
as the web root, webApp
becomes the root directory of the website.
-v ${PWD}/mysql:/var/lib/mysql
: Maps your local mysql
folder to the container’s MySQL directory, so data persists on your machine.
mattrayner/lamp:latest-1604-php7
: The Docker image used (a pre-built server with Apache, PHP7, and MySQL).
webApp
), and access the site in your browser via port 1018.
댓글 없음:
댓글 쓰기