How to set up a web server on Ubuntu?

Member

by sallie , in category: Networking & Wireless , a year ago

How to set up a web server on Ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lia , a year ago

@sallie 

To set up a web server on Ubuntu, you can follow these steps:

  1. Install Apache HTTP server:


Open a terminal window and run the following command to install Apache HTTP server:

1
2
sudo apt update
sudo apt install apache2


  1. Check if the Apache service is running:


After the installation is complete, Apache should start automatically. You can check if it is running by typing the following command:

1
sudo systemctl status apache2


If the Apache service is running, you should see a message similar to this:

1
2
3
4
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2021-09-08 08:58:32 UTC; 2min 15s ago
 Main PID: 1234 (apache2)


  1. Open the firewall for HTTP and HTTPS traffic:


By default, the Ubuntu firewall is configured to block incoming traffic. To allow HTTP and HTTPS traffic to reach your web server, run the following commands:

1
2
sudo ufw allow 'Apache'
sudo ufw enable


  1. Test your web server:


You can test your web server by opening a web browser and navigating to http://localhost. You should see the default Apache page. If you want to serve your own content, you can replace the default page with your own files in the /var/www/html directory.


That's it! You now have a fully functioning web server on Ubuntu.