Setting up of Apache2 and Project Directory along with security in Linux / Ubuntu

Setting Apache2:

Installation of Apache2:
       Open terminal
       Run the command: $ sudo apt-get install apache2

To start the apache2:
       $ sudo /etc/init.d/apache2 start

To stop the apache2:
       $ sudo /etc/init.d/apache2 stop

To restart the apache2:
       $ sudo /etc/init.d/apache2 restart

To work with apache server, work with root access:
       $ sudo su or $ su (for some other linux/ubuntu)
       Type your password and press Enter

 root access

To open apache2.config file in terminal:
       # cd /etc/apache2
       # nano apache2.conf

apache2 conf1

       Hit Enter

apache2 configur

To modify the content:
       Edit your content
       Press Ctrl + X
       Confirm saving the file by pressing Y
       Then Press Enter

To Exit from the file:
       Press Ctrl + X

To check the working of apache2:
       Open browser and type localhost in the address bar and hit Enter

localhost

Setting Project Directory:

To move to the working project directory:
       # cd /var/www/html or # cd /var/www (when html directory is not found)

working dirr

To create new project directory:
        # mkdir project (use any name of the directory)

mkdir pro

dirrr

Setting security of the directory:

To check the availability of any password protected user (display the password but encrypted):
       # cat /etc/apache2/.htpasswd

To add a user:
       # useradd chind (use any name for the user)

To display the list of users:
       # compgen -u

To set password of the user:
       # htpasswd -c /etc/apache2/.htpasswd chind (choose the user to set password)

user pass

To set password for the project directory:
       # cd /etc/apache2/sites-enabled
       # nano 000-default.conf or # nano 000-default

site enable

       Hit Enter
       Then Add the following lines before the closing tag of virHost at the last –
secur dirr

set pass dirr

       Then, Exit (Ctrl + X) and Save the file (Press Y and Enter)
       Restart the apache2 server:  $ sudo etc/init.d/apache2 restart

To check the security of the project directory:
       Open browser
       Search in the address bar: localhost/project
       Username and Password is asked to access

dirr pass

Thank you

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s