Top 10 magento trouble shooting after transferring to a new server

Standard

1. Make sure there is nothing in the cache directory in new location of magento:
Execute the following command from inside magento root directory,

rm -rf var/*

2. Set proper folder permissions:
Enter the following commands one by one,

chmod o+w var var/.htaccess app/etc
chmod -R o+w media

Also make sure all folder permissions are set to 755 and file permissions to 644

3. Site is loading till the header part only, No other content below it:
Install GD Library

sudo apt-get install php5-gd

4. Admin panel not working after logging in:
Install CURL extension

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

5. SEO friendly URL not working:
Install/enable rewrite module on Apache,

sudo a2enmod rewrite

6. Ajax [Add to Cart] pop up not showing on product detail page:
Turn [Merge Javascript] option to, “No” from magento admin panel.

7. Admin panel showing message for miss configuration of server:
A. Checkout whether .htaccess is being considered properly or not, also make sure any apache module specific command that is in that file is working. Check whether those modules are installed/enabled in the server.
B. Add/Update virtual host OR apache configuration file to allow over ridding by putting this line

AllowOverride All

8. Crontab is working but price rules are resetting:
Empty the [cron_schedule] table from the database to remove all dead locked and garbaged schedules. Don’t worry, this table will populate data again according to new cron schedules.

9. Changed main domain OR site address?:
Access the table [core_config_data] and edit two fields [web/unsecure/base_url] [web/secure/base_url] under the [path] column to the new domain/web address.

10. Want to reset admin password?:
Run the query from inside new server after connecting to mySQL,

UPDATE admin_user SET password=CONCAT(MD5('NEWPASS'), ':NE') WHERE username='ADMINUSERNAME';

Change NEWPASS, NE, ADMINUSERNAME to your wish.

Laravel4 Migrations and Seeding

Standard

So far we have created the virtual host for our laravel4 application named “thisdayinbangladesh.dev” and also set up the basic laravel4 installation. Now in this lesson we will create the migrations and seeders needed for our application.

“Migrations are a type of version control for your database. They allow a team to modify the database schema and stay up to date on the current schema state. Migrations are typically paired with the Schema Builder to easily manage your application’s scheme.”

“Laravel also includes a simple way to seed your database with test data using seed classes.”

First thing first. Open up the Mac Terminal and enter inside the “thisdayinbangladesh” folder under MAMP’s “htdocs” directory. All of the following commands should be executed from inside the project folder.

Create migration files for all of our currently needed tables:
Execute these commands one by one,

php artisan migrate:make create_days_table --table=days --create
php artisan migrate:make create_facts_table --table=facts --create
php artisan migrate:make create_types_table --table=types --create
php artisan migrate:make create_fact_type_table --table=fact_type --create

These commands set up the basic migration scripts that we’ll be using to create the database tables

Update the migration files:
Edit “database/migrations/TODAYS_FULL_DATE_create_days_table.php” file and update the “up()” method to include a new column on the “days” table and to remove the “timestamp” column.

	public function up()
	{
		Schema::create('days', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('day');
		});
	}

Update the “up()” method of “database/migrations/TODAYS_FULL_DATE_create_facts_table.php” file to the following,

	public function up()
	{
		Schema::create('facts', function(Blueprint $table)
		{
			$table->increments('id');
                        $table->integer('day_id');
			$table->string('title');
                        $table->longText('description');
                        $table->timestamps();
		});
	}

Update the “up()” method of “database/migrations/TODAYS_FULL_DATE_create_types_table.php” file to the following,

	public function up()
	{
		Schema::create('types', function(Blueprint $table)
		{
			$table->increments('id');
                        $table->string('type');
		});
	}

Update the “up()” method of “database/migrations/TODAYS_FULL_DATE_create_fact_type_table.php” file to the following,

	public function up()
	{
		Schema::create('fact_type', function(Blueprint $table)
		{
			$table->increments('id');
                        $table->integer('fact_id');
                        $table->integer('type_id');
		});
	}

Prepare the Seeder files to add sample data to those tables:
Create a file within the “app/database/seeds” folder that has the same name as the table. So, for our “days” table create a file named “DayTableSeeder.php” inside “seeds” folder containing the following full code,

<?php 
class DayTableSeeder extends Seeder {
 
    public function run()
    {        
        for ($i = 1; $i <= 31; $i++) {
            for ($j = 1; $j <= 12; $j++) {
                Day::create(array(
                    'day' => sprintf("%02s", $i).'-'.sprintf("%02s", $j)
                ));             
            }
        }

    }
 
}

Here I am inserting some “day-month” patterned days rows in the “days” table using a simple loop. Please, don’t judge my PHP knowledge on this. This is not about showing optimized, minimal, smell free coding.
Also, create other seeder files for those remaining tables into which we want to push some sample data even before launching the app.
Create “FactTableSeeder.php” with following code. Here we are inserting some sample facts that holds the fact’s sample title and sample description just for checking out data retrieval with proper relations later on the next lesson.

<?php
 
class FactTableSeeder extends Seeder {
 
    public function run()
    {        
        for ($i = 1; $i <= 372; $i++) {
                Fact::create(array(
                    'day_id' => $i,
                    'title'   => 'Fact-'.$i,
                    'description' => 'Description of fact-'.$i,
                ));
        }

    }
 
}

Now create the “TypeTableSeeder.php” file with the following code,

<?php
 
class TypeTableSeeder extends Seeder {
 
    public function run()
    {        
        $types = array ('good', 'bad', 'revolutionary', 'birth', 'death');
        
        foreach ($types as $key=>$value) {
                Type::create(array(
                    'type' => $value,
                ));
        }

    }
 
}

And finally create the “FactTypeTableSeeder.php” file with,

<?php
 
class FactTypeTableSeeder extends Seeder {
 
    public function run()
    {        
        for ($i = 1; $i <= 10; $i++) {
            FactType::create(array(
                'fact_id' => $i,
                'type_id' => rand(1,5)
            ));             
        }

    }
 
}

As you can see, we are assigning some “facts” to some “types” and making rows in the “fact_type” table pairing “fact_id” with “type_id” as for our sample data.

Update the DatabaseSeeder file:
Update the “run()” method of the “DatabaseSeeder.php” file. That should already be there inside “app/database/seeds” folder with the following code,

	public function run()
	{
		Eloquent::unguard();

		$this->call('DayTableSeeder');
                $this->call('FactTableSeeder');
                $this->call('TypeTableSeeder');
                $this->call('FactTypeTableSeeder');
	}

Run Migration and Seed:
Execute the following commands one by one.

php artisan migrate
php artisan db:seed

If the commands executed successfully then you should see those tables along with an extra tables named “migrations” under your “thisdayinbangladesh” database. Also there should be our sample data in each table if the Seeding happens successfully!

Note:
As one “fact” will have multiple “types” and vise versa. You should name the Pivot table (“fact_type” in this case) of the “facts” and “types” table by taking the singular name of the alphabetically first table then the second table with an underscore in the middle.
Also there should be two columns at least, to hold the relation which should be named by taking the singular name of one table with its primary key along with an underscore in the middle. Such as “fact_id”, “type_id”.
But wait, don’t be scared. There is still flexibility while naming those tables and columns for using with Eloquent ORM. You will have to just pass those non-conventional table names or column names as parameters in corresponding methods while creating ORM relations among tables or while creating migrations tables.
We just followed the conventional naming pattern in this lesson to make thing simple and understandable.

What next?:
The next step is to make proper Routing for our application. Which is ready now!

Installing Laravel4 in Mac OSX with MAMP

Standard

Re-cap:
In the past and first tutorial of this series we learned how to create a virtual host with MAMP. In this second tutorial, we will install laravel4 PHP framework and will go another step toward developing a full laravel4 application series.

Precautions:

  • Make sure your installed PHP version is greater or equal to 5.3.7
  • Also make sure the MCrypt PHP extension is enabled
  • For pretty URL the mod_rewrite module is enabled on Apache

1. Install Composer Globally:

The following command will just check a few PHP settings and then download composer.phar

$ curl -sS https://getcomposer.org/installer | php

You can run these commands to easily access composer from anywhere on your system

$ sudo mv composer.phar /usr/local/bin/composer

2. Create a laravel project named “thisdayinbangladesh” inside our MAMP’s “htdocs” directory:

Going inside the “htdocs” directory

$ cd /Applications/MAMP/htdocs

Creating the project there

$ composer create-project laravel/laravel thisdayinbangladesh --prefer-dist

3. A small permission issue:

Lets enter into our project directory

$ cd thisdayinbangladesh/

Change the permission of the storage folder to writable

$ sudo chmod -R 0777 app/storage/

4. Basic Configuration:

Update line number 29 of the “app/config/app.php” file to

$ 'url' => 'http://thisdayinbangladesh.dev/',

and line 42 to

$ 'timezone' => 'Asia/Dhaka',

5. Database configuration:
Though configuring database is not necessary to have a first run but lets complete this step as we will not do any editing on the config files later.


'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'thisdayinbangladesh',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
 ),

6. Lets have a test run:

Open the URL of your laravel application as we created earlier using virtual host; on the browser. That is http://thisdayinbangladesh.dev/
You should arrive!

To Do List After Launching a New Linux/Unix Like Server for Development

Standard

Commands, tricks & cautions that will be used here have been tested only on a Ubuntu 12.04 VPS. Though, most of the commands should work in other Unix like system without any change.
In this lesson we will see how should a newly launched/opened server be configured for basic security & proper accessibility. Usually you get an IP address & a root password for logging in as root, as soon as you open a new cloud/vps server from rackspace/digitalocean or some others like these.

1. Connecting to the remote system through/using SSH:
SSH(Secure Shell) is a protocol used to securely loggin in to a remote system & also ssh is the tool used in Linux that connect to the remote server over the SSH protocol.

ssh root@123.45.67.890

The terminal will show a message and will prompt

....
Are you sure you want to continue connecting (yes/no)?

Type yes & press enter & then in next prompt enter your root password that was provided by that server provider while opening a VPS. So, now we are logged in to the remote system as root user.

2. Change your root user’s password:
You used the root password that was generated & provided by the server provider & the first thing is to change this password. Enter the following command on the terminal.

passwd

It will first ask the current root password & after entering the current password it will ask your desired new password twice for confirmation. Continue reading

Deploy apps on pagodabox with git version controlling

Standard

In the very last two posts we saw how to deploy apps in appfog. Today we will see how to deploy such apps in pagodabox. pagodabox is another deployment platform/framework like appfog. I found something good feature here such as you can have a free SSL certificate for your instance under the free scheme and you can see all your git commits under you app’s dashboard and simply deploy any version from your commit history just by clicking a button. Their punch line is “An Object Oriented Hosting Framework”

To start deploying your app on the cloud, just sign up in pagodabox obviously without any requirement of valid payment method as like appfog 🙂

Step A: You need to install the pagodabox command line tool just like you did for appfog according to the last post. For this, type the following command on Mac terminal:

sudo gem install pagoda

Ruby and RubyGems come pre-installed on Mac OSX. As long as you are running v10.6 or later. For windows or any other issue you can check here. Also you should add an SSH key of your local machine to your pagodabox account. Just follow this simple process. Continue reading

Authentication Module with E-mail & Image Verification!

Standard

I’ve built an authentication system which can be used as secured module in a registration form or in a suggestion box where there are probability of insertion of data by a robot script. By using the image verification fact no auto generated script can fill up a form. Other wise there is an e-mail verification fact by which the man who fill up the form giving his e-mail address should check up his inbox for the mail sent by the form.
The e-mail is sent with a link on which by clicking it executes a script for neccessary update in the database.

In this module when a user fill up the form then in database every data is inserted and in a filled named active ‘0’ is inserted. When the user clicks on the link sent to him by e-mail. It then executes another script page which then updates the value of active field into ‘1’.
Then you can verify a user by examining the value of his active field in database that ensures that he clicked on th link.
This can be used as module in any Webapp.

You can download the source code Download