Unable to delete AWS Elastic Beanstalk Environment “resource XX-XXXXXXX has a dependent object”

Unable to delete AWS Elastic Beanstalk Environment “resource XX-XXXXXXX has a dependent object”

Unable to delete AWS Elastic Beanstalk Environment "resource XX-XXXXXXX has a dependent object" - MervCodes

Problem

You will usually get this error when you are trying to delete an Elastic Beanstalk environment.

Solution

As the message in the Events log states, the security group of your Elastic Beanstalk’s environment’s ec2 instance is being referenced in another security group. (This is usually done to allow the ec2 instance to have access to another AWS service.) In this case the security group is referenced in our AWS RDS security group, the deletion works right after removing the reference.

Parsing Large Files in Node.js

“JavaScript heap out of memory”.

This is the kind of error you will be getting when you parsed a large file (sized around 80mb and above) in Node.js, and this happens only when you are trying to load the entire file into memory at one go.

The solution to this problem is to parse the file part by part. In this article, we will be using a library called line-by-line to illustrate the concept. Processing the file line by line will not load the entire file into memory, hence you will not get any memory exception error.

With the line-by-line npm library, you can either process a file synchronously or asynchronously, depending on your requirements.

The next few code snippets will give you a better idea on how it works.

 

Magento 1.9 Fix for Sending Double Emails or Sending Email to Wrong Recipients

As we know, Magento uses a cron job system to send out email from core_email_queue table. There is an additional table called core_email_queue_recipients, which as the name states, will store all recipients for emails there. But these records do not get removed at times and that is usually why you will get the issue of Magento sending double emails or sending email to wrong recipients.

Follow the following steps to have this issue fixed.

1. Clean up core_email_queue_recipients table

Executing the two SQL statements below will remove any orphan email recipient records so that Magento will not send double emails or send email to wrong receipents.

2. Alter core_email_queue_recipients

Altering core_email_queue_recipients table to attach a foreign key to every recipient record so that it will get deleted when an email is done sending.

 

You are welcome! 🙂

How to Setup Let’s Encrypt FREE SSL Certificate on Centos 6 Apache using Certbot?

Having SSL on your website these days is important especially if you want your website to rank better on Google search, and that’s when Let’s Encrypt come into the picture.

Let’s Encrypt is a free, automated, and open certificate authority (CA), run for the public’s benefit. It is a service provided by the Internet Security Research Group (ISRG).

Without further ado, let’s begin with the tutorial.

Step 1: Install Certbot

Installing Certbot via certbot-auto script.

Step 2: Get Certificate & Edit Apache Config

It should bring you through a series of steps to have your SSL certificate setup.

Select the site you want to have SSL certificate installed on.

Step 3: Configure CRON Job for Cert Renewal

The following are commands to renewal your SSL certificate.

Dry Run

Actual Command

Add actual command to crontab.

Enter :i and paste the following in the file following by ctrl+c and :wq to quit and save editor.

 

That’s it all is done.

Palm Resting on Trackpad Issue While Typing in New Apple Macbook 2016

Simply run this command in your terminal.

References

https://discussions.apple.com/message/30217312#30217312

8 Simple Steps to Setup a Web Server with Apache Virtual Hosts & MySQL in Centos

This tutorial will be guiding you in setting up a web server with pre-installed Centos. In summary, you will be installing Apache and MySQL, and learning how to configure virtual hosts in Apache.

Note: before proceeding with this tutorial. Make sure you figure out how to SSH into your server first.

Step 1: Update Centos

Step 2: Install development tools on Centos

Step 3: Install some useful tools

mlocate – This is used to assist you in looking for files in Centos. You will see it in action later.

nano – This a text editor in Centos that is much easier to use than vi or vim.

Step 4: Install Apache

Step 4.1: Install Apache

Step 4.2: Start Apache service

Step 4.3: Set Apache to run on server boot/restart

Step 5: Install MySQL

We are going to install MySQL 5.5 here.

Step 5.1: Add repos and install MySQL 5.5

Step 5.2: Start MySQL service

Step 5.3: Configure MySQL

After running the above command, you will get a bunch of prompts.

  1. Simply hit enter on initial root password prompt as we don’t have any yet from a fresh installation.
  2. Enter your new password for root user.
  3. Simply enter “y” = yes for the remaining options.

Step 6: Set Timezone for server

In the above command, I have set the timezone to Singapore, simply because I’m from Singapore. Feel free to change it to your own timezone.

Step 7: Install SSL support

This will enable SSL support on your web server if you wish to add your own SSL certificate here in future.

Step 8: Setup Virtual Host on Apache

Before proceeding, now we can use mlocate which we have installed previously.

Running the above command sort of index the files in your server for mlocate to work.

Use mlocate to look for Apache’s configuration file.

You should be getting something like this, “/etc/httpd/conf/httpd.conf”.

So now we can make use of nano that we have installed previously.

