Installing module programmatically in Drupal 7 can be achieved with just one step, using module_enable function.
Source code viewer
// Array of module machine names. // Whether or not to enable dependant modules. $dependencies = TRUE; module_enable($modules, $dependencies);Programming Language: PHP