MediaWiki是一款基於服務器的自由軟件,並得到了 GNU 通用公共許可證 (GPL)的許可。這款軟件的設計之目的是使其運行於一個天天擁有百萬次點擊量網站的大型服務器羣組上。php
MediaWiki是一款極其強大、具備極強擴展性的軟件,也是實現維基(wiki)豐富多彩的功能的一個載體,其使用PHP語言來處理和顯示貯存在一個數據庫中的數據,譬如MySQL。mysql
維基頁面使用MediaWiki的維基文本格式編寫,以便使那些不會使用HTML或CSS的用戶也能輕鬆地編輯頁面。linux
當一個用戶提交一個頁面編輯時,MediaWiki就會將此次動做寫入後臺數據庫,但不會刪除以前頁面的版本。所以,管理員就能夠垂手可得地撤回編輯,以防破壞者或垃圾信息對頁面的損壞git
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.web
To download MediaWiki 1.29.0, which is the latest stable release version, to a *nix machine you can use the following command:sql
[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:shell
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.apache
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.服務器
If you have not already uploaded the files to your web server, do so now.
Make sure the "Change file names to lowercase" option for upload is disabled.
Upload the files to your web server's web directory either by:
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.php
. Do 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>
.
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.
mysql
, mysqladmin
and 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).mysqladmin status
. If it is not, run mysqld_safe to start it: sudo mysqld_safe
.
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.mysqladmin -u root password yourpassword
mysql -u root -p
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';
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 |
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,
'username' => ,
'password' => ,
);
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
MediaWiki is ready to accept extensions just after installation is finished. To add an extension follow these steps:
Before you start
Download your extension.
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.
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
wfLoadExtension( '<extension-name>' );
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 ) {
wfLoadExtension ( '<extension-name>' );
}
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";