How to create a virtual host in ubuntu?

On July 10, 2011, in LAMP, Linux, Tips, Tricks, Ubuntu, by phpsolutions

For create a virtual host in ubuntu please follow the below step by step process.

Virtual host name is : “local.dating”
Document root for that virtual host : “/var/www/dating”

1. Create a file with name of your virtual host(name you want for your virtual host like “local.dating”) on “/etc/apache2/sites-available/”.

2. Write the following code on that file :

/*******************************************************************/

#
# local.dating
#

ServerName local.dating
#ServerAlias www.sitename.com
DocumentRoot /var/www/dating
CustomLog /var/log/apache2/local.dating-access.log combined
ErrorLog /var/log/apache2/local.dating-error.log

/*******************************************************************/

3. Now you have to enable this virtual host. To do so please go to your terminal and type following command

sudo a2ensite local.dating

To disable a virtual host use following

sudo a2dissite local.dating

where local.dating is the name of the virtual host you want to enable/disable.

4. Now apache is almost ready to restart, but before doing so, we must inform our linux system that dev.example.com and www.dev.example.com are not to be looked for on the net, but on the local machine instead.
To do so, simply edit “/etc/hosts” and add the new host names at the end of the line beginning by 127.0.0.1, which is localhost like below :

127.0.0.1 local.dating

5. And now we are done, simply reload apache by following command :

sudo /etc/init.d/apache2 reload

Open your web browser and enter the following address local.dating. Magic, it runs the same as when you were using http://localhost/dating but it is far more usefull when devellopping a web service and want to be able to develop applications on your machine just like it is where the real web site.

Tagged with:  

You should now configure the sources for apt.Once that’s done you can upgrade your system to get the latest updates.

  1. $ sudo -s
  2. $ aptitude update
  3. $ aptitude upgrade

You can also do the other steps on this page to configure the network, ssh etc.Only difference is that I prefer aptitude over apt-get since it’s apparently better with dependencies….

Now we’re ready to install the software needed by SugarCRM:

  1. $ aptitude install php5-imap php5-curl unzip

And set the right permissions….

  1. $ chmod -R 777 /var/www/sugarcrm
  2. $ chmod -R 777 /var/www/sugarcrm/cache
  3. $ chmod -R 777 /var/www/sugarcrm/custom
  4. $ chmod -R 777 /var/www/sugarcrm/data
  5. $ chmod -R 777 /var/www/sugarcrm/modules
  6. $ chmod -R 777 /var/www/sugarcrm/config.php

Now we have to edit the default php.ini for SugarCRM, so open it in your favorite editor.The path to the php.ini file is: /etc/php5/apache2/php.ini

  1. $ nano -w /etc/php5/apache2/php.ini

Find : allow_call_time_pass_reference = On
Change : allow_call_time_pass_reference = Off
Find : memory_limit = 8M
Change : memory_limit = 32M
Find : upload_max_filesize = 2M
Change : upload_max_filesize = 10M

And finally we restart apache for the changes to take effect.

  1. $ /etc/init.d/apache2 restart

That’s it, you should now be able to go to the web installer of SugarCRM.Just point your browser to http://server-ip-address/(sugar crm directory)/ which should automatically load http://server-ip-address/(sugar crm directory)/install.php

And go on…

PHP have rich set of functions to solve real time problems in programming and web development.. thanks to Rasmus Lerdorf

eval — Evaluate a string as PHP code

A SET datatype can hold any number of strings from a predefined list of strings. The ENUM datatype restricts to a single member of the set of predefined strings, the SET datatype allows to store any of the values together, from none to all of them.

CREATE TABLE phpsolutions_set (

name SET(’lamp’,’web’,’linux’,’joomla’)

);

CREATE TABLE phpsolutions_enum (

name ENUM(’lamp’,’web’,’linux’,’joomla’)

);

If we want to fill the html select box with these two tables…

SHOW COLUMNS FROM phpsolutions_set;

> set(’lamp’,’web’,’linux’,’joomla’)

SHOW COLUMNS FROM phpsolutions_enum;

> enum(’lamp’,’web’,’linux’,’joomla’)

now based on column type set list of string values from mysql to php array…

<?php

…….

// if column type is set

$arr = “\$set=”.str_replace(”set”, “array(”, $column[‘Type’]));

eval($arr);

// if column type is enum

$arr = “\$set=”.str_replace(”enum”, “array(”, $column[‘Type’]));

eval($arr);

…………..

?>

Use $set PHP array to fill select box….

Geocoding (finding latitude/longitude for street addresses), Geotagging (tagging media with latitude/longitude coordinates), and Geolocation (finding latitude/longitude of computer with IP X-Forwarded-For). There are some options to install on linux environment:

# wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
# gunzip GeoLiteCity.dat.gz
# sudo mkdir -v /usr/share/GeoIP
# sudo mv -v GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat

Install geoip with php5
# sudo apt-get install php5-geoip (ubuntu)

# sudo yum install php5-geoip (centOS)

# sudo pecl install geoip (with PECL)

In Windows environment we have to add extension “php_geoip.dll” with PHP

Download extension from here : http://blog.phpsolutions.co.in/php-5.2.1_geoip-w32.zip

Copy “php_geoip.dll” to xampp “php/ext” .. add a line in php.ini
“extension=php_geoip.dll” and restart xampp

This extension will work on development system using Windows, Apache 2.2.3 and PHP 5.2.10.
We can
check “geoip” with phpinfo() module is loaded.

<?php
$record
= geoip_record_by_name('www.phpsolutions.co.in');
if (
$record) {
print_r($record);
}
?>

Array
(
    [country_code] => US
    [region] => CA
    [city] => Marina...
    [postal_code] =>
    [latitude] => 23.9776792798
    [longitude] => -128.435796741
    [dma_code] => 867
    [area_code] => 400
)

<?php
$result = geoip_record_by_name('78.aaa.yyy.xxx');
var_dump($result);
?>

There is alternative PHP version of the GeoIP API from MaxMind,
but this solution is quite slow on servers. MaxMind uses MaxMind database to display geo locations.

How to run cronjobs per second?

On August 21, 2010, in CentOS, Fedora, Linux, Tricks, by phpsolutions

Have you checked my previous article on cronjobs…

http://blog.phpsolutions.co.in/tag/crontab-command-line/

To run cronjob per second you have to execute crontab/cronjob per minute and then have to run task in cron file per second using PHP function time_sleep_until().

<?php

$start = microtime(true);

for($ii=0;$ii<60;$ii++)
{

//……………………….

/// here is the tasks which need to run per second…

//……………………….

time_sleep_until($start + $ii + 1);
} // end for

if (!function_exists(‘time_sleep_until’))
{
function time_sleep_until($future)
{
if ($future < time())
{
trigger_error(“Time in past”, E_USER_WARNING);
return false;
}

usleep(($future – microtime(1))*1000000);
return true;
}
}

?>

Tagged with:  

I think everyone know about google language translation

We can use http://www.wibiya.com/ to translate webpage/blog content in worlds very known languages

Add the free Google Translate gadget to instantly translate your webpage or blog into other languages: English, Afrikaans, Albanian, Arabic, Armenian, Azerbaijani, Basque, Belarusian, Bulgarian, Catalan, Chinese, Croatian, Czech, Danish, Dutch, Estonian, Filipino, Finnish, French, Galician, Georgian, German, Greek, Haitian Creole, Hebrew, Hindi, Hungarian, Icelandic, Indonesian, Irish, Italian, Japanese, Korean, Latvian, Lithuanian, Macedonian, Malay, Maltese, Norwegian, Persian, Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovenian, Spanish, Swahili, Swedish, Thai, Turkish, Ukrainian, Urdu, Vietnamese, Welsh, Yiddish….

Other translation tools
http://babelfish.yahoo.com/
http://www.microsofttranslator.com/
http://www.systran.co.uk/

CakePHP vs YII

On August 8, 2010, in CakePHP, Open Source, PHP, Tips, Tricks, Web Application, by phpsolutions

Have you checked my previous article on CakePHP…

http://blog.phpsolutions.co.in/2009/11/cakephp-in-phpsolutions/

Yii (Yes, it is) — a high-performance component-based PHP framework best for developing large-scale Web applications. Yii have features, including MVC, DAO/ActiveRecord, I18N/L10N, caching, jQuery-based AJAX support, authentication and role-based access control, scaffolding, input validation, widgets, events, theming, Web services, and so on. Written in strict OOP, Yii is easy to use and is extremely flexible and extensible.

YII Features:

– Magic overloading functions
Lazy loading
– Authentication / Validation
– Widgets (sharing extensions)
– Yii console
– High-performance
– Templates
MVC Push-Pull
RBAC
– Test Case (PHPUnit, Selenium)
EAccelerator
– jQuery
– Zend support

I am currently reviewing YII in comparison with CakePHP … Keep in touch 🙂

Framework vs CMS

On June 19, 2010, in CakePHP, Joomla, PHP, Tips, Tricks, by phpsolutions

Framework: A web application framework is a software framework that is designed to support the development of dynamic websites, Web applications and Web services.

1. CodeIgniter
2. CakePHP
3. Zend
4. Symfony

CMS: A content management system (CMS) is the collection of procedures used to manage work flow in a collaborative environment. These procedures can be manual or computer-based.

1. Joomla
2. Drupal
3. Magento
4. CRE Loaded Oscomerce
5. WordPress

Tagged with:  

LAMP Developer Skills

On June 12, 2010, in Tips, Tricks, by phpsolutions

Here are some basic skills an ideal developer have for growing business….

Technical Skills:

Should have relevant experience on developing and programming interactive applications and websites.
* Should have Customized & developed modules for Oscommerce and Joomla.
* Should have Integrated Custom shipping and Payment Modules.
* Design database and coordinate the UI design.
* Exposure to open source platforms like Drupal, Magento, Moodle, Word Press, V bulletin etc.
* Must have Handled API integrations
* Strong knowledge of web & internet technologies, Skills like LAMP,PHP5, OOP, MySQL, AJAX, CSS, HTML/XHTML standards, CSS, JavaScript (including JSON), JQuery, Prototype & Document Object Model Linux, Web Services, MySQL, Apache, XML MVC Frameworks CakePHP

Required Skills:

* Proficient in Drupal,solid coding abilities within the Drupal framework including custom module development, key contributed modules and the core API
* Proficient in PHP, ideally within a GNU/Linux, Apache, MySQL environment.
* LAMP, PHP, mySQL, CSS, Javascript, jQuery, JPath, JSON
* file system, Bitcache, IMCE, Views, Blocks, CCK, Date, Menus, Roles, I18N, L10N
* Proficient in SQL, relational databases and MySQL; skill with tools like phpMyAdmin and the mysql CLI
* sophisticated scripting; complex database queries and construction of hybrid Views
* database administration, including configuration of shared tables
* Proficient in JavaScript and familiar with major JavaScript libraries
* Proficient in the maintenance and administration of Drupal modules and sites
* light server administration, in conjunction with team of network engineers
* site scaling and performance optimization, in conjunction with team of network engineers
* Proficient in hand-coding HTML and tableless CSS
* Thorough understanding and proven implementation of W3C Web Standards
* Experience in GNU/Linux administration
* Experience integrating free software and third party applications into existing systems
* The ability to work within existing infrastructures
* module installation, patching and upgrades, with a focus on security
* strong theming abilities; up-to-date grasp of base themes and best practices
* Ability to work as part of a team, understanding problems from another team member’s perspective, and, when necessary, go above and beyond the job description to work towards a broader team goal

Additional Assets:

* Involvement in and contributions to the Drupal community
* Familiarity with revision control systems such as CVS and Subversion
* Experience enhancing the performance of high*traffic sites
* Experience with AJAX or jQuery
* Experience in working with other frameworks like Zend, cake, codeigniter
* Exposure of various stages of Application Lifecycle Development
* Zend Certified Engineer 5, Zend Certified Zend Framework Engineer
* MySQL Certified Developer
* Debugging skills

Tagged with:  

RESTClient is an application use to visit and test RESTful services.

REST (Representational State Transfer) is the model of the Web to consume web resources. The browser makes a request to a URL and receives a response.  The request may be a GET or POST (or a PUT, DELETE, or HEAD) and the response may be anything HTML, Image file, PDF, XML, JSON etc.

Some RESTful Web Services…

http://www.flickr.com/services/api/

http://code.google.com/p/a2zvideoapi/

RESTClient extension: https://addons.mozilla.org/en-US/firefox/addon/9780