Posts Tagged tips

mod_proxy & mod_vhost_alias to host multiple domains on Web-Server and running Apache+IIS together

mod_proxy and mod_vhost_alias are two very important extensions/modules for Apache web-server. When it comes to hosting multiple websites on same Web-Server using Apache or requirement to run Apache and IIS together then mod_proxy and mod_vhost_alias are key to succeed.

Here is summary of definition for both modules from Apache docs.

mod_proxy:

This module implements a proxy/gateway for Apache. It implements proxying capability for FTP, CONNECT (for SSL), HTTP/0.9, HTTP/1.0, and HTTP/1.1. The module can be configured to connect to other proxy modules for these and other protocols.

Apache's proxy features are divided into several modules in addition to mod_proxy: mod_proxy_http, mod_proxy_ftp and mod_proxy_connect. Thus, if you want to use one or more of the particular proxy functions, load mod_proxy and the appropriate module(s) into the server (either statically at compile-time or dynamically via the LoadModule directive).

In addition, extended features are provided by other modules. Caching is provided by mod_cache and related modules. The ability to contact remote servers using the SSL/TLS protocol is provided by the SSLProxy* directives of mod_ssl. These additional modules will need to be loaded and configured to take advantage of these features.

mode_vhost_alias:

This module creates dynamically configured virtual hosts, by allowing the IP address and/or the Host: header of the HTTP request to be used as part of the pathname to determine what files to serve. This allows for easy use of a huge number of virtual hosts with similar configurations.

How to host multiple domains/sub-domains on a web-server using Apache Virtual-Hosting (mod_vhost_alias)?

Read the rest of this entry »

Tags: , ,

Calculate Date/Time difference – Simple Javascript code snippet

It's very often we come across requirement when we need to calculate time difference between two dates in Javascript. Here is a simple Javascript function which can do it in quick and dirty way :)

Dirty because I would have to say because I would have made it little more generalized by provide options and formats which convert string to date automatically..!

Anyway for that matter I would rather suggest using php.js which is interesting and helpful library which let's us use lot of PHP functions in Javascript.. It includes hundreds of useful and handy functions which we are used to while we develop PHP Applications.

This simple functions takes only 2 arguments as Javascript Date objects and in return provides an object with days, hours, minutes and seconds as the property in difference between these 2 date provided as parameter to function.

Here is the code for simple Date-time difference calculation:
Read the rest of this entry »

Tags: , ,

PHP: Performance Improvement Tips

This post covers some performance improvement tips by showing merits or demerits of various coding practices in PHP. While developing small websites or projects which are not meant to be maintained for longer period of time it's okey it we don't care about all this performance improvement and so on. But while we are into the development of some product or project which are going to be maintained for longer period of time then it is required that we take care of small things from the beginning. Initially we may feel that benefits are not drastic but when we have large amount of user base then all small and minor things matters.

In PHP we have always so many ways to do things. During development of PHP as a language, developer community/team added up many functions and features (due to requests..!) in the language and some of them might be redundant, so we have sometimes many ways to solve one problem. Here sometimes due to not knowing what is the best way to solve the problem, we use the solution which we already know or we are more familiar with. Sometimes as a developer we create habit of doing something in particular way for always. Please read on to know whether you are already aware of this tips, which could improve performance of your php application. (Even if it is micro improvement it matters..!) Read the rest of this entry »

Tags: , ,