Install and Configure Apache web server in Ubuntu

The Apache web server is the most widely used web server. Approximately 65 million web servers run on Apache.
Given below are the steps to install and configure Apache web server.

Install Apache
To install from the command line, type
$sudo aptitude -r install apache
This will install Apache2 and the recommended packages for the Apache web server.

Configuring Apache
There are different locations where the files related with Apache web server are stored.

/etc/apache2
This directory contains the configuration files for the Apache2 web
Server. The primary configuration file is apache2.conf.

/etc/apache2/conf.d
This directory contains local configuration directives for Apache, such as those associated with third-party or locally installed packages.

/etc/apache2/envvars
A file containing environment variables that can be set to environment used by the apache2ctl script to manage Apache2 web Server.

/etc/apache2/mods-available
This directory contains available Apache2 modules and their configuration files.

/etc/apache2/mods-enabled
This directory contains the links to enable Apache2 modules and their configuration files, located in /etc/apache2/mods-available directory.

/etc/apache2/sites-available
This directory contains files that define the web sites supported by the server.

/etc/default/apache2
This configuration file determines whether Apache should automatically start at boot time.

/etc/init.d/apache2
This is a shell script to start and stop Apache web Server.

/etc/sbin/apache2
The actual executable for the Apache web server.

/usr/sbin/apache2ctl
This is a shell script which simplifies starting, stopping, restarting and monitoring the status of a Apache web server.

/usr/share/apache2-doc
This directory contains the Apache2 manual. This directory is present if apache2 doc package is installed.

/usr/share/apache2/error
This directory contains the default error responses delivered.

/usr/share/apache2/icons
This directory contains the default set of icons used by Apache web Server.

/var/log/apache2/access.log
The default log file for an Apache web server. This log file tracks any attempts to access the web site, the host that they came from and more.

/var/run/apache2/apache2.pid
A text file used by Apache to record its process ID when its starts. This file is used when terminating or restarting the Apache server using the /etc/init.d/apache2script

/var/www/apache2-default
This directory contains the default home page for this web server. To access the default Apache web page, go to http://localhost/. Default root document for apache2 is /var/www.
To change the default root document goto /etc/apache2/sites-available/default file and look for the line DocumentRoot /var/www/. Change the path to your desired folder.
After making any changes to Apache, you need to restart it. To restart Apache, go to terminal and type
$sudo /etc/init/apache2 restart      

Useful Linux commands

These are the few commands related to Ubuntu and work with all other Linux distributions.

System Information Commands

1.df: The df command displays filesystem and disk usage for all partitions. The command df -h uses megabytes(M) and gigabytes(G) to report.
2.free: The free commands displays the amount of free and used memory in the system. free -m will give the information using megabytes.
3.top: The top command displays information om your Linux system,running process and the system resources,including the CPU,RAM,swap,usage and total number of tasks being run. 
4.uname -a : lsb_release command  shows version information for the Linux release you are running.
5.ifconfig: This reports on your system's network intefaces.
6.iwconfig : The command will show any wireless network adapters and the wireless specific information from them,such as speed and network connected.
7.ps : The command ps allows you to view all the process running on the machine.
8.lsusb: The command lists all the USB buses and any connected USB devices such as printers and the thumb drivers.
9.lshw : The command lshw lists hardware on your system, including maker, type and where it is connected.

File system commands

These are the commands which are used for moving around the file system.

1.pwd : pwd stands for "print working directory".The pwd command will tell you the directory in which you are located.
2.cd : The cd command lets you change directories. To move around the file system you have to use cd.

Manipulating Files and Folders
You can manipulate files and folders using the following commands:

1.cp : The cp command will make a copy of a file for you.
2.mv : The mv command will move a file to a different location or will rename a file. eg. mv file foo will rename the file "file" to "foo".
               mv foo ~/Desktop will move the the file "foo' to desktop directory.
