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! ūüôā

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!

Install OpenCart 2 on CentOS

This guide focuses on how to install OpenCart 2 on CentOS 6. Before proceeding with this guide, make sure your server have met the following requirements.

1. Download OpenCart

Download OpenCart 2 from the following link, http://www.opencart.com/?route=download/download.

Then unzip the downloaded package.

2. Upload OpenCart to server

Use any FTP client (FileZilla, Transmit, etc) to upload your OpenCart files that you have just unzip to the server.

After uploading the files, renaming the following files:

  • /config-dist.php to /config.php
  • /admin/config-dist.php to /config.php

Note: For Apache servers, the directory that you are to upload to is /var/www/.

3. Enable file read/write permissions

Modify the file read/write permissions for the following files/directories:

  • /var/www/store/config.php
  • /var/www/store/admin/config.php
  • /var/www/store/system/cache/
  • /var/www/store/system/logs/
  • /var/www/store/system/download/
  • /var/www/store/system/upload/
  • /var/www/store/image/
  • /var/www/store/image/cache/
  • /var/www/store/image/catalog/
  • /var/www/store/system/modification/

Command to modify file read/write permissions

And one more additional command to run on image/cache directory

 

4. Begin Installation

Now head over to your web browser and access the following url.

5. Installation Step 1

OpenCart Installation Step 1
OpenCart Installation Step 1

Click on Continue to proceed.

6. Installation Step 2

OpenCart Installation Step 2
OpenCart Installation Step 2

If you have followed the previous steps correctly, then you should see all green ticks and all files/directories status are labelled as Writable.

Click on Continue to proceed.

7. Installation Step 3

OpenCart Installation Step 3
OpenCart Installation Step 3

Fill up your database connection details and an account for administration.

Then click on Continue to proceed.

8. Installation Step 4

OpenCart Installation Step 4
OpenCart Installation Step 4

That’s it! You have successfully setup an E-Commerce store online for yourself.

Feel free to drop me an email at [email protected] or leave a comment if you have any questions.

Install Zabbix Agent on CentOS/RHEL

Zabbix is an open source software for application and network monitoring. There are two types of Zabbix installation, namely Zabbix server and Zabbix agent. Zabbix server is installed on the server where you will oversee and monitor all the networks or devices. Zabbix agent is installed on all networks or devices so that the Zabbix server is able to communicate with it.

This tutorial guides you step by step on how to install and configure a Zabbix agent on CentOS/RHEL server.

Installing Zabbix Agent

1. Configure Yum Repository

Run the following commands accordingly to the version of CentOS/RHEL you are using.

CentOS/RHEL 7

CentOS/RHEL 6

CentOS/RHEL 5

2. Install Zabbix Agent

Command to install Zabbix agent

3. Update Zabbix Agent Configuration File

Your Zabbix agent configuration file should be located at /etc/zabbix/zabbix_agentd.conf.

Edit configuration file

Modify the following lines

Save and exit nano editor

4. Restart Zabbix Agent

Command to restart Zabbix agent

(Additional Information) Alternately, you can start/stop your Zabbix agent via the following commands.

 

That’s it! You are done installing Zabbix agent¬†on your server.

In case you have missed out on how to install Zabbix server on your server, you can refer to the guide on how to install Zabbix server on CentOS/RHEL.

Feel free to email me at [email protected] if you have any questions.

Install Zabbix Server on CentOS/RHEL

Zabbix is an open source software for application and network monitoring. There are two types of Zabbix installation, namely Zabbix server and Zabbix agent. Zabbix server is installed on the server where you will oversee and monitor all the networks or devices. Zabbix agent is installed on all networks or devices so that the Zabbix server is able to communicate with it.

This tutorial guides you step by step on how to install and configure a Zabbix server on CentOS/RHEL server.

1. Set up Apache, MySQL and PHP

Install Apache

Install MySQL

Install PHP

Start Apache and MySQL services

Setup MySQL by running the following command

2. Configure Yum Repository

RPM repository needs to be configured before installing Zabbix.

Run the following commands according to the version of OS that you are using.

CentOS/RHEL 7

CentOS/RHEL 6

CentOS/RHEL 5

3. Install Zabbix Server with MySQL

Command to install zabbix server

4. Setup Zabbix Apache Configuration

Locate Zabbix’s own Apache configuration file. By default it should be located at¬†/etc/httpd/conf.d/zabbix.conf.¬†Modify the config file by added your time zone.

Added time zone to config file

Restart Apache service after changing the time zone value

5. Create Zabbix MySQL Database

