Published April 30, 2018 by

How to Add New Volume to AWS Instance

Services>>EC2-Instances>>Volumes>>Create Volume


Create Volume

Volumes>>Create Volume
Please choose appropriate parameter according to your requirement. Please, note Availablity Zone must be same for your Instance Zone which with you attach volume.

Attach Volume

Select Volume>>Actions>>Attach Volume


Here it asks for confirmation. Click on Attach button.
Login to AWS instance and type lsblk to check if a drive is initialized on OS.

# lsblsk


Here it shows xvdf (20GB) is available for a mount.

You can also fdisk -l command for same.

Mount your volume using below command.

# mkfs.ext4 /dev/xvdf

Create a new directory and mount a new volume with each.

# mkdir /subhash
# mount /dev/xvdf /subhash

Now check disk fragmentation.

# df -h


Add an entry in /etc/fstab for mounting it automatically after reboot.

# vim /etc/fstab

Add this line at the end of a file.

/dev/xvdf /serverkaka ext4 defaults,nofail 0


Save and Reboot system.
Read More
Published April 28, 2018 by

Modify a Volume Size in AWS EC2

If we face data limitations in our EC2 instance's volume, we can modify or resize it.

First, stop EC2 instance:


Seclect instance>>Actions>>Insatnce State>>Stop



Now, Go to Volumes and Modify

Select Volume>>Actions>>Modify Volume

Here insert a new value of HDD size.
Here it will ask for your permission.
Wait for few minutes till it goes an in-use state.



Whenever state changes to in-use - completed state, Login in an ec2 instance and insert below command.

# sudo apt-get update
# sudo apt install xterm
# sudo growpart /dev/xvda 1
# sudo resize2fs /dev/xvda1

Using df -h command check partition is extended or not.

# df -h
Read More
Published April 24, 2018 by

Change AWS EC2 Instance Type

If we face hardware limitations of our EC2 instance, we can not just increase Memory/CPU cores as in VMWare, instead, we must change instance type. It is set of predefined images with different hardware specifications.

First, stop EC2 instance:

Seclect instance>>Actions>>Insatnce State>>Stop


Then, from Actions>>Instance Settings>>Change Instance Type


Select instance type from drop-down menu and click Apply

Now start the instance. and check changes.
Read More
Published April 24, 2018 by

How to Create Sub Domains in Apache

In this tutorial, we demonstrate how to create a subdomain in Apache Web Server.

This is actually really easy. First, make sure your DNS is working. You can use A, AAAA or CNAME record as long as it points to your IP address.

Please check if it is working before you continue. You can check using ping subdomain.mydomain.com. If it is pointing to your IP address you're good.

Now create virtual hosts in Apache configuration file for Sub Domain.

# vim /etc/apache2/sites-enabled/000-default

Just adding this VirtualHost will do:

<VirtualHost *:80>
    ServerName subdomain.domain.com
    DocumentRoot /var/www/subdomain
</VirtualHost>

Now create /var/www/subdomain

# mkdir -p /var/www/subdomain

And put your subdomain files here.

Now Restart Apache

# service apache2 restart

Test it.

Go to a browser and hit subdomain.domain.com
Read More
Published April 14, 2018 by

Create a Bucket in AWS S3

A bucket is in fact name for the folder or drives in AWS, in which we can store data.

For Create a Bucket In AWS S3 follow below steps.

Open S3 Service in AWS Management Console.



Click on Create Bucket



Please note Bucket name must be unique and lowercase later.



After clicking Next we are presented with some options:

Versioning: Keep track of object version
Logging:      Logs access to objects in AWS
Tags:           Used to track



After clicking Next bucket-Properties we can see all bucket properties, some of them are described earlier


7.PNG

Static Web Site hosting: Hosting an only static website (HTML)
Cross-region replication: Replicate bucket content to a different region
Transfer acceleration: Enables transferring files to and from a bucket
Events: Setting notifications when specific operations occurring in a bucket (creating/deleting/modifying objects)

After clicking Next we can set permissions:



There are user and public permissions, also there are object permissions (permissions over object itself)



After clicking Create bucket it creates a bucket.



Upload Files In Bucket.

Click Upload Button


Choose File
Read More
Published April 12, 2018 by

Set Up Password Authentication in Apache on CentOS/RedHat

In this tutorial, we will learn how to password-protect website or content on an Apache web server running on CentOS and RedHat based server.

Allow .htaccess Authentication


By default, Apache does not allow the use of .htaccess files. We will need to set up Apache to allow .htaccess based authentication.

We can do this by editing the Apache configuration file (httpd.conf).

# sudo vim /etc/httpd/conf/httpd.conf

In httpd.conf file, find the section that begins with <Directory "/var/www/html">. Change the line from AllowOverride none to AllowOverride AuthConfig


AllowOverride AuthConfig

Save and close the file.

Create Password File

We can use htpasswd to create a password file that Apache can use to authenticate users. We will create a hidden file for this purpose called .htpasswd within our /etc/httpd/ configuration directory.

The first time we use this utility, we need to add the -c option to create the specified file. We specify a username (subhash) at the end of the command to create a new entry within the file.

# sudo htpasswd -c /etc/httpd/.htpasswd Subhash

Here it will be asked to password for the user.

Only use -c the first time you create the file. Do not use -c when you add a user in the future.

# sudo htpasswd  /etc/httpd/.htpasswd Adam

If you want to view the contents of the file, you can see the username and the encrypted password for each record

# cat /etc/httpd/.htpasswd

Configuring Apache Password Authentication

Now we need to create a .htaccess file in the web directory we wish to restrict. In this example, we will create the .htaccess file in the /var/www/html/ directory to restrict the entire document root.

# sudo vim /var/www/html/.htaccess

Add below code to a .htaccess file.

AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/httpd/.htpasswd
Require valid-user

Save and close the file.

Restart Apache

# sudo apachectl restart

Time to Test

After everything has been set up, it's time to test your Apache server. Try to access your website in a web browser. You should be presented with a username and password prompt that looks like this.


If you enter the correct credentials, you will be allowed to access the website. If you enter the wrong credentials or hit "Cancel", you will see the "Unauthorized" error page.

Read More
Published April 12, 2018 by

Set Up Password Authentication in Apache on Ubuntu

In this tutorial, we will learn how to password-protect website or content on an Apache web server running on Ubuntu and Debian based server.

Install  Apache Utility Package

We will use a utility called htpasswd, part of the apache2-utils package, to create the file and manage the username and passwords needed to access restricted content.

# sudo apt-get update
# sudo apt-get install apache2-utils


Create Password File

We can use htpasswd to create a password file that Apache can use to authenticate users. We will create a hidden file for this purpose called .htpasswd within our /etc/apache2 configuration directory.

The first time we use this utility, we need to add the -c option to create the specified file. We specify a username (subhash) at the end of the command to create a new entry within the file.

# sudo htpasswd -c /etc/apache2/.htpasswd Subhash

Here it will be asked to password for the user.

Only use -c the first time you create the file. Do not use -c when you add a user in the future.

# sudo htpasswd  /etc/apache2/.htpasswd Adam

If you want to view the contents of the file, you can see the username and the encrypted password for each record

# cat /etc/apache2/.htpasswd

Configuring Apache Password Authentication

Edit Apache virtual host file 000-default.conf

# sudo vim /etc/apache2/sites-enabled/000-default.conf

Add below code to a virtual host.

<Directory "/var/www/html">
                AuthType Basic
                AuthName "Restricted Content"
                AuthUserFile /etc/apache2/.htpasswd
                Require valid-user
</Directory>
Save and close the file.

Restart Apache

# sudo systemctl restart apache2

Time to Test

To confirm that your website is protected, try to access your website in a web browser. You should be presented with a username and password prompt that looks like this.


If you enter the correct credentials, you will be allowed to access the website. If you enter the wrong credentials or hit "Cancel", you will see the "Unauthorized" error page.

Read More