3.rm : Use this command to remove or delete a file in your directory.It will not work on directories in which there are files.
4.ls : The ls command will show you the files in your current directory
5.mkdir : The mkdir command will allow you ro create directories.eg mkdir photos, will create photos directory.
6.chown : The chown command allows the user to change the user and group ownerships of a file.

Dealing with Users and the Groups
You can use following commands to administer users and groups:

1.adduser : The adduser command will create a new user. eg. sudo adduser username. This will create the user home directory and the default group. It will prompt for a user password and then further details about the user.
2.passwd : The passwd command will change the user's password.
eg. sudo passwd .This will prompt for new user passwd.
3.who :The who command will tell you who is currently logged into the machine.
4.addgroup: The addgroup command will add a new group.To create a new group type sudo addgroup groupname.
5.deluser : The deluser command will remove a user from the system.To remove their files and home directory
eg . sudo deluser username
6.delgroup : The delgroup command will remove a group from the systems.You cannot remove a group that is the primary group of any users.

Related posts
10 Linux commands you should know

Directory structure of Ubuntu Linux

Ubuntu directory structure is a directory tree structure very much similar to directory structure of Unix. There is a resemblance between Unix directory structure and directory structure of Ubuntu Linux. The Ubuntu Linux directory structure contains the root directory  '/'  at the top with the remaining Linux system directories and file structure like hard disk, partition and other data files falling under it. It is a tree like structure and the top of the tree i.e., the highest level in the file system is the root directory '/'.
Some important Ubuntu Linux system directories are




1. /bin: This directory contains important binary application. It would contain the executable file for command like ls, cal, grep etc which are used in everyday Linux environment, directly or indirectly.  
2. /boot: This directory contains the files needed for booting up the operating system. It include the kernel (vmlinux), ramdisk image (initrd.lz) and bootloader configuration files.
3. /dev: This Ubuntu Linux directory does not consume any space on disk and is used to keep track of devices connected to the computer including the ones which are a part of the CPU such as the disks, mouse, display,graphics card etc.
4. /etc: This is the place where you can find the configuration files of the base OS and other installed applications and startup scripts. It contain all the configuration files, ranging from the ones which control the booting of computer to the ones which can change the behavior of installed software and services.
5. /home: It is the user profile folder in Linux similar to the c:/ user folder in Windows. Each user on the system would have a separate directory within this sub-directory.
6. /lib: The system libraries required for the proper functioning of installed software are present in this  Linux directory. 'Library' in context of computing is define as a reusable resource that can be used by more then one software.
7. /lost+found: This contains the lost and found files of your / directory.
8. /media:This directory is not a part of the Linux directory structure. It is the system directory file which help to recognize all the mounted removable media such as CD, external hard drives, USB drives, cameras etc.
9. /mnt: This Linux directory is used to create mount point for other systems which are attached to the computer on boot, e.g. Windows partitions.
10. /opt: This directory provides a location for optional applications to be installed.
11. /proc: This virtual directory does not consume any space on disk but exists only in the system memory. This directory is freely available for browsing only to the 'root' user.
12. root: This is commonly known as the slash-root directory, it refer to '/' as root in Ubuntu Linux.
13. /sbin: This directory is also available to root user. It contains commands to change system wide settings.
14. /srv:  This directory acts as a temporary location for data meant to be used by servers.
15. /sys: This directory contains system-specific information meant as reference for other applications.
16. /tmp: As the mane suggest, it acts as storage for temporary files.
17. /usr: This is where most of your applications and files will be stored, as anything present here is available for all users to acccess. It can be also be called as the program files folder for Linux.
18. /var: This is a directory for variable files such as logs and databases. Notice the contrast with the /tmp directory.

10 Ubuntu Linux commands you should know

Here is the list of 10 Ubuntu Linux command that may not be used in day to day life but knowing these command will make Ubuntu experience more enjoyable as these command are used for giving permissions to user or a program to access the files in Ubuntu root directory.

