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