Difference between pages "Package:Portage (Funtoo)" and "Package:MediaWiki"

(Difference between pages)
m (insert an external link to wikipedias portage page.)
 
m (migrate test36 into the page)
 
Line 1: Line 1:
 
{{Ebuild
 
{{Ebuild
|Summary=This is the official package manager/ports system for Funtoo Linux.
+
|Summary=
|CatPkg=sys-apps/portage
+
|CatPkg=www-apps/mediawiki
|Maintainer=Drobbins, Oleg
+
|Maintainer=Drobbins,  
 
|Repository=Funtoo Overlay
 
|Repository=Funtoo Overlay
 
}}
 
}}
=== Introduction ===
 
  
[http://en.wikipedia.org/wiki/Portage_(software) Portage] is the official package manager of Funtoo Linux. Daniel Robbins maintains a slightly different version from upstream Gentoo Linux, with support for mini-manifests and other features.
+
{{Fancyimportant|1=
 +
This page documents how to install MediaWiki from source tarball rather than portage, which is the preferred method. It also shows how to use MediaWiki with php-5.4. As of late 1.22 and 1.23, MediaWiki now unofficially works with php-5.5 & php-5.6.}}
  
=== Portage Commands ===
+
MediaWiki is a [[Web-server-stack]] web application.  This page documents how to set up MediaWiki on Funtoo Linux, from a bare stage3 install with network connectivity. We will use Nginx, xcache and PHP-FPM, which will result in good performance. We will also properly secure MediaWiki, and also cover some additional tips and tricks, focusing on spam reduction.
  
; [[emerge]]
+
== Portage Settings ==
: high-level dependency-based package merge/unmerge tool
+
; [[ebuild]]
+
: lower-level package build tool
+
  
;{{c|etc-update}}
+
Add the following line to <code>/etc/[[make.conf]]</code>:
;{{c|dispatch-conf}}
+
:tools to manage /etc/configurations
+
  
=== Portage Specifications ===
 
  
The latest progress and changes related to EAPI/PMS and Portage can often be found in the Gentoo Council meeting logs, which are listed on the [http://www.gentoo.org/proj/en/council/ Gentoo Council page].
+
<pre>
 +
PHP_TARGETS="php5-4"
 +
</pre>
  
The latest PMS specification to be approved by the Gentoo Council is available: [http://distfiles.gentoo.org/distfiles/pms-3.pdf eapi-3-approved-2010-01-18]. The PMS specification is an attempt to codify the inner workings of Portage, and is authored by Ciaran McCreesh and Stephen Bennett as a Gentoo-hosted project.
+
Add the following lines to <code>/etc/portage/package.use/php</code>:
  
=== Portage Profiles ===
+
<pre>
 +
dev-lang/php curl exif fpm gd mysql mysqli sockets suhosin threads intl xmlreader xmlwriter
 +
>=dev-php/xcache-2.0.0 php_targets_php5-4
 +
</pre>
  
Portage uses [[Portage Profiles|profiles]] to define settings for various architectures and types of Funtoo/Gentoo systems. See the [[Portage Profiles]] page for detailed information on how Portage handles profiles. Look at [[Creating_Profiles]] to learn how to create them and at [[Funtoo_1.0_Profile]] to learn about the Funtoo 1.0 profile.
+
== Emerge ==
  
===Portage Variables ===
+
Emerge xcache, and we'll also emerge metalog and postfix. This should pull in MySQL as well as php-5.4:
  
Portage's behavior can be controlled by a number of configuration settings other variables that can be defined within the ebuild itself. In addition, a number of these variables are defined for the ebuild automatically by Portage. These variables are now documented on their own page: [[Portage Variables]].
+
<console>
=== Multiple ABI Support ===
+
# ##i##emerge --jobs xcache metalog postfix
 +
</console>
  
Portage contains support for multiple ABIs (Application Binary Interfaces) co-existing on the same system. This functionality has been extensively documented and has been moved to its own page: [[Multiple ABI Support]].
+
== Start and Configure Services ==
  
=== Ebuild Functions ===
+
Time to configure MySQL with a root password, start it, secure it, and enable it to start at boot. We'll also start metalog and postfix:
  
An ebuild developer has the ability to define [[Ebuild Functions]] that define steps to perform during a particular part of the ebuild lifecycle. These steps are now documented on their own page: [[Ebuild Functions]].
+
<console>
 +
# ##i##emerge --config mysql
 +
# ##i##rc-update add mysql default
 +
# ##i##rc-update add metalog default
 +
# ##i##rc-update add postfix default
 +
# ##i##rc
 +
# ##i##mysql_secure_installation
 +
</console>
  
=== Funtoo Portage Development ===
+
== Database Setup ==
  
The Funtoo Core Team is currently working on a general-purpose plug-in system so that the GNU info file regeneration, news update display, and scanning of files that need updating in /etc can be pulled out of the official Portage emerge code. In addition, this plug-in system will allow other types of things to be hooked into various phases of emerge. This will allow various new plug-ins to be developed and used on systems, such as periodic security checks, etc.
+
Now, let's create a database named <code>mediawiki</code> for use by MediaWiki, and a <code>mediawiki@localhost</code> user to access this database, using a password of <code>wikifever</code>:
  
=== Portage Logs ===
+
<console>
Logs of portage actions can be found at <code>/var/log/emerge.log</code> & <code>/var/log/portage/elog/summary.log-(date the log is generated)</code>
+
# ##i##mysql -u root -p
 +
Enter password:
 +
Welcome to the MySQL monitor. Commands end with ; or \g.
 +
Your MySQL connection id is 7
 +
Server version: 5.1.62-log Gentoo Linux mysql-5.1.62-r1
  
=== TODO ===
+
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  
Add support to portage, so that when an ebuild is merged, the /var/db/pkg entry contains a list of all currently-installed versions of all ebuilds upon which that ebuild RDEPENDs. This, combined with a comprehensive set of past USE settings (may need to implement this too,) can be used to detect when an ebuild needs to be rebuilt. This could help to address issues like those in [http://bugs.gentoo.org/167662 Gentoo Bug 167662] and allow easier implementation of support for things like perl-cleaner. Currently, perl-cleaner doesn't detect that vim uses perl and moving from -ithreads to ithreads causes vim to die, so it needs to be manually rebuilt.
+
Oracle is a registered trademark of Oracle Corporation and/or its
 +
affiliates. Other names may be trademarks of their respective
 +
owners.
  
Add support for portage to understand which version of a particular app is the "active" version that it was built against, and record this information in /var/db/pkg. This can help to implement perl-cleaner-like support in Portage.
+
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  
=== Funtoo Features/Changes ===
+
mysql> ##i##create database mediawiki;
 +
Query OK, 1 row affected (0.01 sec)
  
==== Summary ====
+
mysql> ##i##grant index, create, select, insert, update, delete, alter, lock tables on mediawiki.* to 'mediawiki'@'localhost' identified by 'wikifever';
 +
Query OK, 0 rows affected (0.01 sec)
  
In [https://github.com/funtoo/portage-funtoo/tree/thin-manifest the thin-manifest branch], Funtoo changes have been isolated into the following commits:
+
mysql> ##i##\q
 +
Bye
 +
#
 +
</console>
 +
 
 +
== Nginx Setup ==
 +
 
 +
We will use nginx as our Web server. Let's emerge it:
 +
 
 +
<console>
 +
# ##i##emerge --jobs nginx
 +
</console>
 +
 
 +
== User and Group ==
 +
 
 +
When we run our wiki, we will run it as the <code>docs</code> user, for security. Let's set up a <code>docs</code> user and group:
 +
 
 +
<console>
 +
# ##i##groupadd docs
 +
# ##i##useradd -g docs --home /home/docs docs
 +
# ##i##install -d /home/docs
 +
# ##i##chown -R docs:docs /home/docs
 +
</console>
 +
 
 +
== Set up PHP ==
 +
 
 +
As our last major configuration step, we will configure the PHP FastCGI Process Manager by creating a <code>/etc/php/fpm-php5.4/php-fpm.conf</code> file with the following contents (existing contents can be deleted):
 +
 
 +
{{file|name=/etc/php/fpm-php5.4/php-fpm.conf|desc= |body=
 +
[global]
 +
error_log = /var/log/php-fpm.log
 +
log_level = notice
 +
 
 +
[docs]
 +
listen = /var/run/docs.php-fpm.socket
 +
listen.allowed_clients = 127.0.0.1
 +
listen.owner = docs
 +
listen.group = nginx
 +
listen.mode = 0660
 +
user = docs
 +
group = docs
 +
pm = dynamic
 +
pm.max_children = 16
 +
pm.start_servers = 2
 +
pm.min_spare_servers = 2
 +
pm.max_spare_servers = 2
 +
pm.max_requests = 500
 +
php_admin_value[open_basedir] = /home/docs/public_html:/tmp
 +
php_admin_value[error_log] = /home/docs/php-errors.log
 +
php_admin_value[disable_functions] = exec, system, shell_exec, passthru, popen, dl, curl_multi_exec, posix_getpwuid,
 +
disk_total_space, disk_free_space, escapeshellcmd, escapeshellarg, eval, get_current_user, getmyuid, getmygid,
 +
posix_getgrgid, parse_ini_file, proc_get-status, proc_nice, proc_terminate, suexec, pclose, virtual, set_time_limit, show_source
 +
}}
 +
This configuration file tells PHP to use the <code>docs</code> user when running MediaWiki. '''Please note that the last line is very long - I have split it into 3 lines for readability on this wiki, but you should combine them into a single line in your configuration file. The line should start with <code>php_admin_value[disable_functions]</code> and end with <code>show_source</code>.
 +
 
 +
== Configure Nginx ==
 +
 
 +
Oh! Now we need to configure nginx to serve pages as the docs user. Assuming your site is named wiki.mysite.com, create a <code>/etc/nginx/sites-available/wiki.mysite.com</code> file with the following contents:
  
 
<pre>
 
<pre>
e5a6649e094eb7230aa8f56d97fe303f77b158e9 preserve bindist through use expansion
+
server {
5a092fdae8afbff679350dc5d8818e10ab35fd80 safetydance feature
+
        listen 80;
16887ddce712da8b61887f9bce70e19b95e75c25 core funtoo git-sync implementation
+
        server_name wiki.mysite.com;
2c6e2b427a2aa179b61667caf89497818ec34ae2 run pwconv and grpconv after emerge completes to ensure /etc/shadow and /etc/gshadow are valid.
+
 
ea565da9ab5f54580f66814a17aca39d8e568732 funtoo-specific man page changes
+
        access_log /var/log/nginx/wiki.mysite.com.access.log main;
c8f130fa4b332d87f2202ddaf0222b89018914d0 Funtoo config file changes. This includes stuff related to rsync as well as /lib/firmware
+
        error_log /var/log/nginx/wiki.mysite.com.error.log error;
dba5a350e16043a6ff6281ea80fc02c8f56efd4f remove emerge-webrsync -- not supported in funtoo
+
       
0d9dda7b2b3165b268545e3e8eb44aa8d3c20a57 small ebuild.sh fix to not source any stray directories
+
        root /home/docs/public_html;
8500043b3075d26c77a7ec1b8c2745373ca0c3b5 disable warning for use of *, -* in KEYWORDS
+
        index index.html index.php;
86ed81605e73b8b6d6b06fc60a9a0bc0c13ee429 protect firmware as well as modules
+
 
e7b6512e582fbcd9af0eb82c617549b101c8ae97 slashbeast's localpatch feature
+
        # uncomment this if you want to htpasswd-protect your site while you set it up initially
5af34ad9334310c0926e52d9e1801ee170e12184 simplify path setting in ebuild.sh by using getpath() function
+
        # auth_basic "Ninjas allowed only";
42789a70184343008c4cb1fe20bc4398e881d285 remove bin/ebuild-helpers/sed
+
        # auth_basic_user_file /etc/nginx/docs.funtoo.org.htpasswd;
 +
 
 +
location ~* ^(.*)(install.php|LocalSettings.php|\.git) { deny all; }
 +
 
 +
location ~* \.php$ {
 +
        #set $https "off";
 +
        #if ($scheme = https) { set $https "on"; }
 +
        #fastcgi_param HTTPS $https;
 +
 
 +
        try_files      $uri    @404;
 +
        fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
 +
        fastcgi_param  SERVER_SOFTWARE    nginx;
 +
        fastcgi_param  QUERY_STRING      $query_string;
 +
        fastcgi_param  REQUEST_METHOD    $request_method;
 +
        fastcgi_param  CONTENT_TYPE      $content_type;
 +
        fastcgi_param  CONTENT_LENGTH    $content_length;
 +
        fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
 +
        fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
 +
        fastcgi_param  REQUEST_URI        $request_uri;
 +
        fastcgi_param  DOCUMENT_URI      $document_uri;
 +
        fastcgi_param  DOCUMENT_ROOT      $document_root;
 +
        fastcgi_param  SERVER_PROTOCOL    $server_protocol;
 +
        fastcgi_param  REMOTE_ADDR        $remote_addr;
 +
        fastcgi_param  REMOTE_PORT        $remote_port;
 +
        fastcgi_param  SERVER_ADDR        $server_addr;
 +
        fastcgi_param  SERVER_PORT        $server_port;
 +
        fastcgi_param  SERVER_NAME        wiki.mysite.com;
 +
 
 +
        fastcgi_pass    unix:/var/run/docs.php-fpm.socket;
 +
        fastcgi_index  index.php;
 +
}
 +
 
 +
# this will secure the MediaWiki uploads against arbitrary PHP injection attacks:
 +
location /images/ {
 +
        location ~.*\.(php)?$ {
 +
                deny all;
 +
        }
 +
}
 +
 
 +
 
 +
location @404 {
 +
        return 404;
 +
        break;
 +
}
 +
 
 +
location / {
 +
        try_files $uri $uri/ @mediawiki;
 +
}
 +
 
 +
location @mediawiki {
 +
        rewrite ^/([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
 +
}
 +
 
 +
}
 
</pre>
 
</pre>
  
These commits do not yet include the unified-path/funtoo-profile 1.0 patches.
+
for localhost/wiki/ short urls in nginx:
 +
{{file|name=/etc/nginx/sites-enabled/localhost|lang=|desc=domain.com/wiki/ short urls|body=
 +
location /wiki {
 +
index index.php;
 +
rewrite "^(wiki)$" $1/ permanent;
 +
rewrite "^/?wiki(/.*)?" /mediawiki/index.php?title=$1&$args last;
 +
 +
}}
  
==== In Funtoo stable/current Portage ====
+
== Enable Ngnix and PHP-FPM ==
  
;emerge --sync from git
+
Now, let's enable nginx to serve our site, and also be sure to enable php-fpm:
:If a git-based Portage tree is already in place, <tt>emerge --sync</tt> will run "git pull" to update the underlying Portage tree. If one is not in place, the contents of the SYNC variable will be used as the remote URI from which to clone a git tree (2.2). In addition, SYNC_USER and SYNC_UMASK (defaulting to root and 022) can be used to define the user account to use for cloning/syncing, as well as the umask to use. (2.2).
+
  
;Sed Wrapper Symlink and PATH fix
+
<console>
: The Funtoo version of Portage has replaced the BSD-only sed wrapper with a symlink. This will eventually be deprecated. The sed wrapper was a way to provide BSD systems with a "sed" command that could be used inside ebuilds that worked similarly to GNU sed. A PATH fix has been applied so that /bin/sed will be detected first anyway.
+
# ##i##cd /etc/nginx/sites-enabled
 +
# ##i##ln -s ../sites-available/wiki.mysite.com wiki.mysite.com
 +
# ##i##rc-update add nginx default
 +
# ##i##rc-update add php-fpm default
 +
# ##i##rc
 +
* Starting PHP FastCGI Process Manager ...                                                            [ ok ]
 +
* Starting nginx ...                                                                                  [ ok ]
 +
#
 +
</console>
  
;mini-manifest
+
== MediaWiki from portage ==
:Funtoo's Portage supports a special mode of operation where Manifests only contain digests for distfiles and not for files in the Portage tree. This is to eliminate redundant digests since git already provides SHA1 digests. This feature is currently enabled by adding "mini-manifest" to FEATURES in /etc/make.conf but the intention is to eventually move it to a repo-specific option (note: this has now been done, as "thin-manifest" functionality has been integrated into recent versions of Portage, and is being beta tested in Funtoo.) Funtoo provides a special "mini-manifest" tree that is smaller than the full-size Portage tree, and is intended to be used with the mini-manifest feature.
+
There are mediawiki ebuilds in portage, if you like your site breaking upon emerge --sync && emerge -avuND world:
  
;preserve bindist through USE filtering
+
<console>###i## emerge mediawiki</console>
: Normally, anything not in an ebuild's IUSE is stripped from the USE passed to ebuild.sh. This patch allows "bindist" to not be stripped, so it can be used as a means to disable pre-merge sanity checks that may exist in pkg_setup() and pkg_pretend() but will not otherwise affect the resultant build. If "bindist" will affect some functionality in the package, then it should be added to an ebuild's IUSE. This patch allows pkg_setup() and pkg_pretend() to look for "bindist", which indicates that the ebuild is being built for release, typically in an automated fashion, and thus runtime sanity checks that might otherwise run can be optionally skipped. This check is used by the udev-160-r1.ebuild to see if we should fail if we are merging udev on a system where the kernel will not support it. In Metro, this is not a big deal, but on a ''real'' production system, merging the udev on an incompatible system will render the kernel inoperable.
+
  
;safetydance FEATURE
+
With out the vhost flag the files will be dropped into /var/www/localhost/htdocs/mediawiki.
:A new FEATURE setting is used by Funtoo's udev ebuild called "safetydance" which can be used to manually bypass sanity checks. This is an alternative to the "bindist" approach above. udev-160 in Funtoo Linux supports both approaches and Metro sets "safetydance" by default.
+
  
;GLEP 55 removal
+
== Download MediaWiki ==
:Some code to support GLEP 55 has been removed.
+
 
 +
We're getting close. Now, head to http://www.mediawiki.org/wiki/Download and copy the link address for the latest version of MediaWiki, currently 1.19.1 at the time this was written. Let's download the archive to <code>/var/tmp</code>:
 +
 
 +
<console>
 +
# ##i##cd /var/tmp
 +
# ##i##wget http://download.wikimedia.org/mediawiki/1.19/mediawiki-1.19.1.tar.gz
 +
</console>
 +
 
 +
== Extract MediaWiki ==
 +
 
 +
We now have all the Web, database and email infrastructure enabled that we need. Heading to the IP address of your server should result in a 404 - Not Found error in your Web browser. Time to extract and configure MediaWiki itself:
 +
 
 +
<console>
 +
# ##i##su docs
 +
$ ##i##cd /var/tmp
 +
$ ##i##tar xvf ./mediawiki-1.19.1.tar.gz
 +
$ ##i##mv mediawiki-1.19.1 ~/public_html
 +
</console>
 +
 
 +
== MediaWiki from GIT ==
 +
 
 +
Alternatively, we can download the code from the git repository:
 +
 
 +
<console>
 +
# ##i##su docs
 +
$ ##i##cd ~
 +
$ ##i##git clone https://gerrit.wikimedia.org/r/p/mediawiki/core.git public_html
 +
</console>
 +
 
 +
Specific stable versions of MediaWiki are tracked using 'tags'. These are analogous to the tarball releases. We can see the versions available with:
 +
<console>
 +
$ ##i##cd public_html
 +
$ ##i##git tag -l | sort -V
 +
</console>
 +
 
 +
To use a specific tag (1.19.1):
 +
<console>
 +
$ ##i##git checkout 1.19.1
 +
</console>
 +
 
 +
== Initial Web Config ==
 +
 
 +
You will now be able to load the URL of your server in your Web browser and configure MediaWiki through the Web user interface. Complete the '''full''' installation process and be sure to specify that you are using XCache for caching. Once you go through this process, the Web installation process will provide you with a <code>LocalSettings.php</code> file, which you should place in <code>/home/docs/public_html</code>. The <code>LocalSettings.php</code> file can also be manually edited and used to enable MediaWiki features and extensions.
 +
 
 +
== Tips and Tricks ==
 +
 
 +
=== Alternate Main Page ===
 +
To define your default landing page for mediawiki.
 +
edit: localhost/wiki/MediaWiki:Mainpage
 +
 
 +
example: http://www.funtoo.org/MediaWiki:Mainpage
 +
 
 +
=== Arbitrary Page Titles ===
 +
To change a page's title from domain.com/Main_Page to "title" insert this magic word in the page:
 +
 
 +
*<nowiki>{{DISPLAYTITLE:title}}</nowiki>
 +
 
 +
=== Show Php handler, Database & Plugins Used ===
 +
To show which plugins are installed on a wiki, browse localhost/wiki/Special:Version.
 +
 
 +
example: http://funtoo.org/Special:Version
 +
 
 +
=== Sidebar ===
 +
To define your own sidebar links, edit localhost/wiki/MediaWiki:Sidebar
 +
 
 +
links follow the page|text format.  example:
 +
http://www.funtoo.org/MediaWiki:Sidebar
 +
 
 +
=== Rss subscriptions ===
 +
Rss is handy to track page changes.  all individual pages can be tracked for changes under mediawiki.  For example, if you wish to track your user talk pages via rss, go to your talk page, navigate to history.  add &feed=rss to the end.  &feed=atom is also valid.
 +
 
 +
http://www.funtoo.org/index.php?title=User:Drobbins&action=history&feed=rss
 +
 
 +
 
 +
=== ArticlePath ===
 +
 
 +
By default, MediaWiki pages will have a URL of <code>wiki.myserver.com/index.php?title=PageName</code>. With a few minor tweaks, you can tell MediaWiki to use <code>wiki.myserver.com/PageName</code> instead. Here's how. Open up <code>LocalSettings.php</code> and search for the <code>$wgScriptPath</code> line. This part of the config will look like this:
 +
 
 +
<pre>
 +
$wgScriptPath      = "";
 +
$wgScriptExtension  = ".php";
 +
</pre>
 +
 
 +
Change this part of the file to look like this:
 +
 
 +
<pre>
 +
$wgScriptPath      = "";
 +
$wgArticlePath      = "/$1";
 +
$wgUsePathInfo      = true;
 +
$wgScriptExtension  = ".php";
 +
</pre>
 +
 
 +
The old-style URLs will still work, but the shorter more intuitive URLs will now be used for all wiki links.
 +
 
 +
=== $wgSpamRegex ===
 +
 
 +
You may find that your wiki is the target of spammers. The easiest way to combat spam is to set <code>$wgSpamRegex</code> in <code>LocalSettings.php</code>, like so:
 +
 
 +
<pre>
 +
$wgSpamRegex = "/badword1|badword2|badword3/i"
 +
</pre>
 +
 
 +
This will perform a case-insensitive match against the bad words and block anyone from saving edits that contain these words.
 +
 
 +
=== DNS Blacklist ===
 +
 
 +
MediaWiki also has the ability to consult a DNS blacklist to prevent known forum and wiki spam sites from performing any edits on your wiki. To enable this capability, add the following to <code>LocalSettings.php</code>:
 +
 
 +
<pre>
 +
$wgEnableDnsBlacklist = true;
 +
$wgDnsBlacklistUrls = array( 'xbl.spamhaus.org', 'opm.tornevall.org' );
 +
</pre>
 +
 
 +
You may notice a significant decrease in spam posts.
 +
 
 +
=== $wgExternalLinkTarget ===
 +
For external links if you wish for the link to open a new tab or new window for the external link add this to your LocalSettings.php
 +
 
 +
{{file|name=/var/www/localhost/htdocs/mediawiki/LocalSettings.php|lang=php|desc=set external links to open in a new tab|body=
 +
...
 +
$wgExternalLinkTarget = '_blank';
 +
}}
 +
 
 +
=== $wgRawHtml ===
 +
 
 +
{{warning|raw html can be dangerous regarding injecting spam/malicious/fishing pages.  use with care!}}
 +
 
 +
To allow any raw html inserted into your wiki:
 +
 
 +
{{file|name=/var/www/localhost/htdocs/mediawiki/LocalSettings.php|lang=php|desc=enabling arbitrary html|body=
 +
...
 +
$wgRawHtml = "true";
 +
}}
 +
 
 +
=== $wgServer ===
 +
 
 +
Here is an important tip -- the <code>$wgServer</code> variable in <code>LocalSettings.php</code> defines the URL of your MediaWiki installation. MediaWiki will encode this within its HTML replies, which means that the Web browser from which you are accessing MediaWiki must be able to reach your server using this address, or pages will not display. This is not a security feature in any way, but a configuration issue. For example, if <code>$wgServer</code> is set to <code>10.0.1.128</code>, then the only systems that will be able to access your MediaWiki installation are those for which <code>10.0.1.128</code> resolves to your MediaWiki installation.  The same is true of non-IP <code>$wgServer</code> entries like <code>wiki.mysite.com</code>. If you are setting up a test wiki, you may need a temporary entry in a desktop's <code>/etc/hosts</code> file so that it can interact with the wiki properly before DNS is set up.
 +
 
 +
=== $wgLogo ===
 +
 
 +
If you want to change the wiki logo, edit <code>LocalSettings.php</code> and replace $wgLogo with the location of the image you want to use:
 +
 
 +
<pre>
 +
$wgLogo = "image.png"
 +
</pre>
 +
{{fancynote| The above references the file <code>image.png</code> in the directory <code>/home/docs/public_html</code>}}
 +
 
 +
=== MySQL wildcard searches ===
 +
Recent versions of mediawiki have broken search results.
 +
 
 +
{{file|name=/var/www/localhost/htdocs/mediawiki/includes/search/SearchMySQL.php|lang=php|desc=line 175 modification to repair mysql searches|body=
 +
if ( trim( $term ) === '' ) {
 +
return null;
 +
} else {
 +
$term = $term . '*';
 +
}
 +
}}
 +
 
 +
=== License Badges ===
 +
You can have licenses displayed with your pages.
 +
 
 +
{{file|name=/var/www/localhost/htdocs/mediawiki/LocalSettings.php|lang=php|desc=add license badge to articles|body=
 +
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
 +
$wgRightsUrl = "http://creativecommons.org/licenses/by-sa/3.0/"; //external source explaining license
 +
$wgRightsText = "Creative Commons Attribution Share Alike"; //alternate text on the image
 +
$wgRightsIcon = "{$wgStylePath}/common/images/cc-by-sa.png";
 +
}}
 +
 
 +
There are 6 possible badge images
 +
 
 +
* {$wgStylePath}/common/images/cc-0.png
 +
* {$wgStylePath}/common/images/cc-by-nc-sa.png
 +
* {$wgStylePath}/common/images/cc-by-sa.png
 +
* {$wgStylePath}/common/images/cc-by.png
 +
* {$wgStylePath}/common/images/gnu-fdl.png
 +
* {$wgStylePath}/common/images/public-domain.png
 +
 
 +
=== Importing Google Fonts & External Css ===
 +
Googles font api is excellent.  all you have to do is look through https://www.google.com/fonts# and select which font you want.  To the bottom right of the font pane is a little box with an arrow pointing right.  click the arrow, and follow step 1, and 2.  for step 3 you need to select @import.  on your wiki navigate to localhost/MediaWiki:Common.css or a specific skin to add the css to like localhost/MediaWiki:Vector.css and enter this code.
 +
 
 +
{{file|name=localhost/MediaWiki:Common.css|lang=css|desc=|body=
 +
@import url(http://fonts.googleapis.com/css?family=Lobster);
 +
 
 +
.firstHeading, #mw-head, .body ul li {
 +
font-family: 'Lobster', cursive;
 +
}
 +
}}
 +
 
 +
External css is similar, if you wanted to bootswatch your wiki navigate to http://www.bootstrapcdn.com/#bootswatch_tab select which cdn and insert it into your common css.
 +
 
 +
{{file|name=localhost/MediaWiki:Common.css|lang=css|desc=yeti for the sasquatch hunter in you|body=
 +
@import url(//maxcdn.bootstrapcdn.com/bootswatch/3.2.0/yeti/bootstrap.min.css);
 +
}}
  
;new metadata format (experimental)
+
== Media ==
:Some tweaks to ebuild.sh have been made so that it is easier to support new metadata formats in the future.
+
{{#widget:YouTube|playlist=PL7ABDor6eEgc2U9PH4Irty4K8mqUgkvDq}}
  
;xz-utils auto-dependency
+
== External Resources ==
:There are several ebuilds in the Gentoo Portage repository that use .xz files but do not explicitly depend on xz-utils. A workaround has been added to ebuild.sh to add this dependency to metadata automatically if a .xz file exists in SRC_URI. This change is not yet in the official Portage sources but is being used on the Funtoo side when generating our git-based Portage trees.
+
* http://www.mediawiki.org/wiki/Manual:System_administration
 +
* http://www.mediawiki.org/wiki/Manual:Performance_tuning
 +
* http://www.mediawiki.org/wiki/Help:Templates
 +
* http://www.mediawiki.org/wiki/Transclusion
  
[[Category:Projects]]
+
[[Category:Featured]]
[[Category:Portage]]
+
[[Category:HOWTO]]
 +
[[Category:Official Documentation]]
 +
[[Category:Ebuilds]]
 
{{EbuildFooter}}
 
{{EbuildFooter}}

Revision as of 09:52, January 10, 2015

www-apps/mediawiki


Current Maintainer(s):Daniel Robbins
Source Repository:Gentoo Portage Tree

Summary:


News

Drobbins

Pre-built kernels!

Funtoo stage3's are now starting to offer pre-built kernels for ease of install. read more....
12 May 2015 by Drobbins
Drobbins

Better Experiences: Ego and Vim

Info on Funtoo's new personality tool called 'ego', and user-focused updates to vim's defaults.
27 April 2015 by Drobbins
Drobbins

How We're Keeping You At the Center of the Funtoo Universe

Read about recent developments that keep you, our users, at the forefront of our focus as Funtoo moves forward.
10 April 2015 by Drobbins
View More News...

MediaWiki

Tip

This is a wiki page. To edit it, Create a Funtoo account. Then log in and then click here to edit this page. See our editing guidelines to becoming a wiki-editing pro.


Important

This page documents how to install MediaWiki from source tarball rather than portage, which is the preferred method. It also shows how to use MediaWiki with php-5.4. As of late 1.22 and 1.23, MediaWiki now unofficially works with php-5.5 & php-5.6.

MediaWiki is a Web-server-stack web application. This page documents how to set up MediaWiki on Funtoo Linux, from a bare stage3 install with network connectivity. We will use Nginx, xcache and PHP-FPM, which will result in good performance. We will also properly secure MediaWiki, and also cover some additional tips and tricks, focusing on spam reduction.

Portage Settings

Add the following line to /etc/make.conf:


PHP_TARGETS="php5-4"

Add the following lines to /etc/portage/package.use/php:

dev-lang/php curl exif fpm gd mysql mysqli sockets suhosin threads intl xmlreader xmlwriter
>=dev-php/xcache-2.0.0 php_targets_php5-4

Emerge

Emerge xcache, and we'll also emerge metalog and postfix. This should pull in MySQL as well as php-5.4:

# emerge --jobs xcache metalog postfix

Start and Configure Services

Time to configure MySQL with a root password, start it, secure it, and enable it to start at boot. We'll also start metalog and postfix:

# emerge --config mysql
# rc-update add mysql default
# rc-update add metalog default
# rc-update add postfix default
# rc
# mysql_secure_installation

Database Setup

Now, let's create a database named mediawiki for use by MediaWiki, and a mediawiki@localhost user to access this database, using a password of wikifever:

# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.1.62-log Gentoo Linux mysql-5.1.62-r1

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database mediawiki;
Query OK, 1 row affected (0.01 sec)

mysql> grant index, create, select, insert, update, delete, alter, lock tables on mediawiki.* to 'mediawiki'@'localhost' identified by 'wikifever';
Query OK, 0 rows affected (0.01 sec)

mysql> \q
Bye
# 

Nginx Setup

We will use nginx as our Web server. Let's emerge it:

# emerge --jobs nginx

User and Group

When we run our wiki, we will run it as the docs user, for security. Let's set up a docs user and group:

# groupadd docs
# useradd -g docs --home /home/docs docs
# install -d /home/docs
# chown -R docs:docs /home/docs

Set up PHP

As our last major configuration step, we will configure the PHP FastCGI Process Manager by creating a /etc/php/fpm-php5.4/php-fpm.conf file with the following contents (existing contents can be deleted):

/etc/php/fpm-php5.4/php-fpm.conf
[global]
error_log = /var/log/php-fpm.log
log_level = notice

[docs]
listen = /var/run/docs.php-fpm.socket
listen.allowed_clients = 127.0.0.1
listen.owner = docs
listen.group = nginx
listen.mode = 0660
user = docs
group = docs
pm = dynamic
pm.max_children = 16
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 2
pm.max_requests = 500
php_admin_value[open_basedir] = /home/docs/public_html:/tmp
php_admin_value[error_log] = /home/docs/php-errors.log
php_admin_value[disable_functions] = exec, system, shell_exec, passthru, popen, dl, curl_multi_exec, posix_getpwuid, 
 disk_total_space, disk_free_space, escapeshellcmd, escapeshellarg, eval, get_current_user, getmyuid, getmygid, 
 posix_getgrgid, parse_ini_file, proc_get-status, proc_nice, proc_terminate, suexec, pclose, virtual, set_time_limit, show_source

This configuration file tells PHP to use the docs user when running MediaWiki. Please note that the last line is very long - I have split it into 3 lines for readability on this wiki, but you should combine them into a single line in your configuration file. The line should start with php_admin_value[disable_functions] and end with show_source.

Configure Nginx

Oh! Now we need to configure nginx to serve pages as the docs user. Assuming your site is named wiki.mysite.com, create a /etc/nginx/sites-available/wiki.mysite.com file with the following contents:

server {
        listen 80;
        server_name wiki.mysite.com;

        access_log /var/log/nginx/wiki.mysite.com.access.log main;
        error_log /var/log/nginx/wiki.mysite.com.error.log error;
        
        root /home/docs/public_html;
        index index.html index.php;

        # uncomment this if you want to htpasswd-protect your site while you set it up initially
        # auth_basic "Ninjas allowed only";
        # auth_basic_user_file /etc/nginx/docs.funtoo.org.htpasswd;

location ~* ^(.*)(install.php|LocalSettings.php|\.git) { deny all; }

location ~* \.php$ {
        #set $https "off"; 
        #if ($scheme = https) { set $https "on"; }
        #fastcgi_param HTTPS $https;

        try_files       $uri    @404;
        fastcgi_param   GATEWAY_INTERFACE  CGI/1.1;
        fastcgi_param   SERVER_SOFTWARE    nginx;
        fastcgi_param   QUERY_STRING       $query_string;
        fastcgi_param   REQUEST_METHOD     $request_method;
        fastcgi_param   CONTENT_TYPE       $content_type;
        fastcgi_param   CONTENT_LENGTH     $content_length;
        fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
        fastcgi_param   REQUEST_URI        $request_uri;
        fastcgi_param   DOCUMENT_URI       $document_uri;
        fastcgi_param   DOCUMENT_ROOT      $document_root;
        fastcgi_param   SERVER_PROTOCOL    $server_protocol;
        fastcgi_param   REMOTE_ADDR        $remote_addr;
        fastcgi_param   REMOTE_PORT        $remote_port;
        fastcgi_param   SERVER_ADDR        $server_addr;
        fastcgi_param   SERVER_PORT        $server_port;
        fastcgi_param   SERVER_NAME        wiki.mysite.com;

        fastcgi_pass    unix:/var/run/docs.php-fpm.socket;
        fastcgi_index   index.php;
}

# this will secure the MediaWiki uploads against arbitrary PHP injection attacks:
location /images/ {
        location ~.*\.(php)?$ {
                deny all;
        }
}


location @404 {
        return 404;
        break;
}

location / {
        try_files $uri $uri/ @mediawiki;
}

location @mediawiki {
        rewrite ^/([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
}

}

for localhost/wiki/ short urls in nginx:

/etc/nginx/sites-enabled/localhost - domain.com/wiki/ short urls
location /wiki {
		index index.php;
		rewrite "^(wiki)$" $1/ permanent;
		rewrite "^/?wiki(/.*)?" /mediawiki/index.php?title=$1&$args last;
	}

Enable Ngnix and PHP-FPM

Now, let's enable nginx to serve our site, and also be sure to enable php-fpm:

# cd /etc/nginx/sites-enabled
# ln -s ../sites-available/wiki.mysite.com wiki.mysite.com
# rc-update add nginx default
# rc-update add php-fpm default
# rc
 * Starting PHP FastCGI Process Manager ...                                                            [ ok ]
 * Starting nginx ...                                                                                  [ ok ]
#

MediaWiki from portage

There are mediawiki ebuilds in portage, if you like your site breaking upon emerge --sync && emerge -avuND world:

# emerge mediawiki

With out the vhost flag the files will be dropped into /var/www/localhost/htdocs/mediawiki.

Download MediaWiki

We're getting close. Now, head to http://www.mediawiki.org/wiki/Download and copy the link address for the latest version of MediaWiki, currently 1.19.1 at the time this was written. Let's download the archive to /var/tmp:

# cd /var/tmp
# wget http://download.wikimedia.org/mediawiki/1.19/mediawiki-1.19.1.tar.gz

Extract MediaWiki

We now have all the Web, database and email infrastructure enabled that we need. Heading to the IP address of your server should result in a 404 - Not Found error in your Web browser. Time to extract and configure MediaWiki itself:

# su docs
$ cd /var/tmp
$ tar xvf ./mediawiki-1.19.1.tar.gz
$ mv mediawiki-1.19.1 ~/public_html

MediaWiki from GIT

Alternatively, we can download the code from the git repository:

# su docs
$ cd ~
$ git clone https://gerrit.wikimedia.org/r/p/mediawiki/core.git public_html

Specific stable versions of MediaWiki are tracked using 'tags'. These are analogous to the tarball releases. We can see the versions available with:

$ cd public_html
$ git tag -l | sort -V

To use a specific tag (1.19.1):

$ git checkout 1.19.1

Initial Web Config

You will now be able to load the URL of your server in your Web browser and configure MediaWiki through the Web user interface. Complete the full installation process and be sure to specify that you are using XCache for caching. Once you go through this process, the Web installation process will provide you with a LocalSettings.php file, which you should place in /home/docs/public_html. The LocalSettings.php file can also be manually edited and used to enable MediaWiki features and extensions.

Tips and Tricks

Alternate Main Page

To define your default landing page for mediawiki. edit: localhost/wiki/MediaWiki:Mainpage

example: http://www.funtoo.org/MediaWiki:Mainpage

Arbitrary Page Titles

To change a page's title from domain.com/Main_Page to "title" insert this magic word in the page:

  • {{DISPLAYTITLE:title}}

Show Php handler, Database & Plugins Used

To show which plugins are installed on a wiki, browse localhost/wiki/Special:Version.

example: http://funtoo.org/Special:Version

Sidebar

To define your own sidebar links, edit localhost/wiki/MediaWiki:Sidebar

links follow the page|text format. example: http://www.funtoo.org/MediaWiki:Sidebar

Rss subscriptions

Rss is handy to track page changes. all individual pages can be tracked for changes under mediawiki. For example, if you wish to track your user talk pages via rss, go to your talk page, navigate to history. add &feed=rss to the end. &feed=atom is also valid.

http://www.funtoo.org/index.php?title=User:Drobbins&action=history&feed=rss


ArticlePath

By default, MediaWiki pages will have a URL of wiki.myserver.com/index.php?title=PageName. With a few minor tweaks, you can tell MediaWiki to use wiki.myserver.com/PageName instead. Here's how. Open up LocalSettings.php and search for the $wgScriptPath line. This part of the config will look like this:

$wgScriptPath       = "";
$wgScriptExtension  = ".php";

Change this part of the file to look like this:

$wgScriptPath       = "";
$wgArticlePath      = "/$1";
$wgUsePathInfo      = true;
$wgScriptExtension  = ".php";

The old-style URLs will still work, but the shorter more intuitive URLs will now be used for all wiki links.

$wgSpamRegex

You may find that your wiki is the target of spammers. The easiest way to combat spam is to set $wgSpamRegex in LocalSettings.php, like so:

$wgSpamRegex = "/badword1|badword2|badword3/i"

This will perform a case-insensitive match against the bad words and block anyone from saving edits that contain these words.

DNS Blacklist

MediaWiki also has the ability to consult a DNS blacklist to prevent known forum and wiki spam sites from performing any edits on your wiki. To enable this capability, add the following to LocalSettings.php:

$wgEnableDnsBlacklist = true;
$wgDnsBlacklistUrls = array( 'xbl.spamhaus.org', 'opm.tornevall.org' );

You may notice a significant decrease in spam posts.

$wgExternalLinkTarget

For external links if you wish for the link to open a new tab or new window for the external link add this to your LocalSettings.php

/var/www/localhost/htdocs/mediawiki/LocalSettings.php (php source code) - set external links to open in a new tab
...
 $wgExternalLinkTarget = '_blank';

$wgRawHtml

Warning

raw html can be dangerous regarding injecting spam/malicious/fishing pages. use with care!

To allow any raw html inserted into your wiki:

/var/www/localhost/htdocs/mediawiki/LocalSettings.php (php source code) - enabling arbitrary html
...
$wgRawHtml = "true";

$wgServer

Here is an important tip -- the $wgServer variable in LocalSettings.php defines the URL of your MediaWiki installation. MediaWiki will encode this within its HTML replies, which means that the Web browser from which you are accessing MediaWiki must be able to reach your server using this address, or pages will not display. This is not a security feature in any way, but a configuration issue. For example, if $wgServer is set to 10.0.1.128, then the only systems that will be able to access your MediaWiki installation are those for which 10.0.1.128 resolves to your MediaWiki installation. The same is true of non-IP $wgServer entries like wiki.mysite.com. If you are setting up a test wiki, you may need a temporary entry in a desktop's /etc/hosts file so that it can interact with the wiki properly before DNS is set up.

If you want to change the wiki logo, edit LocalSettings.php and replace $wgLogo with the location of the image you want to use:

$wgLogo = "image.png"
Note
The above references the file image.png in the directory /home/docs/public_html

MySQL wildcard searches

Recent versions of mediawiki have broken search results.

/var/www/localhost/htdocs/mediawiki/includes/search/SearchMySQL.php (php source code) - line 175 modification to repair mysql searches
if ( trim( $term ) === '' ) {
			return null;
		} else {
			$term = $term . '*';
		}

License Badges

You can have licenses displayed with your pages.

/var/www/localhost/htdocs/mediawiki/LocalSettings.php (php source code) - add license badge to articles
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "http://creativecommons.org/licenses/by-sa/3.0/"; //external source explaining license
$wgRightsText = "Creative Commons Attribution Share Alike"; //alternate text on the image
$wgRightsIcon = "{$wgStylePath}/common/images/cc-by-sa.png";

There are 6 possible badge images

  • {$wgStylePath}/common/images/cc-0.png
  • {$wgStylePath}/common/images/cc-by-nc-sa.png
  • {$wgStylePath}/common/images/cc-by-sa.png
  • {$wgStylePath}/common/images/cc-by.png
  • {$wgStylePath}/common/images/gnu-fdl.png
  • {$wgStylePath}/common/images/public-domain.png

Importing Google Fonts & External Css

Googles font api is excellent. all you have to do is look through https://www.google.com/fonts# and select which font you want. To the bottom right of the font pane is a little box with an arrow pointing right. click the arrow, and follow step 1, and 2. for step 3 you need to select @import. on your wiki navigate to localhost/MediaWiki:Common.css or a specific skin to add the css to like localhost/MediaWiki:Vector.css and enter this code.

localhost/MediaWiki:Common.css (css source code)
@import url(http://fonts.googleapis.com/css?family=Lobster);
 
.firstHeading, #mw-head, .body ul li {
font-family: 'Lobster', cursive;
}

External css is similar, if you wanted to bootswatch your wiki navigate to http://www.bootstrapcdn.com/#bootswatch_tab select which cdn and insert it into your common css.

localhost/MediaWiki:Common.css (css source code) - yeti for the sasquatch hunter in you
@import url(//maxcdn.bootstrapcdn.com/bootswatch/3.2.0/yeti/bootstrap.min.css);

Media

External Resources