1. sudo: Ubuntu developers have disabled the administrative root account by default, it means that any user who logs in cannot carry out system administrative duties. It does not mean that the root account has been disabled or cannot be accessed. Instead sudo command is used to carry out system administrative duties. Sudo command allows an authorized user to temporarily become the root user and carry out the system administrative duties such as installing software, removing software or giving file permission etc.

2.chmod: This command is use for setting file permissions for users.
 There are three types of access restrictions:
Permission
Action
chmod option
read
(view)
r or 4
write
(edit)
w or 2
execute
(execute)
x or 1

There are also three types of user restrictions:
User
ls output
owner
-rwx------
group
----rwx---
other
-------rwx
                    
e.g. sudo chmod 777.Then this command will give permission to owner,group and other to read,write and execute the specific file.

3.apt-get: The apt-get command is used for performing functions as installation of new software packages, removing of existing software, upgrade of existing software packages, updating of the package list index, and upgrading the Ubuntu system.
        eg. sudo apt-get install package name
             sudo apt-get remove package name
             sudo apt-get update
             sudo apt-get upgrade

4.man: If you have problem getting the syntax or what functions are actually performed by a specific command, all you need to do is in terminal type man  and the command you will get all the information related to the command.
             e.g. man sudo
This command will give all the information related to sudo command.

5.cd: This command is used to change directories. Initially terminal shows the home directory. For performing administrative action for a file or folder this command is very useful.
     eg.   cd /home/Desktop
This command makes Desktop the active directory in terminal. 

6.rm: This command is used to remove or delete file from the system.
           eg. sudo rm filename
If you want to remove a file you cannot delete then you can use the following command  sudo rm -rf filename

7.ls: This command is used to list all the files and folders in a directory.
         eg. ls /home 
This is will show all file and folders in home directory.It all shows permissions,size of files and when files are made.

8.kill or killall: Sometimes, applications become unresponsive and to quickly get rid of the application kill/killall all function is used.Difference between kill and killall is kill functions require  PID (Process ID number) whereas killall require only process name.Process name can be seen from System monitor.
             eg   sudo killall firefox-bin
  This command will close the firefox.

9 top :This command will show all the current running process and the memory use by them.Simply type the command top in terminal and you will get all your running process.
10 ping : ping will show the information whether the computer is connected to any other computer or to the internet.

Install Ubuntu on external hard drive or pendrive


This post will help installing Ubuntu on external hard drive which is
almost same as installing Ubuntu on internal hard drive.The very same
process can be used to install Ubuntu on pen drive.

Steps:

1. Connect the external disk or pendrive to your system and boot the computer using an Ubuntu 11.04 CD or DVD.

Ubuntu pendrive screenshot 1


Select install ubuntu.

2.The following window will appear.

Ubuntu pendrive screenshot 2
Select Something else option.

3.The external disk connected to computer will be denoted by dev/sdb. The “b” shows that it is the external hard disk detected by the system.

Ubuntu pendrive screenshot 3

Select the free space and Click Add option.

If its not showing any free spaces, then select any drive appear below /sdb and delete it (back up your data).

Ubuntu pendrive screenshot 4

In this option, select the mount point /boot and partition size can be anything between 22MB to 258MB.

Now create a partition from the free space for swap area this will act as virtual memory.

Ubuntu pendrive screenshot 5

Select the swap area any where between 500MB to 1GB. 

In the free space available create a new partition for Home. Creating this
partition is optional and you can skip to next step to create partition
for root directory "/" .

Ubuntu pendrive screenshot 6
Now create partition for root directory '/' .

Ubuntu pendrive screenshot 7

Click OK.

Ubuntu pendrive screenshot 8
As partition for /, /boot and /home is created now in boot loader option select your external hard disk or pen drive option. Click Install Now and you are ready with installation.

NOTE : Do not select the partition of external hard disk but the whole hard disk.

NOTE: To access Ubuntu from hard disk plug in the hard disk before starting your system. In the Grub menu you will see Ubuntu option with external
hard disk info. In front of it, select that option and you are ready to
access Ubuntu from hard drive and do not remove your external drive
while accessing Ubuntu.

