Archive

Archive for October, 2008

Install and configure libssh2 and ssh2 PECL module with AMP on OpenSolaris

October 26th, 2008 Divyen Patel No comments

Detailed information on libssh2 and SSH2 PECL module is available on

libssh2 – http://www.libssh2.org/wiki/index.php/Main_Page

SSH2 PECL Module – http://pecl.php.net/package/ssh2


Installing AMP on OpenSolaris is quite easy. below are the
steps [1-4]
for AMP stack installation.

[ Step:1 ]

-bash-3.2# pkg refresh
-bash-3.2#

[ Step:2
]        

                 
 
-bash-3.2# pkg install amp
DOWNLOAD                                   
PKGS      
FILES     XFER (MB)
Completed                                 
13/13   1633/1633 331.59/331.59

PHASE                                       
ACTIONS
Update
Phase                                    
2/2
Install
Phase                             
2111/2111
-bash-3.2#

[ Step:3 ]

-bash-3.2# /usr/sbin/svccfg import
/var/svc/manifest/network/http-apache22.xml
-bash-3.2# /usr/sbin/svcadm enable http:apache22
-bash-3.2#

[ Step:4 ]

-bash-3.2# /usr/sbin/svccfg import
/var/svc/manifest/application/database/mysql.xml
-bash-3.2# /usr/sbin/svcadm enable mysql:version_50
-bash-3.2#

before we begin
downloading libssh2 from sourceforge. We need to have
gcc compiler installed to compile and build libssh2 library.

[ Step:5 ]

-bash-3.2# pkg install gcc-dev
DOWNLOAD                                   
PKGS      
FILES     XFER (MB)
Completed                                 
18/18   2797/2797 105.65/105.65

PHASE                                       
ACTIONS
Install
Phase                             
3545/3545

[ Step:6 ]

Download and extract libssh2 distribution.

-bash-3.2# cd /usr/src
-bash-3.2# wget

http://voxel.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.18.tar.gz

-bash-3.2# gunzip libssh2-0.18.tar.gz
-bash-3.2# tar xvf libssh2-0.18.tar

[ Step:7 ]

build and install libssh2

-bash-3.2# cd libssh2-0.18
-bash-3.2# ./configure
-bash-3.2# make all install

Next we need to link
libssh2 and PHP with the SSH2 PECL module.

[ Step:8 ]

-bash-3.2# cd /usr/src
-bash-3.2# wget http://pecl.php.net/get/ssh2-0.10.tgz
-bash-3.2# gunzip ssh2-0.10.tgz
-bash-3.2# tar xvf ssh2-0.10.tar

-bash-3.2# cd ssh2-0.10

[ Step:9 ]

edit ssh2.c and change
following if condition

#if LIBSSH2_APINO < 200412301450

to

#if LIBSSH2_VERSION_NUM < 0×001000

Save the file and execute phpize to prepare the build environment for
the ssh2 PHP extension.

[ Step:10 ]

-bash-3.2# pwd
/usr/src/ssh2-0.10
-bash-3.2# /usr/php5/bin/phpize
Configuring for:
PHP Api
Version:        
20041225
Zend Module Api No:     
20060613
Zend Extension Api No:   220060519

[ Step:11 ]

-bash-3.2# pwd
/usr/src/ssh2-0.10

-bash-3.2# ./configure –with-ssh2
–with-php-config=/usr/php5/bin/php-config
-bash-3.2# make
-bash-3.2# make install
Installing shared extensions:    
/usr/php5/5.2.4/modules/

[ Step:12 ]

ssh2.so module is now installed. We can modify the php.ini
file and make sure the module gets loaded by php.

-bash-3.2# vi /etc/php5/5.2.4/php.ini
add
extension=ssh2.so
under Dynamic Extensions section

restart the apache to and load the SSH2 php extension.

-bash-3.2# svcadm restart svc:/network/http:apache22

Categories: php Tags:

Administering OpenSolaris Based MySQL AMI using MySQL Administator Tool

October 17th, 2008 Divyen Patel No comments

before you begin, have a quick look at the opensolaris MYSQL AMI(Amazon Machine Images) catalog


[Step -1]

Launch OpenSolaris MySQL 5 AMI

-bash # ec2-run-instances ami-63ce2a0a -k your-keypair

[Step -2]

get the public DNS name associated with the instance

-bash # ec2-describe-instances i-xxxxxxxx

[Step -3]

if the instance is in the creation or booting up phase, you may see
‘Pending’ in place of address.

Once the instance is up and running you will get the public DNS name
which should look like as ec2-xx-xxx-xx-xx.compute-1.amazonaws.com

[Step -4]

login into the instancce with the your keypair

ssh -i <your keypair file path>
root@ec2-xx-xxx-xx-xx.compute-1.amazonaws.com

[Step -5]

The first step to start MySQL server.

To do this, “su – mysql” and type “mysqld &” and “exit”

-bash # su – mysql

mysqld &

[Step-6]

if you have changed the original my.conf file (/etc/my.cnf) make sure
that there is no “skip-networking” option in this file.

[Step-7]

test if mysql is listening to external connections on the port 3306

-bash # netstat -a | grep -i 3306

*.3306
*.*
0      0
49152      0 LISTEN

[Step-8]

Login into mysql database with root user

-bash # su – mysql

-bash # mysql -u root -p

[Step-9]

Execute this query to grant access to external remote host for
administering mysql databases.

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP,
INDEX,ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON *.* TO ‘root’@'%’
IDENTIFIED BY ‘password’;

Query OK, 0 rows affected (0.00 sec)

here  ’%; is the wild card character and used for any remote
host. (if you want to give access to specific remote host, we can
replace it with host address) and ‘password’ is the password you want
to set for the remote host which needs to be provided to make
connection.

[Step-10]

Open “MySQL Administrator” tool.

Provide follwing details to connect to the instance

Server Hostname: ec2-xx-xxx-xx-xx.compute-1.amazonaws.com

Username: root

password: password

mysql_admin_tool_ec2-mysql_ami_snap1

click on the connect and you are ready to administer mysql server
running on ec2 instance  with mysql administrator tool.

mysql_admin_tool_ec2-mysql_ami_snap2

Categories: Amazon EC2, MySQL Tags:

how to create and setup facebook application on Amazon EC2 instance

October 12th, 2008 Divyen Patel No comments

After setting up the facebook application development platform on Amazon EC2 follwing this link, users can simply follow the README file located at ”/var/apache2/2.2/htdocs/footprints/README” to test out the sample ”footprints” application.

Here are the detailed steps, you can follow to sucessfully deploy the sample facebook application available on Amazon EC2 instance.

[step-1]

bash # cd /var/apache2/2.2/htdocs/footprints
bash # ls
config.php  index.php
lib.php     README

[step-2]
edit the config.php and set

$db_ip = 'localhost';
$db_pass = '';

if you have changed your db password, set it accordingly.

[step-3]
create database needed for the sample application. Database script for creating table structure is available in the config.php file.

­bash­3.2# /usr/mysql/bin/mysql ­u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database footprints;
Query OK, 1 row affected (0.00 sec)

mysql> use footprints
Database changed

mysql> CREATE TABLE `footprints` (
­>   `from` int(11) NOT NULL default '0',
­>   `to` int(11) NOT NULL default '0',
­>   `time` int(11) NOT NULL default '0',
­>   KEY `from` (`from`),
­>   KEY `to` (`to`)
­> );

Query OK, 0 rows affected (0.01 sec)

mysql> select * from footprints;
Empty set (0.00 sec)

mysql>

[step-4]
open http://apps.facebook.com and login with your facebook username and password.

goto the Developer section and click on the “Setup new application”.

Provide appropriate application name and agree to the terms and conditions. finally click on the submit button to create the new application.

setup new application

[step-5]

Click on the “Edit Settings” and provide following details.

Call back URL:

http://ec2-XX-XX-XX-XXX.compute1.amazonaws.com/footprints

Canvas page URL:

http://apps.facebook.com/osolami

replace osolami with any avaiable string, to identify your application.

Check mark on  ”Can your application be added on facebook?”

In the default FBML text box provide following

<fb:ifisownprofile>

<br />Hi

<fb:name uid="profileowner" firstnameonly="true"
useyou="false"/>! This is the default FBML as specified
in Footprints' account configuration page. This will get replaced the
first time you get stepped on.

</fb:ifisownprofile>

after the change, click on ”Save” button to update the settings.

facebook application settings page

facebook application settings

facebook application info page

[step-6]

Copy API Key and Secret Key from the above page and change that in to

/var/apache2/2.2/htdocs/footprints/config.php

after the change config.php should look like as given below

<?php
// Get these from http://developers.facebook.com
$api_key = 'd4ec887d2c2d820300eb95785fa5bd68';
$secret = 'a8db36baf5c93f3673fce7ea799d6b40';

/* While you're there, you'll also want to set up your callback url to the url
* of the directory that contains Footprints' index.php, and you can set the
* framed page URL to whatever you want. You should also swap the references
* in the code from http://apps.facebook.com/footprints/ to your framed page URL. */

// The IP address of your database

$db_ip = 'localhost';
$db_user = 'root';
$db_pass = '';

// the name of the database that you create for footprints.

$db_name = 'footprints';

/* create this table on the database:
CREATE TABLE `footprints` (
`from` int(11) NOT NULL default '0',
`to` int(11) NOT NULL default '0',
`time` int(11) NOT NULL default '0',
KEY `from` (`from`),
KEY `to` (`to`)
) */

?>

[step-7]
Replace the URL http://apps.facebook.com/footprints/ to http://apps.facebook.com/osolami/ in /var/apache2/2.2/htdocs/footprints/lib.php

Note: Here “http://apps.facebook.com/osolami/” is your canvas page URL.
make the necessary changes accordingly.

[step-8]

Every thing is set. Now we are ready to hit the application URL

http://apps.facebook.com/osolami/

provide facebook username and password to login in

facebook application login page

[step-9]
Once you are logged in. You will see your sample facebook application running on EC2 instance.

It should look like as given below.

facebook application preview

facebook application preview

“leave your foot prints on some of your friends by steping upon them, and see the database table with updated stepping history”.

bash # /usr/mysql/bin/mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use footprints;
Database changed
mysql> select * from footprints;
+-----------+------------+------------+
| from      | to         | time       |
+-----------+------------+------------+
| 51760XXXX | 101467XXXX | 1223533149 |
+-----------+------------+------------+
1 row in set (0.00 sec)

mysql>

You are all done and set with the sample facebook application on amazon ec2 instance.

Categories: Amazon EC2, Facebook Tags: