A website must be stored on a computer that is always connected to the internet and runs web-server software. Web hosting provides this.
Web Servers
A web server is software, and the computer it runs on, that stores website files and sends them to browsers in response to HTTP requests. Popular web servers are Apache HTTP Server, Nginx, Microsoft IIS and LiteSpeed. A web server can also run server-side programs, such as PHP, Node.js or Python, to create pages on the fly, and work with a database such as MySQL.
Definition: Web hosting. A service that provides space on an internet-connected server, together with the software and connectivity needed, so that a website can be accessed by users on the web.
Setting Up Web Servers
On Windows, IIS can be turned on from "Windows Features", or a package such as XAMPP or WAMP installs Apache, MySQL and PHP together; files placed in htdocs are served at http://localhost. On Linux and UNIX, Apache is installed with the package manager, for example sudo apt install apache2, started with sudo systemctl start apache2, and serves files from /var/www/html; Nginx is installed and started in the same way. For a site to be reachable from the internet, the server needs a public IP address, a domain name pointing to it through DNS records, open firewall ports 80 and 443, and an SSL/TLS certificate for HTTPS, often free from Let's Encrypt.
Web Hosting Providers
A web hosting provider rents server space and connectivity, and usually provides a control panel such as cPanel, email accounts, databases, backups and support. Examples are Hostinger, GoDaddy, Bluehost and BigRock.
Types of Web Hosting
Shared hosting: many websites share one server and its resources; it is cheap and easy, but slow if neighbours are busy. VPS (Virtual Private Server) hosting: one server is divided into virtual machines, each with guaranteed resources and root access. Dedicated hosting: a whole physical server for one customer, giving full control and performance at high cost. Cloud hosting: the site runs on a network of virtual servers in the cloud, and resources grow or shrink with traffic, billed by use, as on AWS, Google Cloud and Azure. Managed hosting: the provider handles updates, security and backups, as with managed WordPress hosting. Static site hosting: platforms such as GitHub Pages, Netlify and Vercel serve plain HTML, CSS and JS files, often free. Colocation: the customer owns the server and rents space in a data centre.
Hosting in the Cloud
In cloud hosting, a website runs on virtual servers or services provided by a cloud platform. It offers scalability (resources follow traffic), high availability (if one server fails, another takes over), pay-as-you-go pricing and global content delivery networks. Static sites can be stored in object storage such as Amazon S3 and served worldwide through a CDN.
Table 2.6: Types of web hosting
| Type | Description | Suits |
|---|---|---|
| Shared | Many sites on one server | Small personal sites |
| VPS | Virtual share with set resources | Growing sites |
| Dedicated | Whole server for one customer | Large, busy sites |
| Cloud | Scalable virtual servers, pay per use | Variable traffic |
| Static hosting | Serves plain files, often free | Portfolios, docs |
Example 2.6: Choosing hosting
Problem: Choose a hosting type for (a) a student's portfolio of plain HTML pages, (b) a college website with modest traffic and a small database, (c) an online exam portal with heavy traffic only during exams.
Solution:
- Plain HTML pages suit free static hosting such as GitHub Pages.
- A modest dynamic site suits shared or VPS hosting.
- Traffic that rises sharply at exam time suits cloud hosting, which scales up and down.
Result: (a) static hosting, (b) shared or VPS, (c) cloud hosting.
const plans = [
{ type: "Shared", cost: 150, control: "low", scales: false },
{ type: "VPS", cost: 900, control: "root", scales: false },
{ type: "Cloud", cost: "per use", control: "full", scales: true },
];
for (const p of plans)
console.log(p.type.padEnd(7), "cost:", String(p.cost).padEnd(8),
"auto-scales:", p.scales);
Output
Shared cost: 150 auto-scales: false
VPS cost: 900 auto-scales: false
Cloud cost: per use auto-scales: true
Common mistakes
- Choosing dedicated hosting for a small site, which wastes money.
- Forgetting to set up HTTPS with a certificate.
- Thinking that a site on localhost can be seen by others on the internet.
Key takeaways
- A web server (Apache, Nginx, IIS) sends files in response to HTTP requests.
- XAMPP sets up a local server on Windows; Apache and Nginx run on Linux.
- Hosting types: shared, VPS, dedicated, cloud, managed, static and colocation.
- Cloud hosting scales with traffic and is billed by use.
Practice questions
- What is a web server?
- Distinguish shared and dedicated hosting.
- Give one advantage of cloud hosting.
Answers to the practice questions
- Software and the computer running it that stores web files and sends them to browsers on request.
- Shared hosting puts many sites on one server; dedicated hosting gives a whole server to one customer.
- It scales resources automatically with traffic (also high availability, pay per use).
Sources
- Official BCA syllabus Web Technologies, course code 25BCA402SEC02, Unit II
