Open In App
Related Articles

How to make sure that Apache service keeps running in Ubuntu

Improve Article
Save Article
Like Article

Majority of world’s websites are hosted on are hosted on Apache Web Servers and the majority of those servers run Apache in Linux. Let’s see how to install Apache in Ubuntu:

Type the following commands in terminal application on your computer:

$ sudo apt-get update
$ sudo apt-get install apache2

Now type localhost on your browser. It will pop up a message “IT WORKS“.

There is also another way to check whether Apache Services running in the browser or not. To check, first find the IP Address using the below command:


Now, put that IP address on the browser. The same message is being displayed “IT WORKS”. This ensures that Apache service keeps running in Ubuntu.

To find out the active ports then type:

$ netstat -a|more

Here we get all of the ports, our active connections, our virtual ports essentially that our computer is listening. If you need to get the port numbers then type:

$ netstat -an|more

It shows port80, the port for the web server, port for HTTP, it listens to every address available. Our web server is listening.


  • To stop the web server then type:
    $ sudo /etc/init.d/apache2 stop

    To check it Type:

    $ netstat -an|more

    Now our web server is no more listening.

  • To start our web server, type:
    $ sudo /etc/init.d/apache2 start

  • To Restart our web server, type:
    $ sudo /etc/init.d/apache2 restart

    To check, Type:

    $ netstat -an|more

    Now our server is running.

Now We have to create and edit our Webpage. So type the following command:

$ cd /var/www

Press ENTER to continue.

:/var/www$ ls

Press ENTER to continue.


This ‘index.html‘ is the default Webpage in the Apache. To edit the Webpage, type the Command:

:/var/www$ sudo nano index.html

Dans Homepage</title>
<body><h1>Welcome to my webpage!</h1>
<p>This website is under construction.</p>

Press CTRL+X to save and exit.

Type localhost or Your IP address on the address bar of a web browser. ‘index.html‘ page will be displayed.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 03 Jan, 2019
Like Article
Save Article
Similar Reads
Complete Tutorials