Tuesday, May 25, 2010

FAST CGI Support

Steps to FAST CGI Support

Go to system -> Administration -> Synaptic Package Manager and select php-cgi

sh /etc/init.d/lighttpd start

sh /etc/init.d/lighttpd stop

Click apply changes

Edit file /etc/lighttpd/lighttpd.conf file to add following things.

First add the module mod_fastcgi (lighttpd provides an interface to a external programs that support the FastCGI interface via this module). Make sure your server.modules loades mod_fastcgi:

server.modules = (
“mod_access”,
“mod_accesslog”,
“mod_fastcgi”,
“mod_rewrite”,
“mod_auth”
)

Add following lines to configuration

fastcgi.server = ( “.php” =>

(( “socket” => “/tmp/php-fastcgi.socket”,
“bin-path” => “/usr/local/bin/php”,
“bin-environment” => (
“PHP_FCGI_CHILDREN” => “16″,
“PHP_FCGI_MAX_REQUESTS” => “10000″
)
))
)

Restart lighttpd server with following command

TileCache Installation

Steps to Tile Cache Installation

  • Sample Cache entry is as follows

Tile cache can be accessed by link http://localhost:port/tilecache/

Map Server version 5.4.2 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=SWF OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=ICONV SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=GEOS SUPPORTS=RGBA_PNG INPUT=EPPL7 INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE

[cache]

type=Disk

base=/home/mapserver/fgs/tmp/tilecache/cache

Sample WMS layer entry is as follows

[states]

type=WMS

url=http://localhost:8000/cgi-bin/mapserv?map=/home/mapserver/fgs/apps/OMMS3.0/htdocs/map/india_states.map

layers=states

extension=png

For above entry it is important that your map server supports WMS server to test that just go to your FGS installation directory and type command ./www/cgi-bin/mapserv -v and it should not throw any error

Mounting Linux partitions

Step 1.

sudo fdisk -l

This command will list down all devices (drives) connected to your machine

Sample output can be as follows

Disk /dev/sda: 20.0 GB, 20020396544 bytes

255 heads, 63 sectors/track, 2434 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 1275 10241406 83 Linux

/dev/sda2 1276 2434 9309667+ 5 Extended

/dev/sda5 1276 2388 8940141 83 Linux

/dev/sda6 2389 2434 369463+ 82 Linux swap / Solaris

Step 2.

Install partion creator program in ubuntu

sudo apt-get update

sudo apt-get install gparted gksu

gksudo gparted

Step 3.

sudo mkdir /storage

This will create a directory where partition will be mounted

Step 4.

ls -l /dev/disk/by-uuid

List down uuids for all drive’s partitions.

Sample output can be as follows

lrwxrwxrwx 1 root root 10 2009-11-04 17:05 069427AD94279E65 -> ../../sda1

lrwxrwxrwx 1 root root 10 2009-11-04 17:05 82b11ae0-e4c9-4e95-9518-06a337659dfb -> ../../sda5

lrwxrwxrwx 1 root root 10 2009-11-04 17:05 EA902C94902C6971 -> ../../sda7

Step 5.

sudo cp /etc/fstab /etc/fstab_backup

Take back up of original file

sudo gedit /etc/fstab

Edit original file and add following line to that.

Step 6

sudo mount -a

Mount all partitions

Step 7

sudo chown -R username:usergroup /storage

sudo chmod -R 755 /storage

UUID=82b11ae0-e4c9-4e95-9518-06a337659dfb /storage ext3 defaults 0 0

Postgres Update Memory

Steps to Postgres Update Memory

Open Terminal Window

cat/proc/sys/kernel/shmmax.

To view By default shared memory segment

  • To change memory segment permanantly
  • etc/sysctl.conf
  • 1) Login as root
  • 2) Go to system->Administration->Login Window->security->Check Local
  • 3) To edit shared memory segment.
  • edit/proc/sys/kernel/shmmax

PostgreSQL on Ubuntu

Installation

  • To install PostgreSQL, run the following command in the command prompt:
  • sudo apt-get install postgresql
  • Once the installation is complete, you should configure the PostgreSQL server

based on your needs, although the default configuration is viable.

  • Configuration
  • By default, connection via TCP/IP is disabled. PostgreSQL supports multiple

client authentication methods. By default, IDENT authentication method is

used for postgres and local users.

Please refer the PostgreSQL Administrator’s Guide.

  • The following discussion assumes that you wish to enable TCP/IP connections

and use the MD5 method for client authentication. PostgreSQL configuration

files are stored in the /etc/postgresql//main directory.

For example, if you install PostgreSQL 8.3, the configuration files are stored

