Tuesday, September 20, 2011

how to compile php on windows / win32

This is how you do it, using Sara Golemon’s Extending and Embedding PHP as a reference (a fabulous book, by the way).

create a folder on your c drive, like C:\PHPDEV
download php 5.2.6 source from a mirror (this is the current php 5 version, time of this post). Save this tar.gz file into C:\PHPDEV. EXTRACT IT THERE.
download php win32 build extras and save into C:\PHPDEV. EXTRACT IT THERE.
Get pre-built binary packages for bison.exe and flex.exe. Put those on your desktop, or somewhere AWAY from C:\PHPDEV.
Open both archives and go into their /bin directories. Take flex.exe from the flex archive and bison.exe from the bison archive and put THOSE into C:\PHPDEV.

The next step can get twisted if you don’t have Visual Studio (any version?) installed.
If you don’t have it, try the express editions, or take a look at ishouldbecoding.com article.

Assuming you have Visual Studio 2008, FIRST, open C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat.

The file is about 50 lines long full of @set type statements.

Find the line that starts with

@set PATH=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;(goes on)

Change that line to read

@set PATH=C:\PHPDEV;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;(leave the rest exactly as it were)

So all I did there was add C:\PHPDEV; just after the = sign. The reason I did that was so that flex.exe and bison.exe are part of the system path now.

NOW, go to Start->Microsoft Visual Studio 2008->Visual Studio Tools->Visual Studio 2008 Command Prompt.

switch to C:\PHPDEV\php-5.2.6
type buildconf.bat
What this does is scan all folders for .w32 files and creates configure.js for you
type:
cscript /nologo configure.js --without-xml --without-wddx --without-simplexml --without-dom --without-libxml --disable-zlib --without-sqlite --disable-odbc --disable-cgi --enable-cli --enable-debug --without-iconv --disable-ipv6
**** COPY PASTE THE ABOVE LINE. ITS LONGER THAN IT LOOKS.

what this does is modify configure.js for you. You can get the same effect I guess by going into configure.js and manually setting things to “yes” and “no”. Why disable all these things? Most of these aren’t included in the bundle you downloaded, so you’d get compile errors like “file not found” if you didn’t disable these.

if you don’t have bison.exe, you’ll get:

ERROR: bison is required

If you don’t have flex.exe, you’ll get

ERROR: flex is required

so get bison and flex as explained above.

Type
nmake

switch to c:\PHPDEV\php-5.2.6\Debug_TS
Type something like
php -r “$x = ‘hello’; echo($x);”

Friday, April 15, 2011

How To Setup A DNS Server In Ubuntu

Overview
Would you like to setup a DNS Server in Ubuntu? How about setting up a private internal domain name at home? Well, you’ve come to the right place. There are number of tutorials on the internet showing you how to setup a DNS Server with Ubuntu using Bind 9. So, why another how-to document? That’s a good question. I’ve decided I needed to write a simple tutorial that anyone with a little bit of Linux knowledge would be able to follow. In the process, I hope readers are also able to learn how DNS works. Ok, let’s jump right to it!

What is DNS?

First of all, let’s cover the basics. What is DNS? DNS stands for Domain Name Server. It’s a service that runs on a server that translates humanly recognizable domain names such as www.yahoo.com or www.google.com into its assigned IP addresses. If the DNS server does not recognize the domain name being requested, it will forward the domain name request to another DNS server and so on until the name is resolved.

A typical DNS request is when someone is accessing a website. Let’s use the www.yahoo.com domain as an example. When a user clicks a Yahoo link or types the Yahoo URL on the address bar of the browser, the DNS server processes the domain request. If it doesn’t find www.yahoo.com on its DNS table, it will forward the request to another DNS server with a higher authority and so on until it finds a server with the URL entry. The IP address information is then sent back to the user’s browser. If the domain name is not found, a “server not found” message is displayed on the browser.

Assumptions

