Mediawiki installation on CentOS 6

Embedded DB wiki backup (sqlite)
cd /var/www/html/wiki/
php maintenance/sqlite.php --backup-to /home/user/wikisqlitedb-2017_01_27.backup

cd /var/www/html/
tar zcvfh wikidata2017_01_27.tar.gz wiki

cd /var/www/html/wiki
php maintenance/dumpBackup.php --full > dump-2017_01_27.xml

Mediawiki installation and configuration
Be careful, you have to create main page (there’s no way to import main page with xml import feature). Copy main page source code from the old mediawiki server!

yum install httpd php php-gd php-xml postgresql postgresql-server php-pgsql

chkconfig --level 345 postgresql on
chkconfig --level 345 httpd on

service postgresql initdb

vi /var/lib/pgsql/data/postgresql.conf
listen_addresses = 'localhost'
port = 5432

cat << _EOT >> /var/lib/pgsql/data/pg_hba.conf
local all postgres trust
local all all md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
_EOF

service postgresql start

su - postgres

psql -c "alter user postgres with password 'password'"

semanage boolean -m --on httpd_can_network_connect_db

vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

service httpd restart

wget http://releases.wikimedia.org/mediawiki/1.24/mediawiki-1.24.1.tar.gz
tar zxvf mediawiki-1.24.1.tar.gz

vi /etc/httpd/conf.d/mediawiki.conf

### MediaWiki Configuration
Alias /wiki /var/www/html/wiki
<Directory /var/www/html/wiki>
  Options Indexes FollowSymLinks
  AllowOverride None
  Order allow,deny
  # Uncomment this if you have no restrictions
  Allow from all 
  # For restrictive networks, consider using the
  # below and tailoring it to your likings 
  #Allow from 127.0.0.1
  #Allow from 192.168.0. 

RewriteEngine On 
  # so skins, images and extensions work
  RewriteRule ^(images|skins|extensions)/ - [L]

  # Forces specified index page to go ahead and load
  RewriteRule ^(load|index).php - [L] 
  # The following makes it so if our configuration file isn't
  # present we will always catch this rewrite rule (allowing the 
  # user to set up mediawiki)  
  RewriteCond /usr/share/mediawiki/LocalSettings.php !-f
  RewriteRule ^(.+)  -  [PT] 
  # Path Formating
  RewriteRule ^/*$ /wiki/index.php?title=Main_Page [L,QSA]
  RewriteRule ^/*(.+)$ /wiki/index.php?title=$1 [PT,L,QSA] 
  ## Support colon (:)
  RewriteRule ^/(.*:.*)$  /wiki/index.php?title=$1 [L]
 </Directory>

 <Directory "/var/www/html/wiki/images">
 # Ignore .htaccess files
 AllowOverride None  

# Serve HTML as plaintext, don't execute SHTML
  AddType text/plain .html .htm .shtml .php 
 # Don't run arbitrary PHP code. php_admin_flag engine off 

RewriteEngine On
 RewriteCond %{QUERY_STRING} \.[^\\/:*?\x22|%]+(#|\?|$) [nocase]
 RewriteRule . - [forbidden]  
# If you've other scripting languages, disable them too.
 </Directory>

Go to http://Wiki_IP/wiki to configure and generate LocalSettings.php. Copy LocalSettings.php to wiki dir

Import content from old wiki
cd /var/www/html/wiki/
php maintenance/importDump.php < dumpfile.xml

Mediawiki AD integration
Go to http://www.mediawiki.org/wiki/Special:ExtensionDistributor/LdapAuthentication
https://extdist.wmflabs.org/dist/extensions/LdapAuthentication-REL1_24-24a399e.tar.gz
tar -xzf LdapAuthentication-REL1_24-24a399e.tar.gz -C /var/www/html/wiki/extensions

yum install php-ldap

require_once( "$IP/extensions/LdapAuthentication/LdapAuthentication.php" );
$wgAuth = new LdapAuthenticationPlugin();
$wgLDAPDomainNames = array( "SUB1" );
$wgLDAPServerNames = array( "SUB1" => "dc01.sub1.domain.com" );
$wgLDAPSearchStrings = array( "SUB1" => "USER-NAME@SUB1" );
$wgLDAPEncryptionType = array( "SUB1" => "clear" );
$wgLDAPBaseDNs = array( "SUB1" => "dc=sub1,dc=domain,dc=com" );
$wgLDAPSearchAttributes = array( "SUB1" => "sAMAccountName" );
$wgLDAPProxyAgent = array("SUB1" => "CN=wikiop,OU=Other,OU=Users,OU=Administrative,DC=sub1,DC=domain,DC=com");
$wgLDAPProxyAgentPassword = array("SUB1" => "password");
$wgLDAPUseLocal = false;
$wgMinimalPasswordLength = 1;
$wgLDAPDebug = 3; //for debugging LDAP
$wgShowExceptionDetails = true; //for debugging MediaWiki
$wgDebugLogFile = "/var/log/mediawiki/debug-{$wgDBname}.log";
$wgLDAPBaseDNs = array( "SUB1" => "dc=sub1,dc=domain,dc=com" );
$wgLDAPRetrievePrefs = array( "SUB1" => "true" );

php maintenance/update.php

PostrgeSQL DB backup
pg_dump wikidb > wikidbdump2017_01_28.sql
pg_dumpall --globals > postgres_globals2017_01_28.sql

Leave a comment

You must be logged in to post a comment.