Recent Changes - Search:

PmWiki

pmwiki.org

edit SideBar

PHPWiki

Trying to setup PHPWiki to use MySQL

I started using http://phpwiki.sourceforge.net/phpwiki/MySqlInstall

I looked like it was fine but it didn't really work at first, but it turns out I misunderstood the SCRIPT_NAME path.


1. Create a database with the (default) name phpwiki if you do not have one already. Use the root or another privileged account.

The command line syntax is:

mysqladmin -uuser -ppassword create phpwiki

2. Create a user for the database with the (default) name wikiuser who has the rights to select, insert, update, delete (again using an administration account). It is done in two steps on the command line:

Login to the database with:

mysql -uuser -ppassword phpwiki

If you use mySQL 4.x or higher, you will also need to grant 'LOCK' permissions, so your grant statement would look like:

GRANT select, insert, update, delete, lock tables ON phpwiki.* TO wikiuser@localhost IDENTIFIED BY 'password2';

The new password2 belongs to the wikiuser, not to the root.

On most shared webservers you can't create new users. Your hoster gave you a fixed mysql-username like web55. This user has some administration privileges and can create new tables. You can use phpMyAdmin to give this user the above mentioned rights for your phpwiki database.


Then it calls for:

 mysql -uuser -ppassword phpwiki <schemas/mysql-initialize.sql

And I don't know where or what schemas/mysql-initialize.sql is!

I FOUND IT in the a sub folder of phpwiki


3. Create the tables inside your database (still using an administration account). A lot of typing is necessary to do this. Therefore the developers have put together those commands in one SQL-batchfile. Let MySQL execute this file with the command:

mysql -uuser -ppassword phpwiki <schemas/mysql-initialize.sql

(When using MySQL 4.1, I noticed that half the searches stopped working. I solved this with ALTER TABLE page CHARACTER SET latin1 COLLATE latin1_general_ci;, which fixed a problem with pagename being set to 'binary' collation. --KeithTyler) We will see if this happens, for now I ignored it

4. Edit the configuration to reflect your settings.

First generate an encrypted password for the wiki administrator with the passencrypt.php page. This page came with PhpWiki and is now in the PhpWiki directory on your webserver.

Open the default configuration file config/config-dist.ini and change the following entries:

* ADMIN_USER = YourAdminName
* ADMIN_PASSWD = The encrypted administrator password
* DATABASE_TYPE = SQL
* DATABASE_DSN = "mysql://wikiuser:password2@localhost/phpwiki" (For wikiuser and password2 see step 2 above, for phpwiki see step 1)
* DEFAULT_LANGUAGE = de or your most beloved language code
* SCRIPT_NAME = /the_absolute_path_from_server_root_to_your_wiki/index.php

              THIS MEANS STARTING AT THE WEB ROOT NOT HARD DRIVE ROOT DIRECTORY

Save the file with the new name config.ini in the config directory.
The entries WIKI_PGSRC, DEFAULT_WIKI_PGSRC, INLINE_IMAGES and USE_SAFE_DBSESSION are not correctly read in Version 1.3.11rc3.

5. Run your Wiki.

I had to close out the browser and restart it to find the homepage for the wiki


Now I can display everything but I cannot edit or create any page. In Mozilla it brings up a blank page and in IE I get a page cannot be displayed.

I switch to a non MySQL version (flatfile) and I have the same problems.

A permissions problem?

I don't think so as I gave others permission to write on the phpwiki folder and subfolders. Something in the code I guess.


Thanks to an now obvious suggestions, I checked the apache log file (/var/log/apache/...) and found

 [error] PHP Fatal error:  Allowed memory size of 8388608 bytes exhausted (tried to allocate 11520 bytes) 

Searching the web brought two suggestions, one was change the .htaccess file which I took to mean the one in my phpwiki folder and add a line about memeory allocation.

I tried that but it didn't work

The other suggestion was to edit the php.ini file in /etc/apache/php.ini

I found the resource sections and change it from 8 MB to 12 MB

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 30     ; Maximum execution time of each script, in seconds
max_input_time = 60	; Maximum amount of time each script may spend parsing request data
memory_limit = 12M      ; Maximum amount of memory a script may consume (8MB)

Then I could edit and create pages. But at the bottom of each page I got this message:

 lib/pear/Cache/Container/file.php:339: Warning: mkdir(/tmp/cache/toolbarcache/): Permission denied 

I thought I change the permissions but I must not have applied it to subfolders, because it didn't work until I allowed everyone and applied to subfolders. Then it worked.

I found info for it at this site
http://phpwiki.sourceforge.net/phpwiki/KnownBugs

Which I think I will mirror on this wiki. It also had the solution to my resource problem


I changed back to the MySQL version and will check the database manually in a bit.

