I’ve spend half of a day trying to get MediaWiki working on a VirtualBox for the internal project in the internal network. Looks like it’s done now and I want to share tips to help someone to spend less time in the future.
I’ve been installing and configuring MediaWiki 1.21 on the OpenSUSE 12.3, but all tips are valuable for any linux distro.
I’ve installed apache2, mediawiki from the php:extensions repository (with tons of dependencies) and php5-related packages (sqlite, xmlreader, zlib and others). The mediawiki package has mysql in dependencies which is annoying, because I want to use PostgreSQL.
Mediawiki installation creates /var/lib/mediawiki directory, in which almost every file is a simulink to the /usr/share/mediawiki corresponding file. After the package is installed and apache is restarted using sudo rcapache2 restart, you’re able to start a mediawiki instance installation through http://localhost/w/ path in your browser. I recommend you to install some additional packages before the actual mediawiki instance (not package) installation:
php5-xcache, php5-intl, postgresql, php5-postgresql, postgresql-server, sendmail, php5-pear-Mail
XCache and Intl are required for MediaWiki, PostgreSQL is better than MySQL, sendmail and php mail extensions are needed for email confirmation from wiki.
Then I suppose you should install phpPgAdmin and go to http://localhost/phpPgMyAdmin to properly configure one. At the moment, you won’t be able to login using the default username-password combination (postgres:postgres). To do so, you should make a bit of DB console hacking and _/var/lib/pgsql/data/pghba.conf hacking (described in this article).
After you’re able to login to phpPgAdmin, you should create user for mediawiki db connection, say, _mediawikiuser.
When you’re done, go to http://localhost/w/ and start the wiki installation process.
During installation choose PostgreSQL instead of MySQL. Enter username you’ve created in phpPgAdmin before. Then you would be asked for username and password for a MediaWiki user, so make sure you’re remembered/backed them up, cause they are username-password of so-called sysop user (e.g. main administrator of MediaWiki installation).
After you would succeed with MediaWiki intallation, let’s make this Wiki available outside of the VirtualBox. First, go to /etc/apache2/vhosts.d/ directory and create two files. One named _default_vhost.conf (with an underscore before name to be the default VirtualHost entry - read more in the OpenSUSE apache docs and Official apache docs) with the following contents:
ServerName localhost DocumentRoot /srv/www/htdocs
And the second one, say, your_website_wiki.conf:
ServerAdmin firstname.lastname@example.org ServerName your_website_wiki.local DocumentRoot /var/lib/mediawiki/webroot/ ErrorLog /var/log/apache2/your_website_wiki.local-error_log CustomLog /var/log/apache2/your_website_wiki.local-access_log combined # don't loose time with IP address lookups HostnameLookups Off # needed for named virtual hosts UseCanonicalName Off AllowOverride None Options +ExecCGI -Includes Order allow,deny Allow from all
First file ensures correct resolution for requests to localhost and the second one is for our wiki resolution for external requests. After VirtualHosts are added, edit the /etc/apache2/listen.conf file and uncomment next line
Now restart apache (rcapache2 restart).
Don’t forget to add HTTP server to the Yast Firewall exceptions and
to your /etc/hosts file.
Now you should be able to get you wiki from browser at guest OS from http://your_website_wiki.local address.
What’s left is to allow access from the host OS. To do so, go to Port forwarding in the VirtualBox network preferences (I assume you have NAT enabled) and add a rule to forward x.x.x.x with 80 port to the 80 port of guest (where x.x.x.x is an address of you computer in your network). You can also play with Bridget networking but it’s not the case.
After you’re done, go to Control panel in Windows, choose Firewall and add domain exceptions to [BranchCache - Content Retrieval (Uses HTTP)].
There’re two abilities for other people to access your wiki. First, you can add a dns entry to the C:WindowsSystem32Driversetchosts file manually. And the other one can be made by your system administrator which can add DNS record to the nearest internal DNS server for your computer.