How To Install MediaWiki on Ubuntu 18.04 LTS
Posted yongwu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了How To Install MediaWiki on Ubuntu 18.04 LTS相关的知识,希望对你有一定的参考价值。
- Step 1 — Installing Apache and Updating the
Firewall - Step 2 — Installing MySQL
- Step 3 — Installing PHP
- Step 4 — Testing php Processing on your Web
Server - Step 5 — Before installation
- Step 5 — Installing MediaWiki
- Step 6 — Create a database
- Step 7 — Run the installation
script - Step 8 — Short URL/Apache
- Step 8 —
Extension:SyntaxHighlight - References
Step 1 — Installing Apache and Updating the Firewall
Adjust the Firewall to Allow Web Traffic
sudo apt update
sudo apt install apache2
sudo ufw app list
sudo ufw app info "Apache Full"
sudo ufw allow in "Apache Full"
http://localhost
How To Find your Server‘s Public IP Address
sudo apt install curl
curl http://icanhazip.com
Step 2 — Installing mysql
sudo apt install mysql-server
sudo mysql_secure_installation
Step 3 — Installing PHP
sudo apt install php libapache2-mod-php php-mysql
sudo gedit /etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
sudo systemctl restart apache2
sudo systemctl status apache2
apt search php- | less
Step 4 — Testing PHP Processing on your Web Server
sudo gedit /var/www/html/info.php
<?php
phpinfo();
?>
http://localhost/info.php
Step 5 — Before installation
Installation requirements
sudo apt install php-apcu
php-curl php-gd php-intl php-mbstring php-xml
sudo apt install texlive
Step 5 — Installing MediaWiki
curl -O https://releases.wikimedia.org/mediawiki/1.30/mediawiki-1.30.0.tar.gz
tar xvzf mediawiki-*.tar.gz
sudo mkdir /var/www/html/w
sudo mv mediawiki-1.30.0/* /var/www/html/w
Step 6 — Create a database
CREATE DATABASE wikidb;
GRANT ALL PRIVILEGES ON wikidb.* TO 'wikiuser'@'localhost' IDENTIFIED BY 'password';
Step 7 — Run the installation script
http://localhost/w/index.php
sudo mv LocalSettings.php /var/www/html/w
Step 8 — Short URL/Apache
MediaWiki‘s default page addresses looks like these examples:
http://localhost/w/index.php/Page_title
Short URL
page addresses looks like these examples:
http://localhost/w/index.php/Page_title
- The MediaWiki directory is located at: /w
- The desired short url format is: /wiki/Page_title
Enabling mod_rewrite
sudo a2enmod rewrite
sudo systemctl restart apache2
Setting Up Apache2
sudo gedit /etc/apache2/sites-available/mediawiki.conf
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
sudo a2ensite mediawiki.conf
sudo a2dissite 000-default.conf
sudo apache2ctl configtest
sudo systemctl restart apache2
Setting up the rewrite rules
sudo gedit /var/www/html/.htaccess
## http://www.mediawiki.org/wiki/Manual:Short_URL/Apache
# Enable the rewrite engine
RewriteEngine On
# Short URL for wiki pages
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
LocalSettings.php
sudo gedit /var/www/html/w/LocalSettings.php
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "/w"; // this should already have been configured this way
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;
Step 8 — Extension:SyntaxHighlight
Troubleshooting
After updating to MediaWiki v1.26 and above, some users started reporting problems with the extension.
- Try pointing?
$wgPygmentizePath
?in LocalSettings.php towards an external pygmentize binary. - See the?phabricator task?on this for further suggestions and information.
sudo apt install python
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py
sudo pip install Pygments
which pygmentize
/usr/local/bin/pygmentize
sudo gedit /var/www/html/w/LocalSettings.php
$wgPygmentizePath = "/usr/local/bin/pygmentize";
References
How To Install MediaWiki on Ubuntu 14.04
How To Rewrite URLs with mod_rewrite for Apache on Ubuntu 16.04
How To Install the Apache Web Server on Ubuntu 18.04
How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 18.04
INSTALL MEDIAWIKI ON UBUNTU 18.04 LTS WITH APACHE2, MARIADB AND PHP 7.1 SUPPORT
Manual:Installation requirements
以上是关于How To Install MediaWiki on Ubuntu 18.04 LTS的主要内容,如果未能解决你的问题,请参考以下文章
ubuntu——How to Install MySQL GUI