Install Ubuntu on external hard drive

This post will help installing Ubuntu on external hard drive which is almost same as installing Ubuntu on internal hard drive.The very same process can be used to install Ubuntu on pen drive.

Steps:

1. Connect the external disk or pendrive  to any computer and boot the computer using an Ubuntu 11.04 CD or DVD.

Select install ubuntu.
2.The following window will appear.
Select Something else option.
3.The external disk connected to computer will be denoted by dev/sdb. The “b” shows that it is the external hard disk detected by the system.
 Select the free spaces and Click Add option.
In this option select the mount point /boot and partation size can be anything between 22MB to 258MB.
Now create Virtual partition for




Top 5 myth about Linux operating system.

There are many myths about Linux operating system and these myths are mostly among those people from non technical background.

1.Linux is more secure because it has a smaller User Base :

Some people say that linux has less malware and viruses because it has less than 1% of the desktop market compared to Windows 90%, and believe that if linux ever increases in popularity then it will suffer just as badly as Windows. This argument is deeply flawed & not just by the spurious statistics as Linux dominates server markets around 65% of the world severs run on Linux then why struggle to write a virus that might knock out a few thousand desktops when knocking out a few thousand servers could knock out a continent? Yet it is the desktop machines that are commonly exploited.

Main reason for Linux to less prone to viruses.   
  • Programs are run as normal user, not Root User
  • More eyeballs on the code, nowhere for malware to hide
  • Vast diversity makes it difficult to reproduce flaws in a system
  • All software and drivers are frequently updated by Package Managers
  • Software is generally installed from vast Repositories not from unfamiliar websites
  • Developers/programmers are recognised as Rock Gods rather than treated with contempt
  • Elegant, secure code is admired & aspired to. Hasty kludges are an embarrassment
  • Ownership of the means of production is in the hands of the workers
  • No-one profits from supplying anti-virus or security products

2.The Linux Interface is  unattractive:
     
   I guess these Desktop screen shots will do all the talking.



 
























Compiz provides the best user interface for any user to imagine.
The main problem is that people are habituated to Windows GUI and when they switch to Linux they find it difficult to operate and hence unattractive.
The most common habit among Windows user is clicking Refresh through right mouse click, which is not available in Ubuntu Linux.

3.Linux is a nightmare to install
   
The most common question in Linux forum is how to install the Linux. Linux is as easy to install as compared to Windows. Other most common myth is one have to install the software only from the source code by typing command in terminal. Linux software can be installed on mouse click as software comes bundled in .deb and .rpm format.

4.After you install Linux, you still don't have any everyday software. 


For every Windows software there are almost two or more alternatives provided in Linux. Check out few alternatives for Windows software. As for the rest of software, rest assured that there is replacement for everything you need. Also, the quality of these applications is typically as good as, and often better than, their commercial counterparts, and most of them are free. Moreover, some of these applications are so popular that versions have been developed for use on Microsoft Windows and other operating systems.

5. Linux has poor support because there is no single company behind it, but rather just a bunch of coders.

Linux has excellent support, often much better and faster than that for commercial software. There is a great deal of information available on the Internet and questions posted to newsgroups are typically answered within a few hours. Moreover, this support is free and there are no costly service contracts required. Commercial support is also available, if desired, from major computer companies such as Red Hat, Novell, IBM and HP. Also to kept in mind is the fact than many users find that less support is required than for other operating systems because Linux has relatively few bugs (i.e., errors in the way it was written) and is highly resistant to viruses and other malicious code.

Grub rescue from live Ubuntu CD

Grub Rescue commands

If Grub is missing after installing Ubuntu and screen is showing Grub Rescue, then Ubuntu grub rescue or restore has to done. It can be done through Ubuntu Server CD or Ubuntu Desktop CD
If at system start up you might be seeing the option Grub Rescue or Grub missing option then you need to follow the below commands.

