Standalone

Summary: Allows PmWiki to run in a "standalone" mode, without needing a webserver such as Apache
Version: 2019-09-10
Prerequisites: none
Maintainer: Pm
Categories: SystemTools

Questions answered by this recipe

Is it possible to run PmWiki in a "standalone" mode, without needing a web server such as Apache?

Answer

PmWiki is a PHP web application, so there has to be something that can support PHP and act as a webserver. The files below contain a special, bare-bones webserver application that can be used to run PmWiki in places where another webserver isn't available (e.g., a desktop machine).

Another possibility is to use a read-only mirror of the wiki gained from wget and a special link conversions :

  • the following bash script can be used (doHoove.txtΔ)
  • the style sheet link conversion needs to be updated if you are not using the default style

Comment

Some of the solutions below do use a webserver, and thus do not answer the question posed above. Attach:

Installation

Microsoft Windows

  1. Download a copy of PmWiki and unzip it into a folder on the local system.
  2. Download the server-php7.1.3.zipΔ package and unpack its contents into a folder called server/ within the PmWiki main folder. This package includes a copy of the PHP executables, so you don't need to install that separately.
  3. Execute the pmwikiserv.bat file in the server/ folder.
    • The first time, Windows may show a message that it prevented the program from running, click "More info" then "Run anyway" (the actual texts may vary depending on your language and dialect).
  4. Open a web browser to http://localhost/pmwiki.php -- you should see the PmWiki default home page.

That's it!

Apple OS X

See Wiki on a stick

GNU/Linux & Unix systems

  • Install PHP with the package manager of your distribution.
  • If you don't have a full webserver, you can use for testing the PHP Built-In Server (since PHP 5.4):
    • Enter the pmwiki directory in a terminal/console
    • Type php -S 127.0.0.1:8080 to launch the server
    • Point your browser to http://127.0.0.1:8080/pmwiki.php and use your wiki. The PHP built-in server is not an Apache replacement, so you should only use this for testing a standalone PmWiki. The PHP command given above prevents access from any other computer. You need to use a port > 1024 (in this case 8080) with an ordinary user account (non-root).

See Also

Discussion

I ran into 2 problems the first time I tried this:

  1. Clicking on the batch file opens a command window. The first few times I did this the window filled with text that scrolled so fast I couldn't see what it was saying. Turning off Skype stopped that problem. As described below, this is a conflict on port 80, and you can disable port 80 use in Skype prefs.
    1. 03/04/10 Newer Skype doesn't seem to have (obvious) way to kill port 80; but stopping skype then starting the PHP then starting skype, worked. The Skype web page on killing 80 is old news - tools / options / connections -- the new menu has no such. Ward Christensen
  2. Once the darn thing was running, there was no way to stop it. The command window was completely unresponsive and I didn't really want to kill PHP.EXE in the Task Manager. Type Control-C in the command window to bring up a "Terminate batch job?" dialog. Neil Herber

While using this recipe I got two problems:

  • Only images situated in the '/pub' directory or subdirectory can be displayed.
    Now fixed as of 9-Oct-2005. --Pm
  • We are back with the terrific problem of accented letters, either in image name or in directory names, which prevent images to be displayed, when these images are in the http://localhost domain. Same images, but called via File:///C:/Doc... are perfectly visible, as they are on any outside site. This occurs with IE and Firefox, while with different error messages.
    PRZ

Please, be aware that the standalone version is not totally functional because of the server configuration. You may run into problems arising from directory names not being recognized by the server. Also, setting WikiFarms doesn't seem to work properly with the minimal server configuration. Be sure to check the readme included with it.

I was able to get this to work, but I had to add the following lines to pmwikiserv.php. As explained on the comments on the PHP site, this tweak is a way of getting around the "unable to bind, address already in use" error (that I was getting). I'm not sure exactly what negative effects this tweak might have; if anybody has an idea about that, please fill us in. These lines go right BEFORE the line, socket_bind($AcceptSocket, $ip, $port);

# reuse socket tweak
  if (!socket_set_option($AcceptSocket, SOL_SOCKET, SO_REUSEADDR, 1)) {
    echo socket_strerror(socket_last_error($sock));
    exit;
  }

I also might add, I was able to get this thing to work on my flash drive, no problem. Just follow the instructions above, and you've got a localized portable PmWiki installation. Just keep in mind that, from computer to computer, there are probably different settings related to servers, and it's possible you could have problems on one machine and not another. - JonHaupt

I am having trouble running on a shared drive at work. PM Wiki ran fine in standalone mode on my hard drive. I exited it by killing the dos window. I copied the installation over to a shared drive and found it working when called from a DOS command prompt. When I click the batch file \server\pmwikiserv.bat from Windows, (with no servers running) I get a lovely flash on the screen but no wiki. Methinks (wethinks?) the path is not setting correctly in Windows. Help? OBTW. My mappage of the drive will be different than my co-worker's, the path can not be hard-coded. - CongaMike

Update: I fixed (kludged) the problem by hard coding the path statement in the pmwikiserver batch file - CongaMike

