More PmWiki setup
This is an extension of a previous post regarding PmWiki. This time I’m going to try and record in excruciating detail what I do to install PmWiki.
Bootstrapping Apache
I’m going to be setting up a Wiki on a host with a name (well, alias)
of tc.codefu.org. Make sure you set up the DNS for whatever name
you’re going to use first, and make sure it can be resolved from the
machine that’s operating as your web server.
At the bottom of /etc/httpd/conf/httpd.conf:
### Local changes
NameVirtualHost *:80
Include conf/vhosts.d/*.conf
[darkness@linode conf]$ sudo mkdir /etc/httpd/conf/vhosts.d
Note that *:80 is necessary if you have SSL installed. Otherwise you
get bitching, at least with the default RH conf. If you need to, set
up the default web directory, above the Include directive in
httpd.conf above. Putting it here seems to make sure it gets
selected as the default VirtualHost.
<VirtualHost *:80>
ServerName plain.old.server.name
DocumentRoot /var/www/html
</VirtualHost>
This was enough to get even /cgi-bin working. Really I’m just too
lazy to look in the Apache docs to find out how it decides what
virtual host to serve from in the case no Host header is passed, or
in the case that the Host header is unrecognized.
Now lets configure the PmWiki host:
[darkness@linode conf]$ cat vhosts.d/tc.codefu.org.conf
<VirtualHost tc.codefu.org:80>
ServerName tc.codefu.org
DocumentRoot /srv/www/tc.codefu.org/root
</VirtualHost>
(Note: you may also need AllowOverride FileInfo for your
DocumentRoot directory if you want to use .htaccess files; see the
section on “Clean URLs,” below, for the whole story.)
We’ll restart Apache later, once we actually have PmWiki installed.
Installing PmWiki
Download the latest PmWiki release. Also have the PmWiki installation instructions on hand.
mkdir -p /srv/www/tc.codefu.org/{root,dist} and wget the PmWiki
distribution into that dist directory. Untar it inside root and
set up a symbolic link as below.
[darkness@linode tc.codefu.org]$ pwd
/srv/www/tc.codefu.org
[darkness@linode tc.codefu.org]$ sudo chown -R root:root root
[darkness@linode tc.codefu.org]$ sudo chmod -R u=rwX,go=rX root
[darkness@linode tc.codefu.org]$ ls -al dist root
dist:
total 244
drwxr-xr-x 2 root root 4096 Feb 13 19:02 .
drwxr-xr-x 4 root root 4096 Feb 13 19:02 ..
-rw-r--r-- 1 root root 233589 Nov 10 10:51 pmwiki-2.0.13.tgz
root:
total 12
drwxr-xr-x 3 root root 4096 Feb 13 19:02 .
drwxr-xr-x 4 root root 4096 Feb 13 19:02 ..
lrwxrwxrwx 1 root root 13 Feb 13 19:02 pmwiki -> pmwiki-2.0.13
drwxr-xr-x 7 root root 4096 Nov 10 10:51 pmwiki-2.0.13
[darkness@linode tc.codefu.org]$ cd root/pmwiki
[darkness@linode pmwiki]$ sudo install -m 775 -o root -g apache -d wiki.d
At this point, if you’re on a system with SELinux (for example, Fedora
Core, CentOS/RHEL 4) you’ll probably need to do something like chcon
-t httpd_sys_content_t wiki.d, but that’s just off the top of my
head. No SELinux on this RHL 9 box.
Now is probably as good a time as any to see if what we’ve done so far has worked:
[darkness@linode pmwiki]$ sudo service httpd reload
Reloading httpd: [ OK ]
Now I’ll try and hit http://tc.codefu.org/pmwiki/pmwiki.php. I’m
glad I did this in my case, since I typoed the DocumentRoot in
tc.codefu.org.conf and got a 404. Remember to check
/var/log/httpd/error_log when you have problems. If everything
works you should see a very normal looking PmWiki HomePage. You
should probably also test editing in the SandBox to make sure pages
can get written to wiki.d OK.
Continuing on, cp sample-config.php local/config.php and edit
local/config.php. Most interesting variables:
$WikiTitle$PageLogoUrlif you’re interested in a different logo$DefaultPasswords['admin']: probably a good idea to set this- I like
$EnableGUIButtons = 1(uncomment the line) so get cute buttons while editing $SpaceWikiWords = 1if you want WikiWords to look like “Wiki Words”$LinkWikiWords = 0if you don’t want WikiWords to make a link at all$WikiWordCountMax = 1if you only want the first occurrence of a WikiWord to generate a link. Keep in mind that, on long pages (for example), this might be a big nuisance (you have to scroll up to find the first occurrence, which is the only actual link).- You can also disable certain WikiWords from ever making a link
(maybe useful for acronyms, for example) by tweaking the
$WikiWordCountassociative array
To enable RSS, uncomment the section that looks something like:
# if ($action == 'rss' || $action == 'rdf') include_once('scripts/rss.php');
PmWiki >= 2.1 might or might not have this bit (it looks like
rss.php has been renamed to feeds.php). See
http://www.pmwiki.org/wiki/PmWiki/RSS for more information.
There are some other interesting variables dealing with “clean URLs” and file uploads. We’ll come back to them.
This is a good point at which to save config.php and test PmWiki again. If you want to test your administrator password, hit a URL such as http://tc.codefu.org/pmwiki/pmwiki.php?n=PmWiki.GroupAttributes?action=attr. This should prompt you for a password. If it accepts your password, you should be taken to a page where you can set passwords for the PmWiki group.
Clean URLs
Start with http://pmwiki.org/wiki/Cookbook/CleanUrls. It looks like they’ve recently cleaned this up, and now it’s even easier to understand.
I want something like
http://tc.codefu.org/pmwiki/pmwiki.php?n=PmWiki.GroupAttributes to
be http://tc.codefu.org/pmwiki/PmWiki/GroupAttributes.
[darkness@linode pmwiki]$ pwd
/srv/www/tc.codefu.org/root/pmwiki
[darkness@linode pmwiki]$ cat .htaccess
# Use mod_rewrite to enable "Clean URLs" for a PmWiki installation.
RewriteEngine On
# Define the rewrite base.
RewriteBase /pmwiki
# Send requests without parameters to pmwiki.php.
RewriteRule ^$ pmwiki.php [L]
# Send requests for index.php to pmwiki.php.
RewriteRule ^index.php$ pmwiki.php [L]
# Send requests for files that exist to those files.
RewriteCond %{REQUEST_FILENAME} !-f
# Send requests for directories that exist to those directories.
RewriteCond %{REQUEST_FILENAME} !-d
# Send requests to pmwiki.php, appending the query string part.
RewriteRule (.*) pmwiki.php?n=$1 [QSA,L]
Relevant excerpt from local/config.php:
## $ScriptUrl is your preferred URL for accessing wiki pages
## $PubDirUrl is the URL for the pub directory.
$ScriptUrl = 'http://tc.codefu.org/pmwiki';
# $PubDirUrl = 'http://www.mydomain.com/path/to/pub';
## If you want to use URLs of the form .../pmwiki.php/Group/PageName
## instead of .../pmwiki.php?p=Group.PageName, try setting
## $EnablePathInfo below. Note that this doesn't work in all environments,
## it depends on your webserver and PHP configuration. You might also
## want to check http://www.pmwiki.org/wiki/Cookbook/CleanUrls more
## details about this setting and other ways to create nicer-looking urls.
$EnablePathInfo = 1;
At this point I test this by going to http://tc.codefu.org/pmwiki/.
Doesn’t work. From /var/log/httpd/error_log:
[Wed Feb 15 23:57:02 2006] [error] [client 65.184.28.68] Directory index forbidden by rule: /srv/www/tc.codefu.org/root/pmwiki/
Turns out I needed to modify
/etc/httpd/conf/vhosts.d/tc.codefu.org.conf, which now looks like:
<VirtualHost tc.codefu.org:80>
ServerName tc.codefu.org
DocumentRoot /srv/www/tc.codefu.org/root
<Directory /srv/www/tc.codefu.org/root>
AllowOverride FileInfo
</Directory>
</VirtualHost>
service httpd reload and I’m back in business.
One final thing: I want http://tc.codefu.org/ to go to
http://tc.codefu.org/pmwiki:
[darkness@linode pmwiki]$ cat /srv/www/tc.codefu.org/root/.htaccess
RewriteEngine on
RewriteRule ^/?$ /pmwiki/ [R,L]
That should do the trick.
Uploads
Now, if you also want to set up uploads, go ahead and check out my previous web log entry on configuring uploads in PmWiki. I don’t need them right now, so I’m not going to set them up here, or say much about them.
One thing I notice I failed to mention in that post is: if you want to
set upload_max_filesize too high in /etc/php.ini, I think you may
also need to make sure post_max_size is large enough to accommodate
the larger upload size.