Apache Web Server

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

preparatory work

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

Install the 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 set up automatic startup

  1. Start the Apache service
sudo systemctl start apache2

Start the Web service to make it run immediately.

  1. Set to start automatically upon booting up
sudo systemctl enable apache2

The system will automatically start Apache when it boots up.

  1. Check the running status:
sudo systemctl status apache2

Check the 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 the default web page

The default web page is merely an HTML file on the file system, located at /var/www/html/index.html

Go to this table of contents and view the contents therein:

cd /var/www/html
ls -al

It will display:

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

The system has a default file named index.html in the directory /var/www/html. The owner of this file is the root user.

Regular users do not have permission to directly modify files owned by root, so if you want to edit this web page file, you need to change the file's owner to your own username.

sudo chown <username>: index.html

Now you can try editing this file, then refresh your browser to see the changes to the web page.

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