Zabbix MySQL user and database is required as part of Zabbix server installation.

Login to your MySQL first

After which you will be prompt to enter your root password that you have configured previously when you setup MySQL.

Create Zabbix database

Create Zabbix MySQL user to access Zabbix database

Grant privileges to Zabbix user on Zabbix database

Flush privileges

Exit MySQL

After creating MySQL user and database for Zabbix, you will need to restore the default MySQL database provided by Zabbix. The files can be found at /usr/share/doc/zabbix-server-mysql-<version>/create/ directory.

Note: remember to change the version accordingly to the version that you are installing.

6. Start Zabbix Server

Command to start Zabbix server

7. Start Zabbix Web Installer

You can now access your Zabbix web installer via the following url

Zabbix Setup Welcome Screen

Following is the welcome screen of Zabbix web installer. Click on Next to proceed.

Screen Shot 2015-08-15 at 11.55.34 am

Installation pre-requisites

If everything is ok, click Next to proceed.

Screen Shot 2015-08-15 at 11.57.54 am

Configure Database Connection

Enter the database information that you have created previously. Then click on Test Connection. If everything is correct, click Next to proceed.

Screen Shot 2015-08-15 at 12.00.35 pm

Zabbix Server Details

Click on Next to proceed.

Screen Shot 2015-08-15 at 12.01.46 pm

Pre-Installation Summary Screen

If all information is correct, click on Next to proceed.

Screen Shot 2015-08-15 at 12.12.48 pm

Installation Success

Click on Finish to proceed.

Screen Shot 2015-08-15 at 12.03.40 pm

Zabbix Login Screen

You can now login to Zabbix via the following url

Default username and password is as follows

Screen Shot 2015-08-15 at 12.15.08 pm

 

 

That’s it! You are done installing Zabbix server on your server.¬†For installation of Zabbix agent, you can refer to my guide on how to install Zabbix agent on CentOS/RHEL.

Feel free to email me at [email protected] if you have any questions.

Create New User and Grant Permissions in MySQL

MySQL is an open source relational database management software. It helps to store, organise and retrieve data. MySQL has a feature for you to create users to manage different databases or tables with certain permissions.

MySQL Permissions

The different types of permissions available in MySQL are as follows.

[su_table]

Permission Description
ALL PRIVILEGES allows user to perform all the following permissions on tables or databases
CREATE allows user to create tables or databases
DROP allows user to delete tables or databases
DELETE allows user to delete rows from tables
INSERT allows user to insert rows to tables
SELECT allows user to retrieve rows to tables
UPDATE allows user to update rows to tables
GRANT OPTION allows user to grant or remove other users’ privileges

[/su_table]

How to create a new user

Before being able to run any of these commands, you will have to login to your MySQL first, which usually we will use root to login at command line.

It should prompt you to enter your root password for MySQL. After that, you will be logged into your MySQL.

Command to create a new user

  • new_username – username of user
  • localhost – location in terms of ip address of MySQL to create user at
  • password – password for user to login to MySQL

After creating a new user in MySQL, we need to give the user permissions in order for the user to do anything.

  • new_username – username of user created previously
  • localhost – location in terms of ip address of MySQL where user was created at previously

Once you are done with the two commands above, you need to reload the permissions for MySQL.

 

That’s it! You are all set.

Feel free to drop me an email at [email protected] if you have any questions.

Install and Secure phpMyAdmin on CentOS 6.4

PhpMyAdmin is a popular web interface for web developers to manage MySQL databases. This tutorial will guide you through on how to install and secure PhpMyAdmin on your CentOS web server.

Pre-requisites

This guide assumes that you already have Apache and MySQL installed on your CentOS web server.
(Optional) Note that if you want to access PhpMyAdmin using SSL, then you will need to configure SSL certificate by referring to the following guide.

Setting up an SSL Secured Web Server with CentOS

1. Add EPEL Repositories

PhpMyAdmin is not included in CentOS packages, therefore you will need to add EPEL (Extra Packages for Enterprise Linux) to your web server.

(Optional) Run the following command to install wget if you haven’t install wget yet

Command to install EPEL packages to your web server

Check that EPEL has been added to your repository

You should see the following

Once done remove the respository configuration package

2. Download PhpMyAdmin

Command to download PhpMyAdmin

3. Configure PhpMyAdmin

Find your IP Address first
Then edit PhpMyAdmin config file

Modify the following 4 lines in the config file

Then save and close the config file

4. Open PhpMyAdmin in your Web Browser

Open the following url in your web browser

 

That’s it you are done!

Feel free to contact me at [email protected] if you have any questions.