This article will show how to do Ubuntu grub rescue with screen shots using Ubuntu Desktop CD. These screenshots  have been taken on Ubuntu 11.04. The very same method can be used to repair grub mint Debian.
If you don't have the desktop CD then you can use Ubuntu server CD or USB also. 
To do grub rescue through Ubuntu Server CD see 
"Install Grub from Ubuntu server CD".

NOTE:  You will get /usr/sbin/grub-probe: error: cannot stat 'aufs'  error if you didn't follow the commands listed below. Specifically you did not do chroot,
i.e. sudo chroot /mnt. 

For Ubuntu grub rescue follow these steps:
1.Boot from the Ubuntu Desktop live CD



Ubuntu grub rescue-1

                          Select Try Ubuntu.     

2.In Live Desktop session open terminal. 
  Application ->Accessories->Terminal.

3. In Terminal tpye sudo fdisk -l  
    It will display all partiton of the disk.
Ubuntu grub rescue screenshot-2
 
The partation which have Linux under System column is your drive in which ubuntu linux is installed. In screenshot ubuntu partition drive is /dev/sda11.

4. Mount the ubuntu partition drive
       sudo mount /dev/sdXX /mnt  (example 'sudo mount /dev/sda11 /mnt' ,don't miss the spaces.)

5.Only if you have a separate boot partition:
            sudo mount /dev/sdYY /mnt/boot.
 6.  Mount the virtual filesystems:
            
            sudo mount --bind /dev /mnt/dev
            sudo mount --bind /proc /mnt/proc 
            sudo mount --bind /sys /mnt/sys

7. To ensure that only the grub utilities from the LiveCD get executed, mount /usr     
     sudo mount --bind /usr/ /mnt/usr 
     sudo chroot /mnt  

8. If there is no /boot/grub/grub.cfg or it's not correct, create one using 
           update-grub 
      or  update-grub2
9.Now reinstall Grub  
         grub-install /dev/sdX  (e.g. grub-install /dev/sda. Do not specify the partition number.   
 10. Verify the install 
        sudo grub-install --recheck /dev/sdX
11. Exit chroot : CTRL-D on keyboard.
12. Unmount virtual filesystems:  
           sudo umount /mnt/dev 
           sudo umount /mnt/proc
           sudo umount /mnt/sys 

If you mounted a separate /boot partition:  
           sudo umount /mnt/boot 

13. Unmount the LiveCD's /usr directory: 
          sudo umount /mnt/usr

14. Unmount last device: 
           sudo umount /mnt
15. Reboot. 
         sudo reboot.

NOTE: If you are getting /usr/sbin/grub-probe: error: cannot stat 'aufs'  error then the possible reason is that you didn't follow the commands listed above. Specifically you did not do chroot,
ie sudo chroot /mnt.
Follow the above steps correctly and you are done.

 

Enable 3D desktop cube without crashing Unity in Ubuntu 11.04


Enabling 3d desktop cube in ubuntu 11.04 with unity will crash Ubuntu Unity. This problem can be solved by following given steps. 
To enable 3D cube in Ubuntu classic mode see 3D Desktop cube in ubuntu classic mode.
Install compiz setting manager through terminal or synaptic manager. In terminal paste the command . 
$sudo apt-get install compizconfig-settings-manager

   

Steps: (Note: each step must be followed sequentially and you will get the desktop cube as shown in the screenshot)

1.In compiz setting manager disable these plugin:
            i) OpenGL
            ii) Composite
            iii) Ubuntu unity plugin
           iv) Desktop wall.
Select disable plugins when a window appears asking for disabling other plugins.
After disabling these plugins your panels and unity will disappear,don't panic and follow next step.

2. Now enable these plugins sequentially.
        i)OpenGl
       ii)Composite
      iii)Desktop cube 
      iv)Rotate cube
      v)Ubuntu unity plugin.

