apt
It is a package manager that stores the reference to the packages which we need to install on our Linux system.
Example
To Install a webserver (apache2 on ubuntu system)
Run the below command to update the apt repository.
Step 1:-> Update apt repo
sudo apt update
OR
sudo apt-get update
Step2: -> Install apache2 from apt repo reference.
sudo apt install apche2 -y
Step 3:-> Verify apache is installed or not (apache is installed as a service)
sudo service apache2 status
OR
sudo systemctl status apache2
Step 4:-> By default, apache2 is running on port 80 (http).
Portr 22 :- SSH
Port 80 :- HTTP
Port 443:- HTTPS
Step 5:- Access apache default web page
curl command:- It returns http respose
curl localhost:80
Got to the browser and check you are able to access the Apache default page
Step 6:- Stop apache service and check whether you are able to access apache webpage or not.(You should not be able to access the web page)
systemctl stop apache2
Step 7:- Start apache service and refresh your browser.restart command is to stop the service and start it again if it is in the started mode whereas if the service is in the stopped mode then it will just start the service.
systemctl start apache2
OR
systemctl restart apache2
Step 8:- Create an HTML file and host it on the apache server.
When you install apache then there is a special type of directory get created (/var/www/html) where we can host html,php...other types of files
sudo echo "<h1> This is super cool html file </h1>" >> /var/www/html/sample.html
Step 9:- Browse sample.html file to the browser
curl localhost/sample.html
OR
got to the browser and browse URL localhost/sample.html
Step 10:- Uninstall apache2 from ubuntu system
apt purge apache2 -y
systemctl status apache2
COMMENTS