MediaWiki/Installation

From Omnia
Jump to navigation Jump to search

Installation

See https://www.mediawiki.org/wiki/Manual:Installation_guide

Installation Dependencies

CentOS 6

Setup Apache, PHP and MySQL:

yum install httpd php mysql mysql-server php-mysql php-xml php-intl
# optional
yum install gd ImageMagick php-gd 

Install Caching (CentOS 6):

# Select APC, XCache or WinCache.
yum install php-pecl-apc
# or (but not both)
yum install php-xcache
# or (but not both)
# install wincache?
service httpd restart

Install APC: [1]

yum install php-pear php-devel httpd-devel pcre-devel gcc make
pecl install apc

Install GD or ImageMagick:

yum install ImageMagick

Install git

yum install git

Ubuntu

Ubuntu 16 or 18

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring
sudo apt-get install php-apcu php-intl imagemagick inkscape php-gd php-cli php-curl git
sudo phpenmod mbstring
sudo phpenmod xml
sudo systemctl restart apache2.service
sudo a2enmod ssl
sudo a2enmod rewrite
sudo mysql -u root -p 
  CREATE DATABASE my_wiki;
  CREATE USER 'new_mysql_user'@'localhost' IDENTIFIED BY 'THISpasswordSHOULDbeCHANGED';
  GRANT ALL ON my_wiki.* TO 'new_mysql_user'@'localhost';
  quit;
cd /etc/apache2
sudo ln -s /var/log/apache2 logs

Install MediaWiki

MediaWiki Download - http://www.mediawiki.org/wiki/Download

1.32.0

cd /www
wget https://releases.wikimedia.org/mediawiki/1.32/mediawiki-1.32.0.tar.gz
tar -zvxf mediawiki-1.32.0.tar.gz
mv mediawiki-1.32.0 wiki
mv mediawiki-1.32.0.tar.gz wiki
cd wiki
chown :www-data cache
chmod g+w cache

1.31.0

cd /www
wget https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.0.tar.gz
tar -zvxf mediawiki-1.31.0.tar.gz
mv mediawiki-1.31.0 wiki
mv mediawiki-1.31.0.tar.gz wiki
cd wiki

1.28

MediaWiki 1.28 requires PHP version 5.5.9:

cd /www
wget http://releases.wikimedia.org/mediawiki/1.28/mediawiki-1.28.2.tar.gz
tar -zvxf mediawiki-1.28.2.tar.gz 
mv mediawiki-1.28.2  wiki
mv mediawiki-1.28.2.tar.gz  wiki
cd wiki

1.24

MediaWiki 1.24

cd /www
wget http://releases.wikimedia.org/mediawiki/1.24/mediawiki-1.24.1.tar.gz
tar -zvxf mediawiki-1.24.1.tar.gz
mv mediawiki-1.24.1  wiki
mv mediawiki-1.24.1.tar.gz  wiki
cd wiki

Configure MediaWiki

Make config folder writable

# chmod a+w config
# centos:
sudo chown apache mw-config
# ubuntu:
sudo chown www-data mw-config
#chown www-data cache

Setup apache virtual hosting:

# centos:
/etc/httpd/conf.d/wiki.conf
# apache:
/etc/apache2/sites-enabled/wiki.conf

wiki.conf Basic Apache Setup:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName wiki.example.com
    DocumentRoot /www/wiki
    ErrorDocument 404 /index.html
    ErrorLog logs/wiki-error_log
    CustomLog logs/wiki-access_log common
</VirtualHost>

Clean URL Apache setup:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName wiki.example.com
    DocumentRoot /www/wiki
    ErrorLog logs/wiki-error_log
    CustomLog logs/wiki-access_log common
    ErrorDocument 404 /index.html

    # comment out this section until after mw-config step is complete
    <Directory /www/wiki>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !^favicon.ico$
        #RewriteCond %{REQUEST_FILENAME} !^mylogo.png$
        #RewriteRule ^(.+)$ /index.php?title=$1 [PT,L,QSA]
        RewriteRule ^(.*)$ /index.php/$1 [L,QSA]

        # Ubuntu:
        Require all granted
    </Directory>
</VirtualHost>

Clean URL Apache with SSL setup:

<VirtualHost *:443>
    ServerName wiki.example.com

    # SSL Enabled:
    SSLEngine on
    SSLCertificateFile /etc/wiki.pem
    SSLCertificateChainFile /etc/wiki.pem

    DocumentRoot /www/wiki

    ServerAdmin website@example.com
    ErrorLog logs/wiki-error_log
    CustomLog logs/wiki-access_log common

    # Short URL
    <Directory /www/wiki>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !^favicon.ico$
        #RewriteCond %{REQUEST_FILENAME} !^mylogo.png$
        #RewriteRule ^(.+)$ /index.php?title=$1 [PT,L,QSA]
        RewriteRule ^(.*)$ /index.php/$1 [L,QSA]

        # Ubuntu:
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName wiki.example.com
    Redirect permanent / https://wiki.example.com
</VirtualHost>

Restart Apache

# centos:
service httpd restart
# ubuntu:
service apache2 restart

Start wizard:

http://wiki.example.com/mw-config/index.php

Note: If you just go to http://wiki.example.com/ you will also be directed to the mw-config setup.

Wizard

  1. Environmental Checks
    • Check for issues reported by wizard and fix. (restart apache, refresh config page, rinse and repeat)
  2. Database
    • MySQL database settings (innodb, binary mode)
  3. Options
    • Enable which extensions and skins you wish to use
  4. Install
    • Click to finalize
  5. Complete
    • Instructions for LocalSettings.php

Database (done by wizard): [2]

create database wikidb;
create database wikidb DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
grant index, create, select, insert, update, delete, alter, lock tables on wikidb.* to 'wikiuser'@'localhost' identified by 'password';

Remove config wizard (for security)

mkdir .archive
mv mw-config .archive
# or
rm -rf mw-config

Cleanup:

mkdir .archive
mv mediawiki-* StartProfiler.sample COPYING CREDITS FAQ HISTORY INSTALL README README.mediawiki RELEASE-NOTES* UPGRADE  .archive
mv docs maintenance  .archive

References:

Upgrading

php maintenance/update.php

References:

Upgrade