@sallie
To set up a web server on Ubuntu, you can follow these steps:
Open a terminal window and run the following command to install Apache HTTP server:
1 2 |
sudo apt update
sudo apt install apache2
|
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) |
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
|
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.