Some conflicts may occur. Conflicts occur when same buttons are assigned to two or more actions.
After all these steps you screen may response abnormally. Don't worry restart your machine and follow next steps.

3.Here starts the actual work.

1. You need 4 workspaces or Desktop for cube effects.In compiz settings manager select General options -> Desktop Size under General  tab. Set Horizontal Virtual size to 4. Set Vertical Virtual size and Number of Desktop to 1. 

2.Enable Desktop Cube,Rotate cube,3D windows and Cube reflection and deformation.Enable all other plugins if any window appears asking for supporting plugin to be enabled.
3.Goto Desktop cube->Transparent Cube and set Opacity during rotation to 75 or as per your convenience.
4.Goto  Cube Reflection and Deformation -> Deformation. set Deformation to  none. You can change the image appearing at top and bottom of cube in Cube Caps tab.
5.Goto Rotate Cube->Bindings->Rotate cube.See if binding is default set to
<control><Alt>Left and <control><Alt>Right or change it as your desire. 

And Hurray Rotate your Desktop .To rotate desktop using mouse select Left mouse button<control><Alt>and move your cursor to get the effects.

Things to remember
1) Do not minimize the compiz manager at any point during all the steps.
2) Do not perform any other action  during the process.
There may be the possibilities that after enabling the desktop cube with Unity maximize and minimize button disappear or you are unable to move your window. To get back all these function, in the compiz manger select the option "Move Window" and " Window Decoration". 

There may be the chance that something may get wrong and things go out of hand.
To undo all the changes. Open the terminal, in-case the top bar and Unity are disappeared ,then open the terminal with shortcut
ctrl+alt+t. Then type
1) metacity --replace
2) unity --replace or  unity --reset
Unity bar will appear again. 


Recommended Posts
1.Install Ubuntu on Pendrive
2.10 Ubuntu commands you should know
3.Open Source alternative for windows software 
4.Top 5 Myth about Linux Operating system 

3D cube effects in Ubuntu Linux

This will enable the 3D desktop cube in Ubuntu Classic mode, to enable the 3D desktop with Ubuntu unity see 3D Desktop cube with ubuntu unity.

To get the Ubuntu Linux 3D Desktop cube and other Ubuntu desktop effects.
First you need to install the compiz.It can be install by either of the two ways. But I recommend Synaptic manager as other plug-ins need to be install.

In terminal paste the command .
sudo apt-get install compizconfig-settings-manager.
Or open the synaptic manager.Click on Search icon and search Compiz. In the appear list select compizconfig-settings-manager and compiz-fusion-plugins-extra.Second plugin for other Ubuntu desktop effects.
   
To apply this 3D cube desktop effects.Open up the Compiz Setting Manager via System->Preferences->CompizConfig Settings Manager.
Follow the following steps.
1. You need 4 workspaces or Desktop for cube effects.In compiz settings manager select General options -> Desktop Size under General  tab. Set Horizontal Virtual size
to 4. Set Vertical Virtual size and Number of Desktop to 1. 
 
2.Enable Desktop Cube,Rotate cube,3D windows and Cube reflection and deformation.Enable all other plugins if any window appears asking for supporting plugin to be enabled.

3.Goto Desktop cube->Transparent Cube and set Opacity during rotation to 75 or as per your convenience.

4.Goto  Cube Reflection and Deformation -> Deformation. set Deformation to  none. You can change the image appearing at top and bottom of cube in Cube Caps tab.
 
5.Goto Rotate Cube->Bindings->Rotate cube.See if binding is default set to
<control><Alt>Left and <control><Alt>Right or change it as your desire.

And Hurray Rotate your Desktop .To rotate desktop using mouse select Left mouse button<control><Alt>and move your cursor to get the effects.


 How to set the fire effects as shown in screen shots.



In Compiz setting manager.Follow following steps.

1.In setting window goto Paint fire on screen. Enable it.
2.In General tab select the initiate key,no of particles and other fields given.
And you are ready to play.