What is Linux?
Linux is a free operating system. An operating system is the main program that runs a computer, like Windows on a laptop. Linux is popular for servers because it is stable, safe and free.
What is a web server in Linux?
It is a Linux computer running a web server program. The program waits for visitors and sends them your pages. The two most common programs are:
- Apache, called
apache2on Debian and Ubuntu, andhttpdon CentOS, AlmaLinux and similar. - Nginx, known for speed.
Many people build a "LAMP" set: Linux, Apache, MySQL and PHP.
Steps to install Apache on Ubuntu or Debian
- Connect to your server with SSH. SSH is a safe way to open a text window on your server from your computer.
- Update the package list:
sudo apt update
This fetches the latest list of software you can install.
- Install Apache:
sudo apt install apache2
This downloads and installs the web server.
- Check that it is running:
sudo systemctl status apache2
It should say active (running).
- Open your server's IP address in a browser. You should see a default welcome page.
On CentOS-style systems, use sudo dnf install httpd and sudo systemctl start httpd instead.
Where the files go
- On Debian and Ubuntu, site files go in
/var/www/html. - Apache settings are in
/etc/apache2. On CentOS-style systems they are in/etc/httpd.
Useful basics
- A firewall may block web traffic. Allow ports 80 and 443.
- Add an SSL certificate so your site uses https.
- Keep the system updated.
Warning: Do not edit settings files without a backup copy. A typo can stop the server from starting.
Quick recap
- A Linux web server is Linux plus a web server program like Apache or Nginx.
- Install with
aptordnfas root. - Site files live in
/var/www/htmlon Debian and Ubuntu. - Open ports 80 and 443 and add SSL.