MediaWiki is the software that runs Wikipedia.
MediaWiki is opensource and is available for download for free. You can use it for offline access to the Wikipedia database, or to set up a wiki of your own.
However, MediaWiki requires other software to be able to run. The prerequisite programs are Apache/IIS, MySQL4 or later (5 or later as of version 1.19) and PHP5. When bundled together, these are referred to as AMP. They are also open source and free.
The Manual Installation Guide explains how to install MediaWiki from scratch.
Note that some users may find MediaWiki software bundles and MediaWiki hosting services with 1-click installation and wiki farms to be convenient alternatives to manual installation.