I thought the action above corrected the problem and I no longer needed the local copy. Windows would not let me delete it due to file sharing issues. I exited PM Wiki, deleted the local copy, and tried to run the shared copy. Voila! All is well! Sorry to trouble you. - CongaMike

Sometimes the server won't work, because the port 80 that the server uses is already taken. A common reason for this is if you have Skype running. To fix this problem go to Skype Tools > Options > Connection and uncheck "use port 80 and 443 as alternatives for incomming connections". You might have to restart Skype in order for the changes to take effect.
The same problem occurs also with other servers used, like the ones below. Anno

Win32 bundle; Applied the recipe successfully, however the PHP http server sometimes seems unable to cope with a large number of simultaneous requests (e.g. GUIButtons images). stderr says socket_write() unable to write to socket [0]: <localized WinSock message here: closed by remote host>. - RasqualTwilight

  • Another possible combination is to set up PmWiki to work under another free and more complete web server called Xampp-Lite. The whole pack needs only about 90 MB and includes many advantages. Visit http://www.apachefriends.org for more details.
  • Yet another WAMP (Windows, Apache, MySQL and PHP) package has been spotted at http://www.en.wampserver.com/index.php . This one is licensed under the GNU GPL (like PmWiki). According to the site "WAMP5 installs automatically Apache 1.3.31 ,PHP5, MySQL database ,PHPmyadmin and SQLitemanager on your computer. It's principal aim is to allow you to easily discover the new version oh PHP .."
  • And yet another is The Uniform Server ( http://www.uniformserver.com/ ) The Uniform Server is a free and open source WAMP package that allows you to run a server on any MS Windows OS based computer. It is small and mobile to download or move around and can also be used or setup as a production/live server.
    • It works great with subfolders (e.g. pmwiki in pmwiki folder)
    • micro-how-to
      • choose UPX zip, uncompress it
      • uncompress your pmwiki in the www folder Z:/path_to_/UniformServer/www/pmwiki/pmwiki.php
      • modify your local/config.php
$ScriptUrl = 'http://localhost/pmwiki/pmwiki.php';
$PubDirUrl = 'http://localhost/pmwiki/pub';
  • run Z:/path_to_/UniformServer/Server_Start.bat
  • et voila !
  • What about using Nanoweb, an HTTP server written in PHP?
    • It works just fine in a SUSE box, just a little slow with the graphics. CarlosAB April 16, 2007, at 06:44 AM

I tried using server.zip on my Windows XP machine. I unzipped PmWiki to a folder on my local machine. I unzipped server.zip into that folder. I executed pmwikiserv.bat. When I tried to use my web browser to http://localhost/wiki, I got a page stating "No input file specified." I can't find mention of this problem in the PmWiki. Can anyone help me out on this? ---Michael Galvin Oops. I just figured out what I did wrong. I created a directory on my machine, I called PmWiki. I unzipped pmwiki-latest to that directory, into a directory under "PmWiki" called "pmwiki-1.2.27". I then unzipped server.zip into "PmWiki". What I should have done was to unzip it into pmwiki-1.2.27. Now all is well and works fine. I'll leave this comment in this page in case someone else makes the same darned mistake. ---Michael Galvin

:Jolly good thing... I just did the same thing, and I would have given up and gone to bed if I hadn't seen your post! Perhaps some rewording of the instruxions would be in order!!!

:I tried putting pmwikiserv in a shared directory and pointing to it, and even changing the default path, etc, but was unsuccessful; it DOES have to be where the readmem says. Question has anyone successfully gotten a wiki farm going locally, so you can have both a farm server copy and a farm local copy for testing? Otherwise I'll write up how to "duplicate" all the files, have multiple copies of server, etc. Kind of ugly. Ward Christensen


I'm trying to run pmwikiserv.php and got message like this:

PHP Warning:  dl() [<a href='function.dl'>function.dl</a>]: 
Unable to load dynamic library 
'/usr/local/Php-5.2.0/lib/php/extensions/no-debug-non-zts-20060613/php_sockets.dll' 
- /usr/local/Php-5.2.0/lib/php/extensions/no-debug-non-zts-20060613/php_sockets.dll: 
cannot open shared object file: 
No such file or directory in /root/spot/webserver/htdocs/tww/server/pmwikiserv.php on line 76
PHP Fatal error:  
Call to undefined function socket_create() in /root/spot/webserver/htdocs/tww/server/pmwikiserv.php on line 77

What does it mean?

---Ierikka

I've been trying to use pmwikiserv.php, and have got it running, but it doesn't seem to work properly:

  • It seems to be splitting the header/body sections incorrectly, resulting in the beginning of the header section being missing, and raw html appearing instead of the wiki.
  • I think the regular expression used in preg_split on line 136 of pmwikiserv.php isn't quite right, but I don't really know enough about php to fix it.

Any thoughts?

Many thanks, Rowland (2007-10-01)



If you wish to distribute your copy of PmWiki on a CD, you can give http://www.server2go-web.de/ a try hua

Another option is Web Server for CD running on Win, Mac OS X and Linux - currently the only option for creating single CD that will work on 3 platforms. Derek?


I'm trying to set up and test this on a Windows XP PC with PHP, apache, etc, but for use on a PC without them. I get

PHP Warning:  Unknown(): (null): Unable to initialize module
Module compiled with module API=20060613, debug=0, thread-safety=1
PHP    compiled with module API=20020429, debug=0, thread-safety=1
These options need to match in Unknown on line 0

Any suggestions for how to get it to work would be appreciated.

tia, Simon

Hello, I'm using XP Home OS. I'm trying to use the stand alone version and i followed instructions. I unzpped pmwiki to pmwiki-2.1.27, then unzipped server to pmwiki-2.1.27 then executed the batch file named "pmwikeserv" and when it runs I get a command promt that says "c:\pmwiki-2.1.27\server>echo off" then a few seconds later i get a pop up box that says;

"Unknown(): (null): Unable to initialize module Module compiled with module API=20060613, debug=0, thread-safety=1 PHP compiled with module API=20020429, debug=0, thread-safety=1"

Can someone please explain to me how to fix this? Sterling

Answer:

I had this same problem when I tried to run a standalone wiki on a machine that already had one set up on an Apache web server. To fix this, I moved the PHP file (originally in Program Files) and its contents to the desktop. Now the standalone one works, but the one running off Apache doesn't. I'm not sure if they can both run at the same, but this issue definitely has something to do with PHP and not the wiki itself.


Configuration note

It's worth to know that some configuration can be put in a separate configuration file pmwikiserv.conf you should create in the server/ directory. This allows e.g. for easy configuration of the port on which the server will reside. An example from my disk is:

 
<?php
$Listen = "127.0.0.1:7777";
print "Listening port used: $Listen\n";

which allows me to browse local PmWiki at http://localhost:7777/wiki when port 80 is occupied by a firewall configuration page. MateuszCzaplinski


I use Quickphp (use google to find it, first hit) to have a PHP-enabled webserver to run PMwiki on it. It is a few files without installing. Just put them in a directory and start the executable file. Just a few options and you can start/stop it from your systray. When you need certain modules that are not enabled by default you can also easily integratie itt with the PHP binaries from PHP.net. --Jeroen


Question: I have been using this wiki for a couple of years, and now I am trying to using it on Windows 7 64 bit OS and IIS 7.0 and have problems with it. It sometimes just crashes or it will take about 30 seconds to load a page. Any suggestions?

-D. McNulty


guys, the only advantage to using this over xampp is that it is small and easier on ram. xampp will load on a USB stick, has versions for windows (including windows 7, but I don't know about 64 bit), linux, mac, and solaris, it's pre-configured to run, and there is extensive support in multiple places. I'd still use xampp for a first installation, or if there's a problem, since I know I can make it work. (disclaimer: php.ini will limit upload size, and I'm a 10 year veteran of running web servers. what I've learned how to do in 30 minutes in Gnome might take you a little while, especially with apache)


FireFox update broke standalone

Stand-alone worked great for me in Windows XP SP 3, then my FireFox got updated to 10.0.3, and while PHP.EXE + pmwikiserv.php etc loads the first page, nothing happens after that - including no messages in the php server window. Would appreciate any ideas. Ward Christensen April 22, 2012, at 03:10 PM


Hi this is Kannan here Im trying to explore the possibility of using PmWiki as a Knowledge Management tool, I have installed both the PmWiki.zip as well and the StandAlone setup, on following the instructions when I try to open the localhost/wiki I get the error as "PHP script interpreter is not working" when I close that error pop-up on the browser I see just Content-Length 0 Im very new to php and Im not sure what Im doing wrong can someone help .

If you are very new to PHP, try installing XAMPP from https://www.apachefriends.org/ which is the easiest way to start a server with PHP. Then extract the PmWiki archive in the xampp\htdocs folder. --Petko September 09, 2019, at 02:38 PM

Thank you for the response,Continuing on the above issue due to restrictions I am unable to install XAMPP on my office laptop, is there anything I can check or do to fix this issue with the current set up i.e., using the standalone server. I have done the following for now

  • the server.zip has been unpacked in the unpacked PmWiki folder. (..\Documents\PmWiki\server)
  • Ran the pmwikiserv.bat from the server location
  • on the command window I get message "Started... ready for requests" . All seems fine up until now
  • Then on the browser (Im using IE) I try to open the following http://localhost/wiki (https does not seem to work). Moments after I press enter I get the pop "PHP Script Interpreter has stopped working", with a button to Close Program. As soon as I click on it on the browser I see "Content Length:0" message.
  • I have uncommented all functional statements in the sample config.php file and placed the same local folder (..\Documents\PmWiki\local)
  • The wiki.d folder was created and the content within is just a .flock file.

I've packed a barebones PHP environment in a new archive, and modified the instructions above. Please report if it works. Note that this is a very basic PHP version, should mostly work for the core PmWiki, but many recipes/addons from the cookbook may require a full featured installation (those dealing with pictures, or downloading files from the internet, or doing database queries for example). If you need a full server, see portable XAMPP (read carefully), or better, get an inexpensive shared hosting. --Petko September 10, 2019, at 06:22 PM

Contributors

User notes +1 -1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.