Enough with the DNS background. Let’s now start configuring our own DNS server. Let’s assume that we have the following: we want to create a private internal domain name called mydomain.com, our private internal network is192.168.0.x and our router and gateway is set at 192.168.0.1. Let’s assume all devices are going to be configured with static IP addresses. Normally, most computer systems nowadays are configured to automatically obtain IP addresses from the DHCP server/router. In this example, we will use static IP addresses to show how DNS works. Finally, we have 3 computers connected to our network:

  • Ubuntu Server, the DNS server – 192.168.0.9
  • Ubuntu Desktop – 192.168.0.10
  • PC – 192.168.0.11

Instructions

1. To install the DNS server, we need to install Bind 9.

sudo apt-get install bind9 

2. Let’s configure Bind. We need to touch 5 files.

We will edit 3 files.

  • /etc/bind/named.conf.local
  • /etc/bind/named.conf.options
  • /etc/resolv.conf

We will create 2 files.

  • /etc/bind/zones/mydomain.com.db
  • /etc/bind/zones/rev.0.168.192.in-addr.arpa

A. First step. Lets add our domain zone – mydomain.com.

sudo vi /etc/bind/named.conf.local 
# Our domain zone zone "mydomain.com" {    type master;    file "/etc/bind/zones/mydomain.com.db"; };  # For reverse DNS zone "0.168.192.in-addr.arpa" {    type master;    file "/etc/bind/zones/rev.0.168.192.in-addr.arpa"; }; 

Save file. Exit.

We just created a new domain. Please note: later we will create two files named mydomain.com.db and rev.0.168.192.in-addr.arpa files. Also, notice the reverse IP address sequence in the reverse DNS section.

B. Let’s add the DNS servers from your ISP. In my case, I’m using Comcast DNS servers. You can place the primary and secondary DNS servers here separated by semicolons.

sudo vi /etc/bind/named.conf.options 
forwarders {    68.87.76.178; }; 

Save file. Exit.

C. Now, let’s modify the resolv.conf file found in /etc and place the IP address of our DNS server which is set to 192.168.0.9.

$ sudo vi /etc/resolv.conf 
search mydomain.com. nameserver 192.168.0.9 

D. Now, let’s define the zones.

sudo mkdir /etc/bind/zones sudo vi /etc/bind/zones/mydomain.com.db 
$TTL 3D @ IN SOA ns.mydomain.com. admin.mydomain.com. (    2007062001    28800    3600    604800    38400 ); mydomain.com.  IN      NS         ns.mydomain.com. ubuntudesktop  IN      A          192.168.0.10 www            IN      CNAME      ubuntudesktop pc             IN      A          192.168.0.11 gw             IN      A          192.168.0.1                        TXT        "Network Gateway" 

The TTL or time to live is set for 3 days
The ns.mydomain.com nameserver is defined
ubuntudesktop, pc and gateway are entered as an A record
An alias of www is assigned to ubuntudesktop using CNAME

E. Let’s create a “rev.0.168.192.in-addr.arpa” file for reverse lookup.

sudo vi /etc/bind/zones/rev.0.168.192.in-addr.arpa 
$TTL 3D @       IN      SOA     ns.mydomain.com. admin.mydomain.com. (                 2007062001                 28800                 604800                 604800                 86400 )         IN      NS      ns.mydomain.com. 1       IN      PTR     gw.mydomain.com. 10      IN      PTR     ubuntudesktop.mydomain.com. 11      IN      PTR     pc.mydomain.com. 

3. Let’s restart Bind to activate our latest changes.

sudo /etc/init.d/bind9 restart 

4. Finally, let’s test our new domain and DNS entries.

Dig

$ dig mydomain.com 

Nslookup

nslookup gw 

5. That’s it.

Monday, March 28, 2011

Subversion in Ubuntu

/home/shyju/.amaya/2/New.html

Initial Setup

