How can I setup iPhone as a wifi hub?
Yes, it's called Personal Hotspot in iOS5.

under the Settings App on iOS, hit the Personal Hotspot section.  If the feature is currently enabled, you will be able to set a Wifi password and turn the Hotspot on.  Instructions on how to connect to the iPhone are built into the page.

The facility is built into iOS, however you will find that it may or may not be available through your carrier.

If you find that the above is not enabled, then you will need to contact your carrier and subscribe to Tethering support for your contract, if it is available, once done you should be able to enable the Personal Hotspot facility inside the Network preferences.