{"id":771,"date":"2017-09-12T20:47:50","date_gmt":"2017-09-12T13:47:50","guid":{"rendered":"https:\/\/trichev.com\/blog\/?p=771"},"modified":"2017-09-27T22:03:03","modified_gmt":"2017-09-27T15:03:03","slug":"mediawiki-installation-on-centos-6","status":"publish","type":"post","link":"https:\/\/trichev.com\/blog\/2017\/09\/12\/mediawiki-installation-on-centos-6\/","title":{"rendered":"Mediawiki installation on CentOS 6"},"content":{"rendered":"<p><strong>Embedded DB wiki backup (sqlite)<\/strong><br \/>\n<code>cd \/var\/www\/html\/wiki\/<br \/>\nphp maintenance\/sqlite.php --backup-to \/home\/user\/wikisqlitedb-2017_01_27.backup<\/code><\/p>\n<p><code>cd \/var\/www\/html\/<br \/>\ntar zcvfh wikidata2017_01_27.tar.gz wiki<\/code><\/p>\n<p><code>cd \/var\/www\/html\/wiki<br \/>\nphp maintenance\/dumpBackup.php --full &gt; dump-2017_01_27.xml<\/code><\/p>\n<p><strong>Mediawiki installation and configuration<\/strong><br \/>\nBe careful, you have to create main page (there&#8217;s no way to import main page with xml import feature). Copy main page source code from the old mediawiki server!<br \/>\n<code><br \/>\nyum install httpd php php-gd php-xml postgresql postgresql-server php-pgsql<\/code><\/p>\n<p><code>chkconfig --level 345 postgresql on<br \/>\nchkconfig --level 345 httpd on<\/code><\/p>\n<p><code>service postgresql initdb<\/code><\/p>\n<p><code>vi \/var\/lib\/pgsql\/data\/postgresql.conf<br \/>\nlisten_addresses = 'localhost'<br \/>\nport = 5432<\/code><\/p>\n<p><code>cat &lt;&lt; _EOT &gt;&gt; \/var\/lib\/pgsql\/data\/pg_hba.conf<br \/>\nlocal all postgres trust<br \/>\nlocal all all md5<br \/>\nhost all all 127.0.0.1\/32 md5<br \/>\nhost all all ::1\/128 md5<br \/>\n_EOF<\/code><\/p>\n<p><code>service postgresql start<\/code><\/p>\n<p><code>su - postgres<\/code><\/p>\n<p><code>psql -c \"alter user postgres with password 'password'\"<\/code><br \/>\n<code><br \/>\nsemanage boolean -m --on httpd_can_network_connect_db<\/code><\/p>\n<p><code>vi \/etc\/sysconfig\/iptables<br \/>\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT<\/code><\/p>\n<p><code>service httpd restart<\/code><\/p>\n<p><code>wget http:\/\/releases.wikimedia.org\/mediawiki\/1.24\/mediawiki-1.24.1.tar.gz<br \/>\ntar zxvf mediawiki-1.24.1.tar.gz<\/code><\/p>\n<p><code>vi \/etc\/httpd\/conf.d\/mediawiki.conf<\/code><\/p>\n<pre><code>### MediaWiki Configuration\r\nAlias \/wiki \/var\/www\/html\/wiki\r\n&lt;Directory \/var\/www\/html\/wiki&gt;\r\n  Options Indexes FollowSymLinks\r\n  AllowOverride None\r\n  Order allow,deny\r\n  # Uncomment this if you have no restrictions\r\n  Allow from all<\/code> <code>\r\n  # For restrictive networks, consider using the\r\n  # below and tailoring it to your likings \r\n  #Allow from 127.0.0.1\r\n  #Allow from 192.168.0.<\/code> \r\n\r\n<code>RewriteEngine On<\/code> <code>\r\n  # so skins, images and extensions work\r\n  RewriteRule ^(images|skins|extensions)\/ - [L]<\/code>\r\n\r\n <code>\u00a0# Forces specified index page to go ahead and load\r\n  RewriteRule ^(load|index).php - [L]<\/code> <code>\r\n  # The following makes it so if our configuration file isn't\r\n  # present we will always catch this rewrite rule (allowing the \r\n  # user to set up mediawiki) <\/code> <code>\r\n\u00a0 RewriteCond \/usr\/share\/mediawiki\/LocalSettings.php !-f\r\n  RewriteRule ^(.+)  -  [PT]<\/code> <code>\r\n  # Path Formating\r\n  RewriteRule ^\/*$ \/wiki\/index.php?title=Main_Page [L,QSA]\r\n  RewriteRule ^\/*(.+)$ \/wiki\/index.php?title=$1 [PT,L,QSA]<\/code> <code>\r\n  ## Support colon (:)\r\n  RewriteRule ^\/(.*:.*)$  \/wiki\/index.php?title=$1 [L]\r\n &lt;\/Directory&gt;<\/code>\r\n\r\n<code> &lt;Directory \"\/var\/www\/html\/wiki\/images\"&gt;\r\n # Ignore .htaccess files\r\n AllowOverride None <\/code> \r\n\r\n<code># Serve HTML as plaintext, don't execute SHTML\r\n  AddType text\/plain .html .htm .shtml .php<\/code> <code>\r\n # Don't run arbitrary PHP code. php_admin_flag engine off<\/code> \r\n\r\n<code>RewriteEngine On\r\n RewriteCond %{QUERY_STRING} \\.[^\\\\\/:*?\\x22|%]+(#|\\?|$) [nocase]\r\n RewriteRule . - [forbidden]<\/code> <code> \r\n# If you've other scripting languages, disable them too.\r\n &lt;\/Directory&gt;<\/code><\/pre>\n<p>Go to http:\/\/Wiki_IP\/wiki to configure and generate LocalSettings.php. Copy LocalSettings.php to wiki dir<\/p>\n<p><strong>Import content from old wiki<\/strong><br \/>\n<code>cd \/var\/www\/html\/wiki\/<br \/>\nphp maintenance\/importDump.php &lt; dumpfile.xml<\/code><\/p>\n<p><strong>Mediawiki AD integration<\/strong><br \/>\n<code>Go to http:\/\/www.mediawiki.org\/wiki\/Special:ExtensionDistributor\/LdapAuthentication<br \/>\nhttps:\/\/extdist.wmflabs.org\/dist\/extensions\/LdapAuthentication-REL1_24-24a399e.tar.gz<br \/>\ntar -xzf LdapAuthentication-REL1_24-24a399e.tar.gz -C \/var\/www\/html\/wiki\/extensions<\/code><\/p>\n<p><code>yum install php-ldap<\/code><\/p>\n<p><code>require_once( \"$IP\/extensions\/LdapAuthentication\/LdapAuthentication.php\" );<br \/>\n$wgAuth = new LdapAuthenticationPlugin();<br \/>\n$wgLDAPDomainNames = array( \"SUB1\" );<br \/>\n$wgLDAPServerNames = array( \"SUB1\" =&gt; \"dc01.sub1.domain.com\" );<br \/>\n$wgLDAPSearchStrings = array( \"SUB1\" =&gt; \"USER-NAME@SUB1\" );<br \/>\n$wgLDAPEncryptionType = array( \"SUB1\" =&gt; \"clear\" );<br \/>\n$wgLDAPBaseDNs = array( \"SUB1\" =&gt; \"dc=sub1,dc=domain,dc=com\" );<br \/>\n$wgLDAPSearchAttributes = array( \"SUB1\" =&gt; \"sAMAccountName\" );<br \/>\n$wgLDAPProxyAgent = array(\"SUB1\" =&gt; \"CN=wikiop,OU=Other,OU=Users,OU=Administrative,DC=sub1,DC=domain,DC=com\");<br \/>\n$wgLDAPProxyAgentPassword = array(\"SUB1\" =&gt; \"password\");<br \/>\n$wgLDAPUseLocal = false;<br \/>\n$wgMinimalPasswordLength = 1;<br \/>\n$wgLDAPDebug = 3; \/\/for debugging LDAP<br \/>\n$wgShowExceptionDetails = true; \/\/for debugging MediaWiki<br \/>\n$wgDebugLogFile = \"\/var\/log\/mediawiki\/debug-{$wgDBname}.log\";<br \/>\n$wgLDAPBaseDNs = array( \"SUB1\" =&gt; \"dc=sub1,dc=domain,dc=com\" );<br \/>\n$wgLDAPRetrievePrefs = array( \"SUB1\" =&gt; \"true\" );<\/code><\/p>\n<p><code>php maintenance\/update.php<\/code><\/p>\n<p><strong>PostrgeSQL DB backup<\/strong><br \/>\n<code>pg_dump wikidb &gt; wikidbdump2017_01_28.sql<br \/>\npg_dumpall --globals &gt; postgres_globals2017_01_28.sql<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Embedded DB wiki backup (sqlite) cd \/var\/www\/html\/wiki\/ php maintenance\/sqlite.php &#8211;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 &#8211;full &gt; dump-2017_01_27.xml Mediawiki installation and configuration Be careful, you have to create main page (there&#8217;s no way to import main page with xml import feature). Copy main page source code from the old [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[231],"tags":[212,243,32,259,14,11],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts\/771"}],"collection":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/comments?post=771"}],"version-history":[{"count":28,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts\/771\/revisions"}],"predecessor-version":[{"id":799,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts\/771\/revisions\/799"}],"wp:attachment":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/media?parent=771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/categories?post=771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/tags?post=771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}