sudo aptitude install subversion

The next steps is to create a new group that will be responsible for subversion tasks.

  • From the Panel, navigate to System > Administration > Users and Groups
  • If necessary, unlock the dialog, and then click “Manage Groups”
  • Click “Add Group”. Create a group named “subversion”, and add yourself to it.
  • Log out and back re-log in for the changes to take effect.
  • n a terminal, create your new folder, using the commands:
cd /home
sudo mkdir svn

Adding the First Repository

cd /home/svn
sudo mkdir my-project

Finally, we use the “svnadmin” command to create some base files and configure the repository.

sudo svnadmin create /home/svn/my-project

Now, change the access permissions to give the subversion group the proper settings:

sudo chgrp -R subversion my-project
sudo chmod -R g+rws my-project

Configuring Your Repository

At this point, you should have a working repository. However, there are still a few options you might want to tweak. In particular, the access permissions. By default, a fresh repository will be readable by anyone and writable by authorized users. To change these settings, open /home/svn/my-project/conf/svnserve.conf in your favorite text editor– you can use the command:

gedit /home/svn/my-project/conf/svnserve.conf

The lines that control access restrictions look like:

# anon-access = read
# auth-access = write

These two lines control anonymous access and authenticated access, respectively. To change from the default behavior for each value, remove the leading ‘#’ character, and set the right-side value to ‘read’, ‘write’, or ‘none’, for read-only, read-write, or no access, respectively. When you are finished, you can save the file and close it.


If you plan on using authenticated access to your repository, you will need to set up at least one username and password. To do so, open the/home/svn/my-project/conf/passwd file in a text editor:

gedit /home/svn/my-project/conf/passwd

To create a username, simply add a line to the bottom of the form:

username = password

There are a few examples already in the file, but commented out. You may add as many usernames as you need.



Access From the Host Computer

At this point you are ready to test out your new repository. Any configured repositories should be accessible from the host computer as-is. You can test it out by checking-out your first working copy:

svn checkout file:///home/svn/my-project ~/my-project-wc

Perhaps you would like to add a “trunk” directory, where you will develop your project:

cd ~/my-project-wc
mkdir trunk
svn add trunk
svn commit -m "Add a trunk directory for development."

Depending on your configuration above, you may be asked for a user name and password. You should use the values you entered in the passwd file.

Monday, March 7, 2011

Installing PHPUnit to run phpunit.xml for Zend Server 5.3.1

1. Install PEAR by running go-pear.bat

if it starts to complain about: “… does not have a signature …” change the go-pear.bat to the following:

1
2
3
4
@ECHO OFF
set PHP_BIN=php.exe
%PHP_BIN% -d output_buffering=0 -d phar.require_hash=0 PEAR\go-pear.phar
pause

2. Update pear:

pear channel-update pear.php.net

pear upgrade pear

3 Install PHPUnit via PEAR by running:

pear channel-discover pear.phpunit.de

pear install phpunit/PHPUnit



Friday, January 14, 2011

zend config file

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
;includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.layout.layout = "layout"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.frontController.plugins.acl = "Plugin_acl"
[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
;# Layout
;resources.layout.layout = "layout"
;resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"

resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "honda"
resources.db.isDefaultTableAdapter = true

Zend Boot strap


class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

protected function _initView()
{

$view = new Zend_View();
$view->doctype('XHTML1_STRICT');
$view->headTitle('Pioneer India');
$view->env = APPLICATION_ENV;
$view->skin = 'blues';
// Add it to the ViewRenderer
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
'ViewRenderer'
);
$view->addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
$viewRenderer->setView($view);
/////////////////////////////////////////////

// Return it, so that it can be stored by the bootstrap
return $view;
}
protected function _initAutoload()
{
// Add autoloader empty namespace
$autoLoader = Zend_Loader_Autoloader::getInstance();
$autoLoader->registerNamespace('Pioneersys_');
$autoLoader->registerNamespace('OFC_');
$resourceLoader = new Zend_Loader_Autoloader_Resource(array(
'basePath' => APPLICATION_PATH,
'namespace' => '',
'resourceTypes' => array(
'form' => array(
'path' => 'forms',
'namespace' => 'Form_',
),
'model' => array(
'path' => 'models/',
'namespace' => 'Model_'
),
'plugin' => array(
'path' => 'plugin/',
'namespace' => 'Plugin_'
)
),
));
// Return it so that it can be stored by the bootstrap
return $autoLoader;
}