in the /etc/postgresql/8.3/main directory.

  • To configure ident authentication,

add entries to the /etc/postgresql/8.3/main/pg_ident.conf file.

  • To enable TCP/IP connections,

edit the file /etc/postgresql/8.3/main/postgresql.conf

  • Locate the line #listen_addresses = ‘localhost’ and change it to:
  • listen_addresses = ‘localhost’
  • To allow other computers to connect to your PostgreSQL server replace

‘localhost’ with the IP Address of your server.

  • You may also edit all other parameters, if you know what you are doing!

For details, refer to the configuration file or to the PostgreSQL documentation.

  • Now that we can connect to our PostgreSQL server, the next step is to set a

password for the postgres user. Run the following command at a terminal

prompt to connect to the default PostgreSQL template database:

  • sudo -u postgres psql template1
  • The above command connects to PostgreSQL database template1

as user postgres. Once you connect to the PostgreSQL server, you

will be at a SQL prompt. You can run the following SQL command

at the psql prompt to configure the password for the user postgres.

  • ALTER USER postgres with encrypted password ‘your_password’;
  • After configuring the password, edit the

file /etc/postgresql/8.3/main/pg_hba.conf to use MD5 authentication

with the postgres user:

  • local all postgres md5 sameuser
    sudo /etc/init.d/postgresql-8.3 restart
  • The above configuration is not complete by any means.

Please refer the PostgreSQL Administrator’s Guide to configure

more parameters.

Resources

  • As mentioned above the Administrator’s Guide is an excellent
  • resource. The guide is also available in the postgresql-doc-8.3
  • package. Execute the following in a terminal to install the package:

sudo apt-get install postgresql-doc-8.3

To view the guide enter

file:///usr/share/doc/postgresql-doc-8.3/html/index.html

into the address bar of your browser. For general SQL information see

Using SQL Special Edition by Rafe Colburn.

PostGIS on Ubuntu

With this post I will show how to install PostGIS 1.2.1 on Postgres

8.2.5 in Ubuntu 7.10 (but this procedure should work also for previous

PostGIS/Postgres/Ubuntu versions) from repositories.I will also show

you how to load and secure GIS data and how to access them with

some cool OS GIS Client (QGIS, UDig and gvSIG).

-1- Install Postgres

If you haven’t Postgres, you need to install it (PostGIS runs on top of it).

Open an Ubuntu terminal, and type:

sudo apt-get install postgresql postgresql-client
postgresql-contrib pgadmin3
sudo apt-get install postgresql pgadmin3
Postgres (8.2.5) will be now on your Ubuntu box.
-2- Install PostGIS

Still from the terminal, type:
sudo apt-get install postgresql-8.2-postgis
PostGIS (1.2.1) will now be installed, to be precise this
2 packages are installed:
postgresql
-8.2-postgis
postgis
under file:///usr/share/doc/postgis/postgis.html you will
find the PostGIS Manual, for more help about installation
and configuration.
-3- Create a PostGIS database template

Creating a PostGIS database template is the way to go if
you want to make it easy the creations of many GIS database
on the same server. Without creating this template, you
would need to repeat this steps every time you need to
create a PostGIS database.
sudo su postgres
createdb postgistemplate
createlang plpgsql postgistemplate
psql -d postgistemplate -f /usr/share/postgresql-8.2
-postgis/lwpostgis.sql
psql -d postgistemplate -f /usr/share/postgresql-8.2
-postgis/spatial_ref_sys.sql
The template is now ready (a lot of functions and two
tables – geometry_columns and spatial_ref_sys – were
created in it).
Now we can test of postgistemplate we just created:
$ psql -d postgistemplate -c “SELECT postgis_full_version();”

