Posts

Transferring an EC2 Instance to Another AWS Account: A Step-by-Step Guide

Image
To move an existing EC2 instance from one AWS account to another, follow the steps mentioned below. Step 1: Log in to the AWS account where the EC2 instance is running, and ensure that you select the appropriate region in the upper right corner where the instance is located. Step 2: Select the instance that needs to be transferred to the other account from the list. To create an image of this instance   Click on 'Actions'  Select 'Image' from the dropdown And then choose 'Create Image' from the submenu. Step 3: A 'Create Image' pop-up will appear. Provide the required details such as the image name and description, and then click on the 'Create Image' button. Step 4: From the side menu, click on 'AMIs' and wait until the image is created. Usually, this process takes around 2-10 minutes. Step 5:  Meanwhile, log in to the other AWS account (you can use a private or separate browser window) ...

Deploying Angular 7 Application with Apache on Amazon EC2 Ubuntu Server: A Step-by-Step Guide

Deploying Angular 7 Application with Apache on Amazon EC2 Ubuntu Server. Prerequisites to Install Install Node Package Manager sudo apt install npm Install Nodejs sudo apt install nodejs Install the Angular CLI sudo npm install -g @angular/cli Install Apache sudo apt-get install apache2 After successful installation. Follow the below steps Clone the complete project repository on the server. Install the dependencies using sudo npm install To deploy, start the production build using ng build --prod An output folder (dist/ by default) will be created on the server. Change the Apache root to your project directory, specifically /dist/ng7/. Enabled mod_rewrite, and restarted Apache. sudo a2enmod rewrite sudo serivce apache2 restart And finally, add this .htaccess inside dist/ng7 directory. </ifmodule mod_rewrite.c=""> RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !...

MYSQL -Import Data from Delimited Data

Loading CSV or any delimited data files to MySQL Database. This is a very common task for the developer and the only thing that I think of is LOAD DATA INFILE. The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed. Here, I will explain how to get the data loaded directly from CSV to MySQL database using commands. For more information, feel free to refer https://dev.mysql.com/doc/refman/5.7/en/load-data.html a) Copy the complete CSV file data including header LOAD DATA LOCAL INFILE 'path/of/csv/file' INTO TABLE <TABLE NAME> FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' Path: '/home/user/file_name.csv' or in windows 'C:/path/file_name.csv' FIELDS TERMINATED BY ',': Divides the line data into Fields Example: A table with three columns say A,B,C and CSV file is as follows a,b,c aa,bb,cc aaa,bbb,ccc By terminating by delimited ',' fields table would look like ...

Increase EC2 root volume size

Image
Introduction: To increase EC2 Linux server's root volume size. Why was this tutorial made?  I had this issue in one of my EC2 instances where I was running Codeigniter Project. So what was the problem? Codeigniter pop-out a message saying " fopen(/var/lib/php/sessions/ci_session2be254f027bc9251bf55ddd02b09c35e5ff7a7c1): failed to open stream: No space left on device " Now I, connected to my instance using Public DNS ran df command ( report free disk space ) By running Df command, I made sure the problem was with the root volume of my EC2 instance. While creating a new instance in EC2, most Linux instances come with an 8GB root volume unless you changed it at first launch. So in my case, I made use of 8GB Volume. Solution Now, we need to increase the space of root volume attached to our EC2 instance. Step 1:  Navigate to your AWS Console and then click EC2 and then Volumes on the left panel.  Step 2: Finding th...

Securely setting Files and Folder permissions on Laravel 5

Image
Securely setting Files and Folder permissions on Laravel 5 Introduction: Handling file and folder permission in Laravel 5 and above. Why was this tutorial made? I had a similar issue while running Laravel Application and Cron Jobs on the same server. So what is the problem here? The issue here was while creating a log file. When the log files are created by the Web Application the file permission would look like. -rw-r--r-- 1 www-data www-data 1646 May 11 2017 laravel.log //Permissions are set to Apache User Similarly, when the log files are created by the Cron Jobs then the file would have its owner and group owner as your Apache User. -rw-r--r-- 1 ubuntu ubuntu 1646 May 11 2017 laravel.log //Permissions are set to User So, if the log file was created by Web Application same file can't be used bt Apache User and vice versa Error would look something like this The stream or file "/var/www/html/project-folder/storage/logs/lara...

Using Redis in PHP for handling background Jobs

Using Redis in PHP for handling background Jobs Introduction On Redis Redis is an open source, BSD licensed advanced key-value store. It is often referred to as a data structure server since the keys can contain strings, hashes, lists, sets and sorted sets. Redis is written in C. Refer to the below link which would help us to understand how to install Redis. Also, it gives the basic understanding of how to use Redis. how to install and use Redis Before you start using Redis in your PHP programs, you need to make sure that you have Redis PHP driver and PHP set up on the machine. You can check PHP tutorial for PHP installation on your machine. Installation Now, let us check how to set up Redis PHP driver. You need to download the phpredis from github repository  phpredis . Once you’ve downloaded it, extract the files to phpredis directory. On Ubuntu, install the following extension. cd phpredis sudo phpize sudo ./configure sudo make sudo make install Now,...

DrillDown using Flot Charts

Image
Flot Charts is a pure JavaScript plotting library for jQuery, with a focus on simple usage, attractive looks and interactive features. For more information on Flot Charts please refer to http://www.flotcharts.org/ Flot Charts supports lines, points, filled areas, bars and any combinations of these, in the same plot and even on the same data series its also provide few additional plugins like pie charts and so on. In this tutorials, we will be creating Bar and Pie Chart DrillDown So, what exactly drilldown means, its opens up a new data set to explore with more granularity A drilldown with allows users to focus on the “data within the data” within a single chart area. Let's get started with real time scenario, Assume any college management software where we need to see individual student performance i.e Average score of the student in all 10 semester along with individual subject scores in each semester. Based on this usecase i have drilled down the charts for 2 level....