- Update maintenance/dev/ to install php inside ~/.mediawiki/php instead of ~/.mwphp
- Tweak README a bit
- Move the router.php into an includes along with two helper .sh files to cut out some of the repetition
maintenance/dev/ scripts can help quickly setup a local MediaWiki for development purposes.
-Wikis setup in this way are NOT meant to be publicly available. They use a development database not acceptible for use in production and place a sqlite database in an unsafe location a real wiki should never place it in.
+Wikis setup in this way are NOT meant to be publicly available. They use a development database not acceptible for use in production. Place a sqlite database in an unsafe location a real wiki should never place it in. And use predictable default logins for the initial administrator user.
Running maintenance/dev/install.sh will download and install a local copy of php 5.4, install a sqlite powered instance of MW for development, and then start up a local webserver to view the wiki.
--- /dev/null
+<?php
+
+# Router for the php cli-server built-in webserver
+# http://ca2.php.net/manual/en/features.commandline.webserver.php
+
+ini_set('display_errors', 1);
+error_reporting(E_ALL);
+
+if ( isset( $_SERVER["SCRIPT_FILENAME"] ) ) {
+ # Known resource, sometimes a script sometimes a file
+ $file = $_SERVER["SCRIPT_FILENAME"];
+} elseif ( isset( $_SERVER["SCRIPT_NAME"] ) ) {
+ # Usually unknown, document root relative rather than absolute
+ # Happens with some cases like /wiki/File:Image.png
+ if ( is_readable( $_SERVER['DOCUMENT_ROOT'] . $_SERVER["SCRIPT_NAME"] ) ) {
+ # Just in case this actually IS a file, set it here
+ $file = $_SERVER['DOCUMENT_ROOT'] . $_SERVER["SCRIPT_NAME"];
+ } else {
+ # Otherwise let's pretend that this is supposed to go to index.php
+ $file = $_SERVER['DOCUMENT_ROOT'] . '/index.php';
+ }
+} else {
+ # Meh, we'll just give up
+ return false;
+}
+
+# And now do handling for that $file
+
+if ( !is_readable( $file ) ) {
+ # Let the server throw the error if it doesn't exist
+ return false;
+}
+$ext = pathinfo( $file, PATHINFO_EXTENSION );
+if ( $ext == 'php' || $ext == 'php5' ) {
+ # Execute php files
+ # We use require and return true here because when you return false
+ # the php webserver will discard post data and things like login
+ # will not function in the dev environment.
+ require( $file );
+ return true;
+}
+$mime = false;
+$lines = explode( "\n", file_get_contents( "includes/mime.types" ) );
+foreach ( $lines as $line ) {
+ $exts = explode( " ", $line );
+ $mime = array_shift( $exts );
+ if ( in_array( $ext, $exts ) ) {
+ break; # this is the right value for $mime
+ }
+ $mime = false;
+}
+if ( !$mime ) {
+ $basename = basename( $file );
+ if ( $basename == strtoupper( $basename ) ) {
+ # IF it's something like README serve it as text
+ $mime = "text/plain";
+ }
+}
+if ( $mime ) {
+ # Use custom handling to serve files with a known mime type
+ # This way we can serve things like .svg files that the built-in
+ # PHP webserver doesn't understand.
+ # ;) Nicely enough we just happen to bundle a mime.types file
+ $f = fopen($file, 'rb');
+ if ( preg_match( '^text/', $mime ) ) {
+ # Text should have a charset=UTF-8 (php's webserver does this too)
+ header("Content-Type: $mime; charset=UTF-8");
+ } else {
+ header("Content-Type: $mime");
+ }
+ header("Content-Length: " . filesize($file));
+ // Stream that out to the browser
+ fpassthru($f);
+ return true;
+}
+
+# Let the php server handle things on it's own otherwise
+return false;
if [ "x$BASH_SOURCE" == "x" ]; then echo '$BASH_SOURCE not set'; exit 1; fi
DEV=$(cd -P "$(dirname "${BASH_SOURCE[0]}" )" && pwd)
-if [ -d "$DEV/php" -a -x "$DEV/php/bin/php" ]; then
- PHP="$DEV/php/bin/php"
-elif [ -d "$HOME/.mwphp" -a -x "$HOME/.mwphp/bin/php" ]; then
- PHP="$HOME/.mwphp/bin/php"
-else
- echo "Local copy of PHP is not installed"
- echo 1
-fi
+. "$DEV/includes/require-php.sh"
set -e
set -e # DO NOT USE PIPES unless this is rewritten
-if [ -d "$DEV/php" -a -x "$DEV/php/bin/php" ] || [ -d "$HOME/.mwphp" -a -x "$HOME/.mwphp/bin/php" ]; then
+. "$DEV/includes/php.sh"
+
+if [ "x$PHP" != "x" -a -x "$PHP" ]; then
echo "PHP is already installed"
exit 0
fi
cd "$DEV"
echo "Preparing to download and install a local copy of PHP 5.4, note that this can take some time to do."
-echo "If you wish to avoid re-doing this for uture dev installations of MediaWiki we suggest installing php in ~/.mwphp"
-echo -n "Install PHP in ~/.mwphp [y/N]: "
+echo "If you wish to avoid re-doing this for uture dev installations of MediaWiki we suggest installing php in ~/.mediawiki/php"
+echo -n "Install PHP in ~/.mediawiki/php [y/N]: "
read INSTALLINHOME
case "$INSTALLINHOME" in
[Yy] | [Yy][Ee][Ss] )
- PREFIX="$HOME/.mwphp"
+ PREFIX="$HOME/.mediawiki/php"
;;
*)
PREFIX="$DEV/php/"
+++ /dev/null
-<?php
-
-# Router for the php cli-server built-in webserver
-# http://ca2.php.net/manual/en/features.commandline.webserver.php
-
-ini_set('display_errors', 1);
-error_reporting(E_ALL);
-
-if ( isset( $_SERVER["SCRIPT_FILENAME"] ) ) {
- # Known resource, sometimes a script sometimes a file
- $file = $_SERVER["SCRIPT_FILENAME"];
-} elseif ( isset( $_SERVER["SCRIPT_NAME"] ) ) {
- # Usually unknown, document root relative rather than absolute
- # Happens with some cases like /wiki/File:Image.png
- if ( is_readable( $_SERVER['DOCUMENT_ROOT'] . $_SERVER["SCRIPT_NAME"] ) ) {
- # Just in case this actually IS a file, set it here
- $file = $_SERVER['DOCUMENT_ROOT'] . $_SERVER["SCRIPT_NAME"];
- } else {
- # Otherwise let's pretend that this is supposed to go to index.php
- $file = $_SERVER['DOCUMENT_ROOT'] . '/index.php';
- }
-} else {
- # Meh, we'll just give up
- return false;
-}
-
-# And now do handling for that $file
-
-if ( !is_readable( $file ) ) {
- # Let the server throw the error if it doesn't exist
- return false;
-}
-$ext = pathinfo( $file, PATHINFO_EXTENSION );
-if ( $ext == 'php' || $ext == 'php5' ) {
- # Execute php files
- # We use require and return true here because when you return false
- # the php webserver will discard post data and things like login
- # will not function in the dev environment.
- require( $file );
- return true;
-}
-$mime = false;
-$lines = explode( "\n", file_get_contents( "includes/mime.types" ) );
-foreach ( $lines as $line ) {
- $exts = explode( " ", $line );
- $mime = array_shift( $exts );
- if ( in_array( $ext, $exts ) ) {
- break; # this is the right value for $mime
- }
- $mime = false;
-}
-if ( !$mime ) {
- $basename = basename( $file );
- if ( $basename == strtoupper( $basename ) ) {
- # IF it's something like README serve it as text
- $mime = "text/plain";
- }
-}
-if ( $mime ) {
- # Use custom handling to serve files with a known mime type
- # This way we can serve things like .svg files that the built-in
- # PHP webserver doesn't understand.
- # ;) Nicely enough we just happen to bundle a mime.types file
- $f = fopen($file, 'rb');
- if ( preg_match( '^text/', $mime ) ) {
- # Text should have a charset=UTF-8 (php's webserver does this too)
- header("Content-Type: $mime; charset=UTF-8");
- } else {
- header("Content-Type: $mime");
- }
- header("Content-Length: " . filesize($file));
- // Stream that out to the browser
- fpassthru($f);
- return true;
-}
-
-# Let the php server handle things on it's own otherwise
-return false;
if [ "x$BASH_SOURCE" == "x" ]; then echo '$BASH_SOURCE not set'; exit 1; fi
DEV=$(cd -P "$(dirname "${BASH_SOURCE[0]}" )" && pwd)
-if [ -d "$DEV/php" -a -x "$DEV/php/bin/php" ]; then
- PHP="$DEV/php/bin/php"
-elif [ -d "$HOME/.mwphp" -a -x "$HOME/.mwphp/bin/php" ]; then
- PHP="$HOME/.mwphp/bin/php"
-else
- echo "Local copy of PHP is not installed"
- echo 1
-fi
+. "$DEV/includes/require-php.sh"
PORT=4881
echo ""
cd "$DEV/../../"; # $IP
-"$PHP" -S "localhost:$PORT" "$DEV/router.php"
+"$PHP" -S "localhost:$PORT" "$DEV/includes/router.php"