postgis_full_version
————————————————————
POSTGIS=”1.2.1″ GEOS=”2.2.3-CAPI-1.1.1″ PROJ=”Rel.
4.5.0, 22 Oct 2006″ USE_STATS
(1 row)
-4- Create group role and user

  • Generally the best way is to create the GIS data in
  • the PostGIS database by using a different role and
    user than using the postgres one, that should be used
    only for administrative tasks.
    Typically I use to create a GIS role and user for
    managing data in the PostGIS database. You can even
    create more GIS users with different rights (SELECT,
    INSERT, UPDATE, DELETE on the different GIS feature
    classes), to generate a more safe environment. This
    depends on the configuration of your GIS scenario.
  • Connect to postgres (with postgres user): psql and
  • enter in the command prompt:
  • type this to create the group role, that here i
    name gisgroup (choose less permissions if needed
    for security reasons):
  • CREATE ROLE gisgroup NOSUPERUSER NOINHERIT CREATEDB
    NOCREATEROLE;
  • type this to create the login role, here named gis
    (feel free to change it):
  • CREATE ROLE gis LOGIN PASSWORD ‘mypassword’ NOINHERIT;
  • assign the gis login role to the gisgroup group role:
  • GRANT gisgroup TO gis;
    -5- Assign permissions
  • We need to assign permissions for the postgistemplate
    tables
  • (geometry_columns and spatial_ref_sys will be owned from
    the gis user):
  • exit from the previous connection (type \q), and connect
    to the postgistemplate database as the postgres user:
  • psql -d postgistemplate
  • assign the permissions:
    ALTER
    TABLE geometry_columns OWNER TO gis;
  • ALTER TABLE spatial_ref_sys OWNER TO gis;
  • Create a schema for your gis data (we shouldn’t create the
    gis data in the public schema):
  • CREATE SCHEMA gis_schema AUTHORIZATION gis;
  • exit from the connection (\q)
    -6- Database creation
  • Now we are ready to create the database (or more databases)
    where to load the data (named gisdb), using the createdb
    command, from the postgistemplate we just have created:
  • $ createdb -T postgistemplate -O gis gisdb
    -7- Data loading
  • Download this test data: there are 4 shapefiles that we
  • will load in the new PostGIS database we have created.
    We can import shapefiles in PostGis with the shp2pgsql
    command. First we will create the sql files with this
  • command, and then we will run this files with Postgres
    to import the data in PostGIS.
  • To create the sql files (if you want to avoid this step,
    the zip file already contains this *.sql files we are
    generating):
  • $ shp2pgsql -I -s 32633 POI.shp gis_schema.poi > poi.sql
  • Shapefile type: Point
  • Postgis type: POINT[2]
  • $ shp2pgsql -I -s 32633 vestizioni.shp gis_schema.vestizioni
  • > vestizioni.sql
  • Shapefile type: Arc
  • Postgis type: MULTILINESTRING[2]
  • $ shp2pgsql -I -s 32633 compfun.shp gis_schema.compfun >
    compfun.sql
  • Shapefile type: Polygon
  • Postgis type: MULTIPOLYGON[2]
  • $ shp2pgsql -I -s 32633 zone.shp gis_schema.zone > zone.sql
  • Shapefile type: Polygon
  • Postgis type: MULTIPOLYGON[2]
  • Note that we used 2 options of the shp2pgsql:
    -I will also create a GiST index on the geometry column
    -s will give to PostGIS the information of the srid of the
    data (srid=32633 is for gis data with a spatial reference
    WGS84, UTM 33 N)
  • Now it is time to execute the *.sql scripts with the gis user:
  • $ psql -d gisdb -h localhost -U gis -f poi.sql
  • BEGIN
    psql:poi.sql:4: NOTICE: CREATE TABLE will create implicit sequence
  • “poi_gid_seq” for serial column “poi.gid”
    psql:poi.sql:4: NOTICE: CREATE TABLE / PRIMARY KEY will create
    implicit index “poi_pkey” for table “poi”
    CREATE TABLE
    addgeometrycolumn
    ——————————————————
    gis_schema.poi.the_geom SRID:32633 TYPE:POINT DIMS:2
  • (1 row)
  • CREATE INDEX
    COMMIT
  • Do the same with the other 3 sqls generated from the
    previous step:
  • $ psql -d gisdb -h localhost -U gis -f compfun.sql
  • $ psql -d gisdb -h localhost -U gis -f vestizioni.sql
    $ psql -d gisdb -h localhost -U gis -f zone.sql

Rownum in 8.3 PostgreSQL

select rownum,columnname from(
SELECT ROWNUM, (a[ROWNUM]).columnname as columnAlias
FROM (
SELECT a, generate_series(1, array_upper(a, 1)) AS ROWNUM
FROM (
SELECT ARRAY
(
/*You complex query goes here*/
) AS a
) q2
) q3 ) q4 where /*Some where condition*/

Pages

About Me

My photo
- A competent M.S. Software Engineer and B.E. (Comp) with 6 years of rich experience in Java/ C / C++ / Oracle/PHP/Postgresql/Mysql in IT industry.
- Resourceful in developing Applications with various platforms and different domains.
A strategic planner with expertise in designing internal control systems towards the accomplishment of corporate business goals.
- A keen analyst with exceptional relationship management skills and abilities in liaising with different clients.
- Team player with excellent analytical and communications skills.
Worked with development projects with software brands like Cognizant and Infosys
Specialties
- Master in struts
- Good hands on in core Java
- Understanding of other building blocks of Enterprise applications like middle ware technologies.
- Knowledge of database like Oracle,postgresql,mysql