Difference between revisions of "Install MediaWiki as Wikipedia in Linux CentOS 7"
(Created page with "=== System Requirements === MediaWiki requires PHP 5.5.9+ and either MySQL 5.0.2+, MariaDB, or one of the other three possible stores. === Prepare Web Server, PHP, and Datab...") |
m (Gejor moved page Install MediaWiki as Wikipedia on Linux CentOS 7 to Install MediaWiki as Wikipedia in Linux CentOS 7 without leaving a redirect) |
||
| (26 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | + | == System Requirements == | |
MediaWiki requires PHP 5.5.9+ and either MySQL 5.0.2+, MariaDB, or one of the other three possible stores. | MediaWiki requires PHP 5.5.9+ and either MySQL 5.0.2+, MariaDB, or one of the other three possible stores. | ||
| − | == | + | == Setup Web Server, Database, and PHP == |
| − | + | === Step 1 : Install Apache Web Server === | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | Update the server. Install Apache web server. Enable and start it. | |
| − | ==== Download MediaWiki 1.27.0 | + | <pre> |
| + | [root@qemu01 ~]# yum update | ||
| + | [root@qemu01 ~]# yum install httpd | ||
| + | [root@qemu01 ~]# systemctl enable httpd.service | ||
| + | [root@qemu01 ~]# systemctl start httpd.service | ||
| + | </pre> | ||
| + | |||
| + | There should be public html folder created at /var/www/html. Just test it with go to that folder. | ||
| + | |||
| + | <pre> | ||
| + | [root@qemu01 ~]# cd /var/www/html | ||
| + | [root@qemu01 html]# pwd | ||
| + | </pre> | ||
| + | |||
| + | === Step 2 : Install MariaDB Database === | ||
| + | |||
| + | In this step, we just install MariaDB database. Start it. And setup security. | ||
| + | |||
| + | <pre> | ||
| + | [root@qemu01 ~]# yum install mariadb-server mariadb | ||
| + | [root@qemu01 ~]# systemctl enable mariadb.service | ||
| + | [root@qemu01 ~]# systemctl start mariadb | ||
| + | [root@qemu01 ~]# mysql_secure_installation | ||
| + | </pre> | ||
| + | |||
| + | In MariaDB securing steps, we have to provide the answers below for simplicity. | ||
| + | |||
| + | <pre> | ||
| + | Set root password? [Y/n] Y | ||
| + | New password: Enter your password here | ||
| + | Re-enter new password: repeat your password | ||
| + | Remove anonymous users? [Y/n] Y | ||
| + | Disallow root login remotely? [Y/n] Y | ||
| + | Remove test database and access to it? [Y/n] Y | ||
| + | Reload privilege tables now? [Y/n] Y | ||
| + | </pre> | ||
| + | |||
| + | === Step 3 : Install PHP, PHP-MySQL, PHP-MBString, and PHPMyAdmin === | ||
| + | |||
| + | PHP is a general-purpose server-side scripting language. | ||
| + | |||
| + | <pre> | ||
| + | [root@qemu01 ~]# yum install epel-release php php-mysql php-mbstring phpmyadmin | ||
| + | </pre> | ||
| + | |||
| + | After that, we have to configure the phpMyAdmin configuration file. | ||
| + | |||
| + | <pre> | ||
| + | [root@qemu01 ~]# vi /etc/httpd/conf.d/phpMyAdmin.conf | ||
| + | </pre> | ||
| + | |||
| + | In phpMyAdmin.conf file, we need to change 127.0.0.1 to our subnet range address. In this example, we change 127.0.0.1 to 10.129.50.0/24. | ||
| + | |||
| + | <pre> | ||
| + | ... | ||
| + | |||
| + | <Directory /usr/share/phpMyAdmin/> | ||
| + | AddDefaultCharset UTF-8 | ||
| + | |||
| + | <IfModule mod_authz_core.c> | ||
| + | # Apache 2.4 | ||
| + | <RequireAny> | ||
| + | Require ip 10.129.50.0/24 | ||
| + | Require ip ::1 | ||
| + | </RequireAny> | ||
| + | </IfModule> | ||
| + | <IfModule !mod_authz_core.c> | ||
| + | # Apache 2.2 | ||
| + | Order Deny,Allow | ||
| + | Deny from All | ||
| + | Allow from 10.129.50.0/24 | ||
| + | Allow from ::1 | ||
| + | </IfModule> | ||
| + | </Directory> | ||
| + | |||
| + | <Directory /usr/share/phpMyAdmin/setup/> | ||
| + | <IfModule mod_authz_core.c> | ||
| + | # Apache 2.4 | ||
| + | <RequireAny> | ||
| + | Require ip 10.129.50.0/24 | ||
| + | Require ip ::1 | ||
| + | </RequireAny> | ||
| + | </IfModule> | ||
| + | <IfModule !mod_authz_core.c> | ||
| + | # Apache 2.2 | ||
| + | Order Deny,Allow | ||
| + | Deny from All | ||
| + | Allow from 10.129.50.0/24 | ||
| + | Allow from ::1 | ||
| + | </IfModule> | ||
| + | </Directory> | ||
| + | |||
| + | ... | ||
| + | </pre> | ||
| + | |||
| + | Then restart the Apache web server. | ||
| + | |||
| + | <pre> | ||
| + | [root@qemu01 ~]# systemctl restart httpd.service | ||
| + | </pre> | ||
| + | |||
| + | == Prepare MediaWiki Sources == | ||
| + | |||
| + | === Download MediaWiki 1.27.0 === | ||
The last stable MediaWiki can be downloaded from MediaWiki. | The last stable MediaWiki can be downloaded from MediaWiki. | ||
| Line 19: | Line 118: | ||
<code> wget https://releases.wikimedia.org/mediawiki/1.27/mediawiki-1.27.0.tar.gz </code> | <code> wget https://releases.wikimedia.org/mediawiki/1.27/mediawiki-1.27.0.tar.gz </code> | ||
| − | + | === Put Media Wiki in Web Server === | |
As example, if we're using Centos 7, the web server path is in /var/www/html/. | As example, if we're using Centos 7, the web server path is in /var/www/html/. | ||
| Line 25: | Line 124: | ||
<code>mv mediawiki-1.27.0.tar.gz /var/www/html/</code> | <code>mv mediawiki-1.27.0.tar.gz /var/www/html/</code> | ||
| − | + | === Extract the File === | |
Extract the tar file and rename it with your wiki name, as example named with wikipedia. | Extract the tar file and rename it with your wiki name, as example named with wikipedia. | ||
| Line 33: | Line 132: | ||
<code>mv /var/www/html/mediawiki-1.27.0 /var/www/html/wikipedia</code> | <code>mv /var/www/html/mediawiki-1.27.0 /var/www/html/wikipedia</code> | ||
| − | + | == Run the MediaWiki Installation == | |
| + | |||
| + | Open MediaWiki index.php page at <code>http://[web_server_address]/wikipedia/index.php</code> and follow the installation requirement there. | ||
| + | |||
| + | == Troubleshooting == | ||
| + | |||
| + | === Problem 1 : LocalSettings.php File Not Readable === | ||
| + | Solution : run restorecon command into the wikipedia website folder. | ||
| + | <pre> | ||
| + | [root@qemu01 ~]# restorecon -r /var/www/html/wikipedia/ | ||
| + | </pre> | ||
| + | |||
| + | === Problem 2 : First Login Error (Session Hijacking Protection) === | ||
| + | Solution : Change $wgMainCacheType from CACHE_ACCEL to CACHE_ANYTHING as suggested in LocalSettings.php file. | ||
| + | |||
| + | <pre> | ||
| + | [root@qemu01 ~]# cd /var/www/html/wikipedia | ||
| + | [root@qemu01 wikipedia]# vi LocalSettings.php | ||
| + | </pre> | ||
| − | + | <pre> | |
| + | ... | ||
| − | === | + | ## Shared memory settings |
| + | #$wgMainCacheType = CACHE_ACCEL; | ||
| + | $wgMainCacheType = CACHE_ANYTHING; | ||
| + | $wgMemCachedServers = []; | ||
| − | + | ... | |
| − | + | </pre> | |
| − | + | === Problem 3 : Upload File Error (LocalFileLockError) === | |
| − | Solution : | + | Solution : Run setenforce 0 script and then try again. |
| − | + | <pre> | |
| − | + | [root@qemu01 ~]# sudo setenforce 0 | |
| + | </pre> | ||
Latest revision as of 12:52, 14 October 2019
Contents
System Requirements
MediaWiki requires PHP 5.5.9+ and either MySQL 5.0.2+, MariaDB, or one of the other three possible stores.
Setup Web Server, Database, and PHP
Step 1 : Install Apache Web Server
Update the server. Install Apache web server. Enable and start it.
[root@qemu01 ~]# yum update [root@qemu01 ~]# yum install httpd [root@qemu01 ~]# systemctl enable httpd.service [root@qemu01 ~]# systemctl start httpd.service
There should be public html folder created at /var/www/html. Just test it with go to that folder.
[root@qemu01 ~]# cd /var/www/html [root@qemu01 html]# pwd
Step 2 : Install MariaDB Database
In this step, we just install MariaDB database. Start it. And setup security.
[root@qemu01 ~]# yum install mariadb-server mariadb [root@qemu01 ~]# systemctl enable mariadb.service [root@qemu01 ~]# systemctl start mariadb [root@qemu01 ~]# mysql_secure_installation
In MariaDB securing steps, we have to provide the answers below for simplicity.
Set root password? [Y/n] Y New password: Enter your password here Re-enter new password: repeat your password Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y
Step 3 : Install PHP, PHP-MySQL, PHP-MBString, and PHPMyAdmin
PHP is a general-purpose server-side scripting language.
[root@qemu01 ~]# yum install epel-release php php-mysql php-mbstring phpmyadmin
After that, we have to configure the phpMyAdmin configuration file.
[root@qemu01 ~]# vi /etc/httpd/conf.d/phpMyAdmin.conf
In phpMyAdmin.conf file, we need to change 127.0.0.1 to our subnet range address. In this example, we change 127.0.0.1 to 10.129.50.0/24.
...
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 10.129.50.0/24
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 10.129.50.0/24
Allow from ::1
</IfModule>
</Directory>
<Directory /usr/share/phpMyAdmin/setup/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 10.129.50.0/24
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 10.129.50.0/24
Allow from ::1
</IfModule>
</Directory>
...
Then restart the Apache web server.
[root@qemu01 ~]# systemctl restart httpd.service
Prepare MediaWiki Sources
Download MediaWiki 1.27.0
The last stable MediaWiki can be downloaded from MediaWiki.
wget https://releases.wikimedia.org/mediawiki/1.27/mediawiki-1.27.0.tar.gz
Put Media Wiki in Web Server
As example, if we're using Centos 7, the web server path is in /var/www/html/.
mv mediawiki-1.27.0.tar.gz /var/www/html/
Extract the File
Extract the tar file and rename it with your wiki name, as example named with wikipedia.
tar xvzf mediawiki-1.27.0.tar.gz
mv /var/www/html/mediawiki-1.27.0 /var/www/html/wikipedia
Run the MediaWiki Installation
Open MediaWiki index.php page at http://[web_server_address]/wikipedia/index.php and follow the installation requirement there.
Troubleshooting
Problem 1 : LocalSettings.php File Not Readable
Solution : run restorecon command into the wikipedia website folder.
[root@qemu01 ~]# restorecon -r /var/www/html/wikipedia/
Problem 2 : First Login Error (Session Hijacking Protection)
Solution : Change $wgMainCacheType from CACHE_ACCEL to CACHE_ANYTHING as suggested in LocalSettings.php file.
[root@qemu01 ~]# cd /var/www/html/wikipedia [root@qemu01 wikipedia]# vi LocalSettings.php
... ## Shared memory settings #$wgMainCacheType = CACHE_ACCEL; $wgMainCacheType = CACHE_ANYTHING; $wgMemCachedServers = []; ...
Problem 3 : Upload File Error (LocalFileLockError)
Solution : Run setenforce 0 script and then try again.
[root@qemu01 ~]# sudo setenforce 0