Setup Mediawiki on Fedora/Fedora 17
This is intended for Fedora 17. Please be sure to email me feedback at jgardner@jonathangardner.net
This is a work in progress. Hopefully, in its nascent form it is useful to someone.
Contents
Install Software
You'll need httpd, php, postgresql-server and mediawiki installed.
yum -y install httpd php mediawiki postgresql-server
Setup Apache
Create the Database
PostgreSQL
See Setup PostgreSQL on Fedora
Now, login as postgres:
su - postgres
As postgres, create a new role. This will be the user that the wiki will use to connect to your wiki database.
NOTE: Keep a note of the database user and database name you're using. You'll need it for config.
createuser -DSRP wikiuser
Now create the database for your wiki
createdb -O wikiuser wikidb
You should test that you can connect to your database:
psql -U wikiuser -h 127.0.0.1 wikidb
If you can't, look at the error message you get. You may need to tweak your pg_hba.conf file to get the right setup for logging into your database. See Setup PostgreSQL on Fedora.
MySQL
I do NOT recommend using MySQL for anything.
SQLite
SQLite is a simple database that is convenient and easy to use. It is not as fast as a more robust database, but it is good and it is not MySQL.
Configure Apache
This is rather simple. As root, edit the file /etc/httpd/conf.d/mediawiki.conf
In that file, add these two lines:
Alias /wiki/skins /usr/share/mediawiki/skins Alias /wiki /srv/wiki
Now restart the server.
systemctl restart httpd.service
Modify mw-createinstance script
The mw-createinstance script does not work. There are a number of bugs with it.
Modify it so it:
- Automatically chmod and chcon on the newly created config directory
- Do the same for the images directory
- Add maintenance and skins to the symlinked directories.
Setup your Wiki
Now it's time to setup your wiki.
As root,
mw-createinstance /srv/wiki
Unfortunately, whoever wrote the mw-createinstance is ignorant of SE Linux.
Apache is going to need permission to create and edit files under the config directory. Simply setting the file permissions is not enough. We need to let our SELinux system know that you are granting permission to apache to modify things under that directory.
First, allow Apache to write to public rw files.
setsebool -P allow_httpd_anon_write on
While we're at it, let's make sure Apache can connect across a network:
setsebool -P httpd_can_network_connect on
Now, let SE Linux know that your config dir is a publicly rw directory.
chcon -t public_content_rw_t /srv/wiki/config
Don't forget to let Linux know that anyone can RW in that directory as well.
chmod a+w /srv/wiki/config
Now go to your server at the /wiki URL, IE, http://127.0.0.1/wiki . If a page doesn't load, try restating apache:
systemctl restart apache.service
You should see a page saying your wiki is not configured. Click on the link.
You should now see a page with a bunch of input fields directing you to configure your wiki. If, instead, you see a message that the config directory is not writable, you didn't follow my instructions above or you need to restart apache.
The fields should be self-explanatory. For the datbase host, I use 127.0.0.1 because that's how my pg_hba.conf is setup.
Move LocalSettings.php
Once configuration is done, it tells you to move config/LocalSettings.php to the root directory. This is rather easy:
mv /srv/wiki/{config/,}LocalSettings.php chcon -t httpd_user_content_t LocalSettings.php chmod 644 LocalSettings.php rm -rf config
Now your wiki should be working.
Removing index.php from the URL
See http://www.mediawiki.org/wiki/Manual:Short_URL
Locking down new user accounts
See http://www.mediawiki.org/wiki/Manual:Preventing_access
Enable Uploads
Set $wgEnableUploads to True in the settings.
Subpages
http://www.mediawiki.org/wiki/Manual:$wgNamespacesWithSubpages#Enabling_for_a_namespace
Troubleshooting
Can't connect to DB
This is likely an issue with SELinux. You should check /var/log/httpd/error_log and /var/log/messages to see if anything relevant has occurred.
maintenance/postgres/tables.sql missing?
Creating tables... Warning: fopen(../maintenance/postgres/tables.sql): failed to open stream: No such file or directory in /usr/share/mediawiki/includes/db/Database.php on line 2166 FAILED
Could not open "../maintenance/postgres/tables.sql".
The file does indeed exist at /usr/share/mediawiki/maintenance/postgres/tables.sql. Why can't it find it? These relative path errors are frustrating, because the context isn't given.
There is a bug on just this issue: https://bugzilla.redhat.com/show_bug.cgi?format=multiple&id=757328 Note that on F17 I'm running Mediawiki 1.16.
Let's try the recommendation by Tom King:
ln -s /usr/share/mediawiki/maintenance/ /srv/wiki
Indeed, that seems to work.