Apache2 web server installation:

  1. The first step is to install apache2
apt install apache2 -y
Copy the code
  1. After the installation is complete, we check to see if the Apache service is started
systemctl status apache2
Copy the code
  1. Let’s take a look at some of the common commands used to manipulate Apache
D /apache2 start // Starting the Apache service /etc/init.d/apache2 stop // Stopping the Apache service /etc/init.d/apache2 restart // Restarting the Apache serviceCopy the code
  1. Now we’re ready to access the Apache server we just configured. Open your browser and typehttp://127.0.0.1/(This is the default IP address of the host) or if it is a cloud host, enter the IP address of the cloud host. When we see the following page, the Apache2 service is working successfully on our server.

Apache Modifies the root directory and default parameters

Let’s try to modify the configuration of the Web server, so that we can request the specified data in the web server we build:

Changing the root Directory

DocumentRoot /var/www/ in /etc/apache2/sites-available DocumentRoot /var/www/html/mainpage

Execute command:

vim /etc/apache2/sites-available/000-default.conf
Copy the code

DocumentRoot /var/www/ in 000-default.conf ServerAdmin webmaster@localhost http://10.11.53.202/%e7%88%b1%e5%bf%83/ DocumentRoot /var/www/html / Normally we the default for this as the root directory of the site, if the site directory is not under/var/WWW is no permissions by default it is we will revise the apache2 apache2. Under the conf file. Open the apache2. Conf

<Directory "/mnt/c/users/18451/Documents/study">
        Options all	
        Require all granted
</Directory>
Copy the code
  1. Then restart Apache
sudo apache2ctl -k restart 
Copy the code