About Prakash Bhandari

I am Programmer since 4 years.


Running IIS and Apache on Same Server at the Same Time

Running IIS and Apache on Same Server at the Same Time

It is possible to run both IIS and Apache on the same Windows machine, both using port 80 (http) and 443 (https), without any start-up or conflict issues.

To do this, you simply configure IIS and Apache to use different interfaces (i.e., IP addresses) with: one web-server binding on the Public IP address, and the other web-server binding on (local host). Depending on your situation and needs, you can also assign the LAN IP to either IIS or Apache (…just ask yourself which web-server do you want reachable on the local/internal network?).

This way you’ll have both web-servers, and their hosted websites, using standard ports (with no need to use non standard URLs), just on different IPs.

With this method (for example), you could keep your existing IIS websites in production, while at the same time developing on and/or migrating to Apache (which is accessible on the local host). Later, you can move Apache to production by re-binding it.

1. Rebind all IIS websites (including “Default Web Site”) from “*” and “” (“″ means all IPs the system has) to the Public IP address… Select each website one by one, and in the Action pane, click Bindings.

2. Bind Apache from to per these simple instructions…
Binding Apache to a Specific Or [local] Secondary IP Address

Note that when you install a WAMP server such as WampDeveloper Pro, it will stop the IIS Service and change its “Startup Type” from “Automatic” to “Disabled”…

To minimize production downtime, after WAMP installation –

  1. Stop Apache.
  2. Go into Services (run services.msc), select the IIS Service (W3SVC / “World Wide Web Publishing Service”), change its startup type back to “Auto”, and start it.
  3. Rebind all IIS websites to the public IP address, and restart IIS.
  4. Rebind Apache to per the above instructions, and start it.

Binding Apache to a Specific Or Secondary IP Address

Running IIS and Apache in same machine [single computer] Apache, by default, will attempt to bind to and listen on these interfaces:


1. “” means ALL IPv4 addresses that the system has (including   2. “::” means ALL IPv6 addresses that the system has (including ::1). When started, Apache will try to take all the IP addresses of the system, and if you are already running another web-server (such as IIS, Tomcat, Nginx, Jetty, Domino, etc) on that same system, Apache will not be able to bind to “” and “::”, and will fail to start. Or, if started first, after binding to all the available IP addresses, it will prevent the other web-server form starting. To bind Apache to a specific or secondary IP address: Edit file – C:\WampDeveloper\Config\Apache\httpd.conf Find and replace these two lines (one is at the beginning, the other at the end) –

Listen 80
Listen 443

With –

Listen ip.address.here:80
Listen ip.address.here:443

You can specify multiple IP addresses with multiple lines. If this is a public server, make sure that the IP addresses you are using, are either the resolvable IP addresses of your Apache hosted domain names (e.g., the Public IP address), or the LAN IP addresses that the Router is port-forwarding outside port 80 and 443 traffic to. If this is a intranet server, you can just bind Apache to the LAN IP. If this is a localhost server, you can just bind Apache to Also make sure that your other web-server is binding only to a specific IP address, and not to “”. After making changes, if Apache won’t start, check the configuration by running (from the command line):

httpd -t -n "Apache2"
httpd -k start -n "Apache2"


How to set up Multiple PHP versions on Wampserver

Having an easy way to switch PHP version is indeed a neat feature. Wampserver makes it easy for developers (like me!!) who works on Windows. Here’s how.

First if you haven’t update your WAMP installation for a while here’s a chance to do it. Keep a backup of your configuration files and your database, then remove WAMP from Programs and Features. Download the latest WAMP and install it. Then restore you backups. Now you should have the latest build of Apache/PHP/Mysql.

But you also need a previous version of PHP. What about it? Well it’s easy. Download the version you need from here. Create a folder under [WAMP_FOLDER]/bin/php/ with the name ‘php’ and the version you have just downloaded and extract the contents of the zip file there. There it should have another folder which is the current PHP version of WAMP.

Now we need a last thing for the WAMP server to recognize this install. Copy from the default PHP version’s folder three files:

  • php.ini
  • phpForApache.ini
  • wampserver.conf

and paste them on the folder you have just created. Change the ‘extension_dir’ setting from the first two files and open the third and make any appropriate changes.

Terminate WAMP and run it again, not just restart it’s services. And there you have it. Multiple PHP versions in just a click. Sweet right?





Symfony Helpful Query


Select all not null column from the TblCms Table. The criteria ISNOTNULL is used to get not empty column from the table.

$cri = new Criteria();
$cri->add(TblCmsPeer::id, $c->getId());
$cri->add(TblCmsPeer::insertedBy,  NULL,Criteria::ISNOTNULL);
$this->selOne = TblCmsPeer::doSelectOne($cri);


Here $myId is the variable which compares the value with table value and This query should return the expect this id rows of data.

$cri = new Criteria();

$cri->add(TblCmsPeer::id, $c->getId());
$cri->add(TblCmsPeer::insertedBy, $myId,Criteria::NOT_EQUAL);
$this->selOne = TblCmsPeer::doSelectOne($cri);


This will search $search_title = “welcome nepal” from the database column.

$cri = new Criteria();

$cri->add(TblCmsPeer::id, $c->getId());
$this->selOne = TblCmsPeer::doSelectOne($cri);

Or Condition in Query Symfony: 

$c = new Criteria();
$c->add(ForwardedPharmacyDeletedLogPeer::CURRENTLY, ‘1’);
$cc = $c->getNewCriterion(ForwardedPharmacyDeletedLogPeer::FORWARDED_TO,$userId);
$c2 = $c->getNewCriterion(ForwardedPharmacyDeletedLogPeer::REVERTED_TO,$userId);
$my_assigned_pharmacy_list = ForwardedPharmacyDeletedLogPeer::doSelect($c);

Or Condition resultOr_query


More Criterias :

EQUAL Comparison type.
NOT_EQUAL Comparison type.
ALT_NOT_EQUAL Comparison type.
GREATER_THAN Comparison type.
LESS_THAN Comparison type.
GREATER_EQUAL Comparison type.
LESS_EQUAL Comparison type.
LIKE Comparison type.
NOT_LIKE Comparison type.
CONTAINS_ALL Comparison for array column types
CONTAINS_SOME Comparison for array column types
CONTAINS_NONE Comparison for array column types
ILIKE PostgreSQL comparison type
NOT_ILIKE PostgreSQL comparison type
CUSTOM Comparison type.
CUSTOM_EQUAL Comparison type for update
DISTINCT Comparison type.
IN Comparison type.
NOT_IN Comparison type.
ALL Comparison type.
JOIN Comparison type.
BINARY_AND Binary math operator: AND
BINARY_OR Binary math operator: OR
ASC “Order by” qualifier – ascending
DESC “Order by” qualifier – descending
ISNULL “IS NULL” null comparison
ISNOTNULL “IS NOT NULL” null comparison
LOGICAL_OR logical OR operator
LOGICAL_AND logical AND operator




Insert Function in Symfony (How to save data of Form in to symfony)


We Can inset the relevant data sent from the form or any other refrence data like system date, author id from session variable.
First we need to know how to get the content of form in Model class.
The function Signature of Symfony is :
public function executeSaveCms(sfWebRequest $request) {
Here we can get the post or get request in this above function.
Get Request :

/* Here editId is get request which is sent from browser*/

Post Request :
/* Here contentTitle is input fields name form */
The request is assign in intermediate variable;
$content = $request->getPostParameter(‘ContentTitle’);

$c = new TBLCMS();
/* Create object for inserting table content Table name TBLCMS */
/* These below are the column name which set the content for the relevant column name */
/* The ContentDescription is column name which is CONTENT_DESCRIPTION*/
/*Finally we have to set the object to save function it will run the query with above relevent fields */


How to paginate the symfony list data


This is for listing the data in tabular format.

Module file  = <module_name/actions/actions.class.php>

/* 10 is constraint for list number of items */

$pager = new sfPropelPager(‘ClkPerPackageType’, 10);

/* this will get the page items which is defined in frontend/config/app.yml */
$c = new Criteria();
$pager->setPage($this->getRequestParameter(‘page’, 1));
$this->page_counter = ($this->getRequestParameter(‘page’, 1)==1) ? 1 : ((($this->getRequestParameter(‘page’)-1)*10)+1);
$this->ClkProductCompounds = $pager;




View file  = <templates/methodSuccess.php>

foreach ($ClkProductCompounds->getResults() as $cpc): ?>
<tr align=”left” <?php if($page_counter%2 ==0){ echo”style=’background-color:#e9e9e9;'”;}?>>
<td><?php echo $page_counter;?></td>
<td><?php echo $id = $cpc->getPerPackageTypeCode() ?></td>
<td><?php echo $cpc->getPerPackageTypeName(); ?></td>
<td><a href=”<?php echo url_for(‘PerPackageType/list?edit=’ . $id ); ?>”>edit</a></td>


Pagination list. It creates the page link to the fist list and page number.

<div class=”Paging”>
<?php if ($ClkProductCompounds->haveToPaginate()): ?>
<?php echo link_to(‘&laquo;’, ‘PerPackageType/list?page=1’) ?>
<?php echo link_to(‘&lt;’, ‘PerPackageType/list?page=’.$ClkProductCompounds->getPreviousPage()) ?>

<?php foreach ($ClkProductCompounds->getLinks() as $page): ?>
<?php echo link_to_unless($page == $ClkProductCompounds->getPage(), $page, ‘PerPackageType/list?page=’.$page) ?>
<?php echo ($page != $ClkProductCompounds->getCurrentMaxLink()) ? ‘-‘ : ” ?>
<?php endforeach; ?>

<?php echo link_to(‘&gt;’, ‘PerPackageType/list?page=’.$ClkProductCompounds->getNextPage()) ?>
<?php echo link_to(‘&raquo;’, ‘PerPackageType/list?page=’.$ClkProductCompounds->getLastPage()) ?>
<?php endif; ?>





Generate Url in Symfony framework

Generate Url   :: this->generateUrl():


This function can generate the url of the module as argument of the function and returns the module full url.



url_for(‘ProductCompound/view?edit=’ . $id );