The above will allow start editing of Apache configuration file.

Step 8.1: Editing Apache Configuration

  1. Hit ctrl+w and type “/var/www” and enter
  2. Change DocumentRoot “/var/www/html” to DocumentRoot “/var/www”
  3. Hit ctrl+w again
  4. Change <Directory “/var/www/html”> to <Directory “/var/www”>
  5. Hit ctrl+w again and type “AllowOverride None” and enter
  6. Change AllowOverride None to AllowOverride All
  7. Hit ctrl+w again and type “NameVirtualHost *:80” and enter
  8. Change #NameVirtualHost *:80 to NameVirtualHost *:80
  9. Add one more line below it, NameVirtualHost *:443
  10. Then hit ctrl+v multiple times till you reach the end of the document

Do not close the file yet.

So what you have done above is doing some basic configuration to Apache for virtual host to work.

Now we need to setup virtual host in Apache configuration.

Below is a sample virtual host configuration.

Notice that “tutorial.mervintan.com” is the subdomain/domain you are trying to configure. So simple just change all occurrence of that to your own subdomain/domain.

To proceed, paste that at the end of Apache configuration file.

To finish editing Apache configuration file.

Hit ctrl+x and enter.

Last step, restart Apache.

Step 8.2: Setup directories and files for a Virtual Host

Remember that we set our Apache document root to “/var/www” above.

Navigate to that directory now.

Create virtual host directory for your subdomain/domain.

Get into the folder.

Create error and requests log files.

Create folder to host files for this virtual host.

Inside public_html folder, this is where you should place all your .html, .js and .css files for hosting.

Step 8.3: Setting permission for hosting directory

This will set Apache to be owner of those folders you have just created.

Step 8.4: Flush iptables

Flushing iptables will remove all firewall records on your server. Then you will be able to access your site.

Finishing Up

If you remember we setup the virtual host for “tutorial.mervintan.com”. Do remember to setup your DNS record that points “tutorial.mervintan.com” to your server ip address.

That’s it you are done!

How to create Apache htpasswd file in Linux OS?

What is htpasswd?

At times during web development, we will need to prevent the whole world from being able to access a particular website. That’s when Apache htpasswd comes into the picture. htpasswd is usually used together with htaccess.

Tutorial

This tutorial will teach you how to create a htpasswd file using command line.

Creating a htpasswd for the first time

Example

Appending new user to existing htpasswd file

Example

Using htpasswd in htaccess

 

That’s it you are done!

How to install Cocoapods for Objective-C/Swift development on Mac OS?

Steps to install Cocoapods

Cocoapods is used in Xcode IDE for development from iOS apps using Objective-C/Swift. Cocoapods helps developers add external libraries to their iOS project easily. The following tutorial guides you on the steps to install Cocoapods on your Mac in order to make use of its features.

Step 1

Step 2

Step 3

You should see the message “1 gem installed“.

Step 4

You should be done if you never encounter any errors along the way.

(Optional) Step 5

Running the above command will show you your current pod version.

That’s it!

Cross Origin Resource Sharing (CORS) Blocked for Cloudfront

Cross Origin Resource Sharing is a very common issue faced.

You will usually get the message like the following.

Font from origin ‘https://k3j3jd3k2j.cloudfront.net’ has been blocked from loading by Cross-Origin Resource Sharing policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘https://www.mervcodes.com’ is therefore not allowed access.

There are two ways to resolve this issue.

Solution 1: S3 Bucket Way

This is the most common solution, which is to set the CORS header in your S3 bucket.

http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html

 

Solution 2: DNS Way

Step 1

Create a subdomain like

instead of using

Step 2

Create a CNAME record that points

to

 

That’s it. You are done!

How to Install Vesta CP on CentOS 6.8 VPS from DigitalOcean?

What is VestaCP?

VestaCP is a web-based control panel for you to manage your server. In fact VestaCP is a much lightweight version of the famous cPanel, which will cost you a bomb. VestaCP is open source, which means its FREE.

Apart from being free, there are commercial plugins available on VestaCP, which are actually quite useful to a certain extend.

There are two commercial plugins that are available for purchase. The good news here is that they are available in lifetime license. You can see them at the image below.

VestaCP Commercial Plugins - MervCodes
VestaCP Commercial Plugins – MervCodes

Without further delay, lets begin with the technical stuffs.

How to install VestaCP?

1. First thing to do is to download VestaCP installation script.

2. Run the installation script

Simply hit “y” for everything except filling up of your FQDN and admin email address.

3. Finally

When the installation completes, you should receive an email at the inbox of the admin email address that you entered previously.

4. [Optional] Upgrade default PHP 5 to PHP 7

In case you want more speed for your PHP-Powered website, you can upgrade your PHP to PHP 7 by following the following guide.

https://www.mervcodes.com/upgrade-php-5-to-php-7-on-centos-6-7/

 

That’s it. You got yourself a lightweight web-based control panel for your server.