Sunday, October 24, 2010

Saturday, January 30, 2010

Zend Frame work in wamp -------

I was suck with zend famework
finally got it working

1. copy library zend folder to project library folder
2. do some settings on wamp - httpd.conf file
un comment
LoadModule rewrite_module modules/mod_rewrite.so
only then .htacces file works properly
and set allowoveride none to allow override all

Tuesday, September 29, 2009

sh^M: bad interpreter: No such file or directory


$ ./configure
bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory

Problem is that we r trying to run script saved in dos format at some point.
Convert this to unix by using dos2unix

dos2unix is contained in package tofrodos

sudo apt-get install tofrodos
dos2unix configure

It will (attempt) to convert this/these files properly to a use-able format

Monday, September 7, 2009

How To Enable Adobe's Flash Player In Google Chrome (Ubuntu 9.04)

If the Flash plugin is already installed for Firefox, we have to find out where it is located:

sudo updatedb
sudo locate libflashplayer.so

If it is installed, output should be similar to this one...

falko@falko-desktop:~$ sudo locate libflashplayer.so
/opt/Adobe AIR/Versions/1.0/Resources/libflashplayer.so
/usr/lib/flashplugin-installer/libflashplayer.so
falko@falko-desktop:~$

... which means the Flash plugin is located in /usr/lib/flashplugin-installer/libflashplayer.so. If there's no output, this means that the Flash plugin isn't installed - you can then install it as follows:

sudo aptitude install flashplugin-installer

Now we create a plugins directory for Google Chrome...

sudo mkdir /opt/google/chrome/plugins

... and copy the Flash plugin to it:

sudo cp /usr/lib/flashplugin-installer/libflashplayer.so /opt/google/chrome/plugins

Finally we have to tell the Google Chrome launcher that it should look out for plugins. To do this, we right-click on Applications and select Edit Menus:




In the Menu Editor, go to Internet > Google Chrome and click on the Properties button:




In the Launcher Properties window, replace the contents of the Command field with this line...

/opt/google/chrome/google-chrome --enable-plugins %U

... and click on Close:

Then leave the Menu Editor.

That's it! We can now launch Google Chrome (Applications > Internet > Google Chrome):





Tuesday, August 25, 2009

Seting-Up a HTTP Proxy Server with Authentication and Filtering