Now my only problem (that I know of), is that after each edit I get this warning at the top of the page

 lib/editpage.php:385: Notice: Use of undefined constant 
    ENABLE_SPAMBLOCKLIST - assumed 'ENABLE_SPAMBLOCKLIST' 

The thing works but I want to fix that little bit.

OK, I got that one. It turns out there was something in config.ini for phpWiki, NOT the editpage.php file where I first looked.

Anyway in confi.ini I had to uncomment the bit about SPAMBLOCKLIST

; Check for links to blocked external tld domains in new edits, against 
; multi.surbl.org and bl.spamcop.net.
ENABLE_SPAMBLOCKLIST = true


I found another problem though. I seems I don't have to log in to edit. In fact I can't log in as the admin at all.

I found this information at http://www.phpbuilder.com/columns/ian_gilfillan20060309.php3

More configuration
Depending on the nature of your wiki, you may not want just anybody editing, or even viewing, your pages. You have quite a lot of flexibility with regards to this. Take a deeper look in the config.ini file. Part Three is what's relevant here. By default, most options are set to their least strict possibility. ALLOW_ANON_USER is set to true, so users don't have to log in to view the pages. Similarly, ALLOW_ANON_EDIT is also true, so anonymous users can make edits. Even if they do log in, ALLOW_BOGO_LOGIN is set to true, which means that no actual password authentication is performed. There are all sorts of more rigorous alternatives, from Apache authentication, IMAP authentication, LDAP authentication or external database authentication. Have a look at the documentation in the config file for more details.

On the same page I found this:

First, create the new database. The database name must match the 
name you selected earlier with the configurator (I chose phpbuilder_wiki):

mysqladmin -uroot_user -proot_password create phpbuilder_wiki

Next, create a new user with the correct permissions (I chose a user with the same name as the database, 
phpbuilder_wiki, and a password of phpbuilder_wiki_password):


mysql -uroot_user -proot_password phpbuilder_wiki

GRANT select, insert, update, delete, lock tables
 ON phpbuilder_wiki.*
 TO phpbuilder_wiki@localhost
 IDENTIFIED BY 'phpbuilder_wiki_password';

I don't remember using the "configurator"

I will try some stuff later.


I looked closer at the README.php.wiki.auth doc in the doc folder and found some suggestions.

So I commented these lines

; allow anon users to view or edit any existing pages
; ALLOW_ANON_USER = true
; allow anon users to edit pages
; ALLOW_ANON_EDIT = true

Then I UN-commented these lines (some comments left for atmosphere)

; True User Authentication:
; To require user passwords:
;   ALLOW_ANON_USER = false
   ALLOW_ANON_EDIT = false
   ALLOW_BOGO_LOGIN = false,
   ALLOW_USER_PASSWORDS = true.
; Otherwise any anon or bogo user might login without any or a wrong password.
ALLOW_USER_PASSWORDS = true

This still lets anybody edit but they at least have to login to do it.

I don't understand how to use the admin password.


I changed a bunch of stuff and it kind of works:

I Wanted To Make It So Only I Could Edit The Page

Got the MySQL user check to work with these settings in the config.ini file

; allow anon users to view or edit any existing pages
ALLOW_ANON_USER = true
; allow anon users to edit pages
; ALLOW_ANON_EDIT = true
; ALLOW_ANON_EDIT = false

; True User Authentication:
; To require user passwords:
; ALLOW_ANON_USER = false
ALLOW_ANON_EDIT = false
ALLOW_BOGO_LOGIN = false
ALLOW_USER_PASSWORDS = true

USER_AUTH_ORDER = "Db"

USER_AUTH_POLICY = strict 
######(I tried stacked and first-only but bogo still seemed to work then)

#### DATABASE CONNECTION 
; A database DSN to connect to.  Defaults to the DSN specified for the Wiki
; as a whole.

;DATABASE_DSN = "mysql://wiki:passwrd@localhost/phpwiki"
### I just took this part out since the connection is in earlier
;
; USER/PASSWORD queries
;
; For USER_AUTH_POLICY=strict and the Db method this is required:
DBAUTH_AUTH_USER_EXISTS = "SELECT userid FROM user WHERE userid='$userid'"
;
; Check to see if the supplied username/password pair is OK
;
; plaintext passwords:
DBAUTH_AUTH_CHECK = "SELECT IF(passwd='$password',1,0) AS ok FROM user WHERE userid='$userid'"

Now only I can edit it but anybody can read it.

BUT if somebody that is NOT in the MySQL database tries to log in the browser goes to a blank page. !!??!!

If I put the USER_AUTH_POLICY = first-only I would sometimes get a MySQL error about duplicate entries in PearDB. I should probably look into that.

Edit - History - Print - Recent Changes - Search
Page last modified on May 07, 2006, at 03:02 AM