Sunday, May 15, 2016

Preparing to install Apache2 server on Ubuntu 14.04 LTS

Installing Apache server on Ubuntu is a very straightforward thing using the apt-get tool. However for my experiments, I wanted a dedicated virtual machine running on VMWare for this purpose. Following information are few things I wanted to do to my Ubuntu 14.04 virtual machine before I install Apache2 server on it. Since my host machine didn't have enough memory, I just gave 256 MB memory for the guest OS for this task.

(1) Setting up a Ubuntu system to boot in to a Bash shell instead of starting GUI:

sudo vi /etc/default/grub

edit the relevant line to look like the following.


To make the above change effective, run the following command and then restart the machine.

sudo update-grub
sudo reboot

if we wanted to start the GUI desktop environment one day,


(2) To see what type of shell we are running, we can use the following command,

echo $SHELL

(3) There are few useful tools which we can use to see the resource usage, etc of
our system.

See the memory usage of the system.

free -m

See the i/o usage. there are various useful arguments which can be used to check various useful information with this command.


See the processes and their system resource usage.

See the processes, CPU and memory usage all in a one illustrative display

sudo apt-get install htop

(4) Package management related important commands.

Search for a package. this just lists all the packages that matches with the provided keyword.

apt-cache search apache2

Read the info of a particular package we found from the above command.

apt-cache show apache2

See a full list of all the packages installed in the system.

dpkg -l

It's better to use if with less command.

dpkg -l | less

When the less command is showing the output of "dpkg -l", we can search for a keyword there like we do in vim editor.


(5) Installing apache server.

sudo apt-get install apache2 apache2-doc apache2-utils

Following command will show that our server has started and currently running.

ps aux | grep apache

Starting, stopping and restarting operations can be done with following commands.

sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restart

or with following commands,

sudo service apache2 start
sudo service apache2 stop
sudo service apache2 restart

(6) Visit the default home page and see. In order to do that, you can install a commandline web browser as follows.

sudo apt-get install w3m
Visit localhost and check whether we get the "it works" HTML page 
w3m localhost

If you prefer a GUI web browser to see it, you can use your host OS web browser for this purpose. For that, first of all, check the IP address of your virtual machine.


Then open a web browser of your host OS and enter that IP address in the address bar. You should see the "it works" page in it.

That's all folks!!!





No comments:

Post a Comment