2018/04/09 17:38

# 什么是MediaWiki？

MediaWiki是一款基于服务器的自由软件，并获得了 GNU 通用公共许可证 (GPL)的许可。这款软件的设计之目的是使其运行于一个每天拥有百万次点击量网站的大型服务器群组上。

MediaWiki是一款极其强大、具有极强扩展性的软件，也是实现维基（wiki）丰富多彩的功能的一个载体，其使用PHP语言来处理和显示贮存在一个数据库中的数据，譬如MySQL。

# 安装

You can download a release version of MediaWiki from the official download page: generally, if you're using a production environment, you want to be running the stable release.

To download MediaWiki 1.29.0, which is the latest stable release version, to a *nix machine you can use the following command:

[https://en.wikipedia.org/wiki/wget wget] [https://releases.wikimedia.org/mediawiki/1.29/mediawiki-1.29.0.tar.gz https://releases.wikimedia.org/mediawiki/1.29/mediawiki-1.29.0.tar.gz]

Alternatively, using cURL:

curl -O [https://releases.wikimedia.org/mediawiki/1.29/mediawiki-1.29.0.tar.gz https://releases.wikimedia.org/mediawiki/1.29/mediawiki-1.29.0.tar.gz]

The downloaded files are in .tar.gz format, so they will need to be uncompressed before use. This can be done locally (and then uploaded via FTP) or directly on your server. This is usually done with software such as 7-Zip (free), WinZip, WinRAR or IZArc (free) on Windows. On Linux and Mac OS X, you can untar the file using this command:

tar xvzf mediawiki-*.tar.'''gz'''

If you untar the archive as root, you should probably change the ownership afterwards with chown, otherwise the files will end up owned as user # 1000, which may or may not be what you want.

### For developers

Developers on the other hand should probably download from Git to set up a local repository with the latest code in development. They will also need to manually install dependencies via Composer.

Make sure the "Change file names to lowercase" option for upload is disabled.

1. directly copying the unzipped folder or
2. by using an FTP client such as FileZilla (Open Source Software, Windows, OSX and Linux) or Cyberduck (OSX).

If you installed Apache, the correct directory is specified in your httpd.conf file (it's typically <apache-folder>/htdocs). Note: This changes in Ubuntu 14.04 with Apache 2.4.7 where the primary config file for Apache server settings and directories is /etc/apache2/apache2.conf.

If you are using a Linux or Unix server you can instead copy the files to any directory on your server and then make a symbolic link to that folder from your web server's web directory.

Rename the uploaded folder to whatever you would like to have in the URL. If your web server is running as http://localhost for example, renaming to /w/ directory would mean you would access your wiki at http://localhost/w/index.phpDo not use /wiki/ if you want to use it as a Short URL.(And don't set up short URLs until you have run the installation script.)

Note that in certain cases, like when a local repository is set-up using Git, on browsing to index.php the Linux server might show the "500 Internal server Error". This is possibly a permissions error which can be resolved on changing the file and directory permissions by running the following command in SSH after changing directory to "w":

find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;

This (renamed) folder will now be referred as <MediaWiki-folder>.

## Create a database

If you already have a database server and know the root password for it, the MediaWiki installation script can create a new database for you. If this is the case, you can skip to the Run the installation script section below. If you don't know the root password, for example if you are on a hosted server, you will have to create a new database now. Currently, you must use SQLite, MariaDB/MySQL or PostgreSQL to store the actual contents of your wiki.

MediaWiki will ask you for database and user name and will attempt to create them if they don't already exist. If doing so from MediaWiki is impossible, you can do this using various control panels such as PhpMyAdmin, which are often available from shared hosts, or you may be able to use ssh to login to your host and type the commands into a MySQL prompt. See the corresponding documentation. Alternatively, contact your host provider to have them create an account for you.

#### Unix/Linux installation

1. Download and install MariaDB/MySQL. Depending on how MariaDB/MySQL was installed on your system the commands mysqlmysqladminand mysqld_safe may need to be amended to include the installation directory of MariaDB/MySQL (for example, by adding /usr/local/mysql/bin/in front of them).
2. Check and see if the database server is running; for example, run mysqladmin status. If it is not, run mysqld_safe to start it: sudo mysqld_safe.
• Another way to initially start the MariaDB/MySQL server is to run the configure script available at the root of the installation. It creates the initial tables and automatically starts the MariaDB/MySQL daemon.
• Alternatively you can start the MariaDB/MySQL daemon with systemd using: sudo systemctl start mysqld. You may also wish to enable the mysqld service with sudo systemctl enable mysqld, so that the MySQL service is started automatically on startup.
3. Set a password for the "root" account on your database server. mysqladmin -u root password yourpassword
4. Run the MariaDB/MySQL command-line client: mysql -u root -p
5. This will prompt for the "root" database password you just set, then connect to the MariaDB/MySQL server. Now, continue with the SQL commands below.

#### Installation continued

CREATE DATABASE wikidb;
GRANT ALL PRIVILEGES ON wikidb.* TO 'wikiuser'@'localhost' IDENTIFIED BY 'password';

If your database is not running on the same server as your web server, you need to give the appropriate web server hostname -- mediawiki.example.com in my example -- as follows:

GRANT ALL PRIVILEGES ON wikidb.* TO 'wikiuser'@'mediawiki.example.com' IDENTIFIED BY 'password';
 https://upload.wikimedia.org/wikipedia/commons/thumb/5/51/Attention_niels_epting.svg/18px-Attention_niels_epting.svg.png  Warning: MySQL/MariaDB on UNIX/Linux logs all queries sent to it to a file, which will include the password you used for the user account. If this concerns you, delete your .mysql_history file after running these queries. This file may be found in your home directory (~/.mysql_history).​​​​​​​

Run the installation script

Once all of the above steps are complete, you can complete the installation through a web browser by going to the index.php URI in your browser -- check the instructions mentioned in Manual:Config script.

If needed, you can run the command-line installer or CLI: php maintenance/install.php.

# 自定义部分

vi /var/www/wiki/LocalSettings.php

$wgDBtype = "mysql";$wgDBserver = "localhost";
$wgDBname = "my_wiki";$wgDBuser = "wiki";
$wgDBpassword = "test"; ## 发送邮件配置 vi /var/www/wiki/includes/DefaultSettings.php$wgSMTP = array(

'host'     => 'smtp.test.com',

'IDHost'   => 'test.com',

'port'     => '25',

'auth'     => false,

);

vi /var/www/wiki/includes/mail/UserMailer.php

add the absolute path: /usr/share/pear/ as:

/usr/share/pear/Mail.php
/usr/share/pear/PEAR.php
/usr/share/pear/Net/SMTP.php
/usr/share/pear/Net/Socket.php
/usr/share/pear/Auth/SASL.php
/usr/share/pear/Mail/smtp.php
/usr/share/pear/Mail/mime.php
/usr/share/pear/Mail/mimePart.php

## 插件

### Installing an extension

MediaWiki is ready to accept extensions just after installation is finished. To add an extension follow these steps:

Before you start

Many extensions provide instructions designed for installation using unix commands. You require shell access (SSH) to enter these commands listed on the extension help pages.

Extension Distributor helps you to select and download most of the popular extensions.
Extensions are usually distributed as modular packages. They generally go in their own subdirectory of $IP/ extensions/. A list of extensions stored in the Wikimedia Git repository is located at git:mediawiki/extensions. Some extensions don't use version control and are not recommended. Some extensions are also available in bundlescomposer or package repositories. Install your extension.. Generally, at the end of the LocalSettings.php file (but above the PHP end-of-code delimiter, "?>", if present), the following line should be added: // mw.v 1.24.x or less require_once "$IP/extensions/extension_name/extension_name.php";
// mw.v 1.25.x or above

This line forces the PHP interpreter to read the extension file, and thereby make it accessible to MediaWiki.
Some extensions can conflict with maintenance scripts, for example if they directly access $_SERVER (not recommended). In this case they can be wrapped in the conditional so maintenance scripts can still run. //for mw.v 1.24.x or less if ( !$wgCommandLineMode ) {
require_once "$IP/extensions/extension_name/extension_name.php"; } //for mw.v 1.25.x or above if ( !$wgCommandLineMode ) {
}

## 自动通知

If you want to enable the notificatio function,you'll need to change the following variables in LocalSettings.php

$wgEnableEmail = true;$wgEnableUserEmail = true; # UPO

$wgEmergencyContact = "wiki@test.com";$wgPasswordSender = "wiki@test.com";

0
0 收藏

0 评论
0 收藏
0