sudo apt-get install squid
Configure Squid by opening /etc/squid/squid.conf using your favorite text editor. In the configuration file, search for the following directives and modify (or add, if they don't exist) as it follows:

http_port 3128 - The port Squid will listen for connections. If your system has two or more interfaces, you can specify which IP address to use. Eg: http_port 192.168.0.1:3128

http_access deny all - Search for it in the config file, uncomment it (remove the # in front), and replace deny with allow so it becomes http_access allow all.

Restart the Squid proxy with:
CODE
$ sudo /etc/init.d/squid restart

Now you should have a fully functional HTTP proxy. To try it out, open a browser, open its preferences dialog and go to proxy settings. Here, enter the IP address of the machine running Squid and the port set in squid.conf. Now load a webpage.

SETTING UP SQUID AUTHENTICATION AND WEB FILTERING

This section will allow you to set up a web site filter for kids. The first time an address is entered in the browser's address bar, an authentication dialog will pop-up, prompting for a username and password. We will set-up two usernames, one with full and another with restricted access.

First, open the /etc/squid/squid.conf and add the following line in the auth_param section:

auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/passwd

Now create the user accounts using htpasswd (use -c only for the first user):
CODE
$ sudo htpasswd -c /etc/squid/passwd dad
Enter a password for user 'dad':
Again:

$ sudo htpasswd /etc/squid/passwd kid
Another password:
Again:

Create the ACLs by adding the following lines in the ACCESS CONTROLS (acl) sections in Squid.conf:
CODE
acl dadUser proxy_auth dad
acl kidUser proxy_auth kid
acl whitelist dstdomain "/etc/squid/whitelist"
http_access allow dadUser
http_access allow kidUser whitelist

Create the whitelist by opening a text editor, adding allowed domains like this:
.google.com
.kids-play.com
.yahoo.com
.msn.com


and save it as /etc/squid/whitelist.

Finally, search for http_access allow all in the Squid config file and modify it so it looks like this:
http_access deny all

This is how my Squid config sections look like:
CODE
# NETWORK OPTIONS
# Squid normally listens to port 3128
http_port 192.168.0.1:3128

# TAG: auth_param
#Recommended minimum configuration per scheme:
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/passwd

# ACCESS CONTROLS
# TAG: acl
acl dadUser proxy_auth dad
acl kidUser proxy_auth kid
acl whitelist dstdomain "/etc/squid/whitelist"
http_access allow dadUser
http_access allow kidUser whitelist

# TAG: http_access
# And finally deny all other access to this proxy
http_access deny all

Use deny all for squid with authentication and allow all for basic squid configuration.

create a shared and a static library with gcc


The code for the library

This is the code that goes into the library. It exhibits one single function that takes two doubles and calculates their mean value and returns it.
calc_mean.c
//#include   double mean(double a, double b) {   return (a+b) / 2; } 

The header file

Of course, we need a header file.
calc_mean.h
double mean(double, double); 

Creating the static library

A static library is basically a set of object files that were copied into a single file. This single file is the static library. The static file is created with the archiver (ar).
First, calc_mean.c is turned into an object file:
gcc -c calc_mean.c -o calc_mean.o 
Then, the archiver (ar) is invoked to produce a static library (named libmean.a) out of the object file calc_mean.o.
ar  rcs libmean.a      calc_mean.o 
Note: the library must start with the three letters lib and have the suffix .a.

Creating the shared library

As with static libraries, an object file is created. The -fPIC option tells gcc to create position independant code which is necessary for shared libraries. Note also, that the object file created for the static library will be overwritten. That's not bad, however, because we have a static library that already contains the needed object file.
gcc -c -fPIC calc_mean.c -o calc_mean.o     
For some reason, gcc says:
cc1: warning: -fPIC ignored for target (all code is position independent) 
It looks like -fPIC is not necessary on x86, but all manuals say, it's needed, so I use it too.
Now, the shared library is created
gcc -shared -Wl,-soname,libmean.so.1 -o libmean.so.1.0.1  calc_mean.o 
Note: the library must start with the three letter lib.

The programm using the library

This is the program that uses the calc_mean library. Once, we will link it against the static library and once against the shared library.
main.c
#include  #include "calc_mean.h"  int main(int argc, char* argv[]) {    double v1, v2, m;   v1 = 5.2;   v2 = 7.9;    m  = mean(v1, v2);    printf("The mean of %3.2f and %3.2f is %3.2f\n", v1, v2, m);    return 0; } 

Linking against static library

gcc -static main.c -L. -lmean -o statically_linked 
Note: the first three letters (the lib) must not be specified, as well as the suffix (.a)

Linking against shared library

gcc main.c -o dynamically_linked -L. -lmean 
Note: the first three letters (the lib) must not be specified, as well as the suffix (.so)

Executing the dynamically linked programm

LD_LIBRARY_PATH=. ./dynamically_linked