How to install Apache Web Server on Ubuntu 20.04 & create a custom web page
Hi, Everyone! Welcome to my Medium page. In this article , I would like to share how to install, configure Apache web server on Ubuntu 20.04 .
Apache HTTP Server is a free and open-source web server that delivers web content through the internet. It is commonly referred to as Apache and after development, it quickly became the most popular HTTP client on the web.
Why we use apache server in linux?
- Apache web servers are easy to customize environments, they’re fast, reliable, and highly secure.
- Apache can process dynamic content within the web server itself without having to rely on any external components.
- Easy to configure, beginner-friendly.
- Cross-platform (works on both Unix and Windows servers).
Step 1: Run the Software Update using the following command:
sudo apt update
It will ensure you have all the updates and necessary packages for Ubuntu.
Step 2: Install Apache2 Software using the following command:
sudo apt install apache2
Cool, right? Now that Apache2 software is installed, you have to verify that it is running correctly.
Step 3: Configure your firewall settings with the following commands:
sudo ufw status
sudo ufw allow http
sudo ufw allow https
sudo systemctl start ufw
sudo ufw enable
sudo ufw status
Step 4: Run Apache2 and see the status Apache2 using the following command:
sudo systemctl start apache2
sudo systemctl status apache2
There is a way, you can also check if Apache server is running by using IP address on the web browser on the address bar (e.g. 52.26.212.75). Now, how do you know what is your IP address? Just type on Google, what is my ip? It will give you your IP address. Also you can type hostname -I on the terminal to get the IP address.
You should see the default Ubuntu 20.04 Apache web page:
👏👏👏👏 Congratulations!! Apache Server is active and running!!
Step 5: Edit the web page:
Use the command sudo nano index.html to edit the index page (currently, the index page contains the Apache2 welcome page in the above image).
Now please type the following command on the terminal to change the directory to the index page
cd /var/www/html/
Then type on the terminal once you are in the index page
ls
You should see the list of files by ls command. Now cope the content of index.html and create a new file index_new.html by using below command:
sudo mv index.html index_new.html
( just creating another file for index.html, named index_new.html)
mv creates any directories that it needs. Now you can check again by using ls command if the file created. Then you have to open the file index.html and edit the index.html file to see new index page (currently, the index page contains the Apache2 welcome page , see the above image).
Once you type sudo nano index.html inside the directory /var/www/html you can start typing code for to create a custom web page.
👏 👏 👏 👏 Congratulations!! You have now completed creating a web page on Ubuntu using an Apache2 web server and the server is running on the browser!!
Bonus Step:
Now, we will write and execute a bash script to automate this process.
Let’s change the directory to bin by using cd /bin
Note:Before that you have to get off from the previous director by using command cd ../
Then use the command nano script.sh to go back into the nano text editor to create a script. Once the nano text editor open’s, please write the attached script.
These scripts will automate the process. Once you are done writing the script, save it and exit the Nano Text Editor by pressing CTRL+X. Finally, we can run the bash script.sh command to see our automated process.
Thank you everyone 😃, for reading my blog!!
👏👏👏👏 Happy Learning!!
Note: If you need help with the installation for NGINX, please see the attached link here .
If you think, this article is helpful 😄, please give me a clap 👏 👏👏👏to inspire me.
Please connect me on linkedin 👎
https://www.linkedin.com/in/aktersabina122/
Please follow me on Medium and Twitter 👎: