Saturday Jan 17, 2009

Get GUI luxury on OpenSolaris 2008.11 EC2 Instance

The following instructions describes steps to access GUI on OpenSolaris EC2 Instance using VNC Viewer.

[ Step - 1]
First steps is to set xvm_vnc property to true for x11-server SMF service. For security reasons it is set to false.

On the terminal type in "svccfg" to modify the service configurations. More details on svccfg is available here.
To come out of svc prompt type in "quit" and hit enter.

root@domU-12-31-39-03-CC-A5:~# svccfg
svc:> select x11-server
svc:/application/x11/x11-server> setprop options/xvm_vnc = true
svc:/application/x11/x11-server> quit

[ Step - 2]
Create .vnc directory under /root if it does not exist
root@domU-12-31-39-03-CC-A5:~# mkdir /root/.vnc/

Create /root/.vnc/xstartup file with following lines.

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
gnome-terminal -geometry 100x60 -title "$VNCDESKTOP Desktop" &

Note: if xstartup file is already exist, replace it with above lines to start gnome terminal session for VNC.

Provide execute permission on xtartup file.
root@domU-12-31-39-03-CC-A5:~#chmod +x /root/.vnc/xstartup

[ Step - 3]
Start the vncserver and set the password.

root@domU-12-31-39-03-CC-A5:~# vncserver

You will require a password to access your desktops.

xauth: creating new authority file /root/.Xauthority

New 'domU-12-31-39-03-CC-A5:1 (root)' desktop is domU-12-31-39-03-CC-A5:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/domU-12-31-39-03-CC-A5:1.log


[ Step - 4 ]
Here we are done with configuring EC2 instance for GUI Remote Access.
Finally we need to authorize and open the listening VNC port on the server with the ec2 group you are using with your instance.

divyen-patels-macbook:~ divyen$ ec2-authorize default -p 5901
GROUP default
PERMISSION default ALLOWS tcp 5901 5901 FROM CIDR
divyen-patels-macbook:~ divyen$

Screen Shots
VNC client connection configuration
Use public DNS address associated with EC2 instance as the host name.

VNC client connected to OpenSolaris 2008.11 EC2 Instance.

For more details on OpenSolaris AMIs visit

Friday Oct 17, 2008

Administering OpenSolaris Based MySQL AMI using MySQL Administator Tool

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

[Step -4]
login into the instancce with the your keypair
ssh -i <your keypair file path>

[Step -5]
The first step to start MySQL server.
To do this, "su - mysql" and type "mysqld &" and "exit"

-bash # su - mysql
mysqld &

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

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

-bash # netstat -a | grep -i 3306
      \*.3306               \*.\*                0      0 49152      0 LISTEN

Login into mysql database with root user
-bash # su - mysql
-bash # mysql -u root -p

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

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.


Open "MySQL Administrator" tool.

Provide follwing details to connect to the instance

Server Hostname:
Username: root
password: password


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


Sunday Oct 12, 2008

how to create and setup facebook application on Amazon EC2 instance

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, one can follow to sucessfully deploy the sample facebook application available on Amazon EC2 instance.

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

edit the config.php and set
$db_ip = 'localhost';
$db_pass = '';

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

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)


open 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

Click on the "Edit Settings" and provide following details.

Call back URL:

Canvas page URL:

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 follwing

<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.

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

facebook application settings page

facebook application settings

facebook application info page


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

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

bash # cat config.php


// Get these from

$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 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`)



Replace the URL to
in /var/apache2/2.2/htdocs/footprints/lib.php

Note: Here "" is your canvas page URL. make the necessary changes accordingly.


Every thing is set. Now we are ready to hit the application URL
provide facebook username and password to login in

facebook application login page

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)


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

Friday Oct 10, 2008

how to setup facebook php client library on Amazon EC2 AMP AMI

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

following are the steps for setting up facebook application development platform on amazon ec2 AMP AMI.
[ step 1]
launch ec2 instance using the AMI ID (ami-45f1152c) and get the instance id
bash # ec2-run-instances -k <your-keypair>  ami-45f1152c

[ step 2]
get the public dns address of the instance using the instance id
bash # ec2-describe-instances <i-xxxxxxxx>

[ step 3]
make ssh connection to the instance.
bash # ssh -i <keypair file>

[ step 4]
download Official PHP client library from

bash # cd /var/apache2/2.2/htdocs/
bash # wget

[ step 5]
extract the platform library and place it at appropriate location

-bash # pwd

bash # gunzip facebook-platform.tar.gz
bash # tar -xf facebook-platform.tar
bash # rm facebook-platform.tar

bash # cd facebook-platform/
bash # mv client/ facebookphp/
bash # mv facebookphp/ /usr/lib/

[ step 5]
make necessary changes in the php.ini file located at /etc/php5/5.2/php.ini
add "/usr/lib/facebookphp" path in the include_path variable.

after the change it should look like this
include_path = ".:/var/php/5.2/pear:/usr/lib/facebookphp"

enable the short_open_tag, so that you can run sample facebook application correctly without any error.
after the change it should look like

short_open_tag = On

[step 6]
restart the apache to apply the changes done in the php.ini file.
bash # svcadm restart svc:/network/http:apache22

[step 7]
arrange directories and perform clean up.

bash # cd /var/apache2/2.2/htdocs/facebook-platform
bash # mv footprints/ ../
bash # mv README ../footprints/
cd ..
bash # pwd

bash # rm -rf facebook-platform/

[step 8]
change the include path in the sample footprint application as we no longer require relative path for the client library.Library path is already included within the php.ini file.

bash # cd footprints/
bash # vi index.php


// the facebook client library
include_once '../client/facebook.php';

// the facebook client library
include_once 'facebook.php';

[step 9]
facebook php client library is now installed and necessary changes has been applied to the sample footprint application.
follow the Readme file located at /var/apache2/2.2/htdocs/footprints/README to begin testing facebook application on amazon ec2.

Divyen Patel


« July 2016