Friday, July 25, 2014

Deploy PHP Application Using Capistrano 2.15

Deployment With Capistrano:

We can also deploy php app using ruby gem capistrano. For this we have to install it first on our system.

gem install capistrano -v 2.15.5
gem install railsless-deploy

After that on any place we have to initialized it. For this use:

capify .


It will create following two files

config/deploy.rb
Capfile

Add in the Capfile

require 'railsless-deploy'
load 'config/deploy'
Now edit the deploy.rb

  1. set :application, "App name"
  2. set :repository, "https://username:password@yourrepository.org/project-repository.git"
  3. set :user, 'shh_username'
  4. set :scm, :git
  5. set :normalize_asset_timestamps, false
  6. set :deploy_to, "/full/path/to/your project"
  7.  
  8. set :deploy_via, :copy
  9. set :use_sudo, false
  10. set :copy_exclude, [".git", ".DS_Store", ".gitignore", ".gitmodules", "Capfile", "config/deploy.rb"]
  11.  
  12. server "server name", :app
  13. namespace :myapp do task :restart_webserver do #Show Start of Task print "Restarting webserver..." # Restart Web Server run "#{sudo} service apache2 restart" end end after "deploy","myapp:restart_webserver"

We can also use deply_via:remote_cache.

Now setup deploy and then execute it.



cap deploy:set
cap deploy

It will create three folders on root
project_root/releases
project_root/shared
project_root/current
 

Friday, July 18, 2014

Moving Magento Website to another server

For Moving Magento Website:

Procedure for moving website:

1. Install Apache, MySql, PHP to new server

2.Take all the back up of code and database from previous server and put it on new server.

3. Now go to the table core_config_data and update coulmn where path web/unsecure/base_url and web/secure/base_url and value to your new website end with '/'.

4. Now edit app/etc/local.xml edit file according to your database configuration.

Its done.

Points Should Be Remind:

 There should be .htaccess file on the root and it should be same as the previous server file.

Problems Occurs:

Mostly there are some problems occurs due to server migration.

Main problem is "404 Error Page Not Found"

For this there are two solution.

1. Configuration of .htaccess file should be correct.

2. /etc/apache2/sites-enabled/000-defualt.conf file configuration should be correct and also there should be following thing:

<Directory /var/www/html>
     AllowOverride All
    Order Allow,Deny
    Allow from all
    Require all granted
</Directory>


Friday, July 4, 2014

Codeigniter Code Tricks

Codeigniter Code Tricks:


1) There is an optional second parameter in $this->uri->segment()

We can find second parameter in a url by this code

$robot $this->uri->segment(3); 


There is an optional second parameter that permits you to set your own default value if the segment is missing.

$robot $this->uri->segment(3'calculon');  


2) Any library can have a configuration file

<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');



$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp1.mailserver.ca';
$config['smtp_user'] = 'username';
$config['smtp_pass'] = 'password';
$config['smtp_port'] = '25';


3) View’s can be returned as data with a third parameter

$page $this->load->view('view'$dataTRUE);$pdf build_pdf($page);
// OR
$this->load->helper('download');$view_data $this->load->view('xml_template'$dataTRUE);
force_download($data['page_title'].'.xml'$view_data);