Apache Web Server

The Apache Web Server (Apache HTTP Server) is an open-source, cross-platform web server software developed and maintained by the Apache Software Foundation. Renowned for its stability, security, and high scalability, it supports a wide range of features through its extensive modules. As one of the most widely used web servers globally, it is commonly employed in scenarios such as website hosting, dynamic application support, and reverse proxy services.

This document provides instructions on how to install and run the Apache Web Server on Debian/Linux.

Preparation

  1. Confirm the device environment.
    • The device is now able to connect to the network normally.
    • The Windows host and the device are within the same local area network.
  2. Check network connectivity.
    • Execute ping www.baidu.com on the terminal. If you can see response time information, it indicates that the network is normal.

Install Apache Web Service

Apache is one of the most commonly used web server programs, which is used to provide website access services.

  1. Update the software repository:
sudo apt update
  1. Install the Apache service:
sudo apt install apache2 -y

Start and Configure Auto-Start

  1. Start the Apache service:
sudo systemctl start apache2

Start the Web service to make it run immediately.

  1. Set Apache to start automatically on boot:
sudo systemctl enable apache2

After this configuration, Apache will automatically start every time the system boots.

  1. Check the running status:
sudo systemctl status apache2

Check Device IP Address

sudo ifconfig

Test Whether Apache Has Been Installed Successfully

  1. Access through the computer browser within the same network:
http://Your device's IP address

If everything is normal, you will see the default page of Apache.

Change Default Web Page

Apache’s default web page is an HTML file located at /var/www/html/index.html.

Navigate to the directory and view its contents:

cd /var/www/html
ls -al

The following content will be displayed:

total 20
drwxr-xr-x 2 root root  4096 Oct 30 07:53 .
drwxr-xr-x 3 root root  4096 Oct 30 06:51 ..
-rw-r--r-- 1 root root 10703 Oct 30 06:51 index.html

By default, the index.html file in the /var/www/html directory is owned by theroot user. Since regular users do not have permission to directly modify files owned by root, you must change the file ownership to your own username if you wish to edit the webpage:

sudo chown <username>: index.html

Now you can edit the file. After making changes, simply refresh your browser to view the updated webpage.

If you are familiar with HTML, you can also place your own HTML files and other resources in this directory and access them as a website via the local network.