Windows 10 Local Wiki Import

From CompleteNoobs
Jump to navigation Jump to search
Please Select a Licence from the LICENCE_HEADERS page
And place at top of your page
If no Licence is Selected/Appended, Default will be CC0

Default Licence IF there is no Licence placed below this notice! When you edit this page, you agree to release your contribution under the CC0 Licence

LICENCE: More information about the cc0 licence can be found here:
https://creativecommons.org/share-your-work/public-domain/cc0

The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.

You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Licence:

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others.

For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following:

   the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work;
   moral rights retained by the original author(s) and/or performer(s);
   publicity and privacy rights pertaining to a person's image or likeness depicted in a Work;
   rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below;
   rights protecting the extraction, dissemination, use and reuse of data in a Work;
   database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and
   other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose.

4. Limitations and Disclaimers.

   No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document.
   Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law.
   Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work.
   Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work.

local wiki on win 10 2nd draft

Make sure Linux subsystem enabled on windows 10

Control Panel > Programs > Turn Windows features on or off Scroll down and make sure Windows Subsystem for Linux box is ticked

If it was unticked, you might should reboot/restart your computer after the subsystem installs.

Video demo:

Install Ubuntu from Microsoft store

Install the Ubuntu App from the store.
And launch it.

When you launch you will be prompted for a username and password:

Video demo:

To Reset Ubuntu

If you want to reset Ubuntu and start again.
In search bar goto Apps & features
Find Ubuntu 22.04.2 TLS and click Advanced options scroll down to Reset and click the Reset button.

Video demo:

Windows 10 subsystem notes

Interacting with snapd is not yet supported on Windows Subsystem for Linux. This command has been left available for documentation purposes only

LXD does not work on the subsystem but we dont need it.

Video demonstration

Find your Subsystem Ubuntu IP address on network

Get the ip for your linux on the subsystem win10.
ip route show default
Will return something like:

none default via 192.168.0.1 dev eth0 proto unspec metric 0


You are looking for your network interface, its after dev in my case it's eth0
Now to find the ip for that interface:
ip address

ip address will return something like this:

12: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 group default qlen 1
    link/ether 9c:b6:54:a5:a0:da
    inet 192.168.0.130/24 brd 192.168.0.255 scope global dynamic
       valid_lft 86178sec preferred_lft 86178sec
    inet6 fe80::55b2:e14f:3167:365d/64 scope link dynamic
       valid_lft forever preferred_lft forever
1: lo: <LOOPBACK,UP> mtu 1500 group default qlen 1
    link/loopback 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope global dynamic
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host dynamic
       valid_lft forever preferred_lft forever
16: wifi0: <> mtu 1500 group default qlen 1
    link/ieee802.11 0c:8b:fd:77:97:d2
    inet 169.254.163.24/16 brd 169.254.255.255 scope global dynamic
       valid_lft forever preferred_lft forever
    inet6 fe80::fd1c:33d1:6cae:a318/64 scope link dynamic
       valid_lft forever preferred_lft forever
8: wifi1: <> mtu 1500 group default qlen 1
    link/ieee802.11 0c:8b:fd:77:97:d3
    inet 169.254.66.175/16 brd 169.254.255.255 scope global dynamic
       valid_lft forever preferred_lft forever
    inet6 fe80::c0e4:3ef8:4054:42af/64 scope link dynamic
       valid_lft forever preferred_lft forever
17: wifi2: <> mtu 1500 group default qlen 1
    link/ieee802.11 0e:8b:fd:77:97:d2
    inet 169.254.142.131/16 brd 169.254.255.255 scope global dynamic
       valid_lft forever preferred_lft forever
    inet6 fe80::5dbb:c7b1:c7f7:8e83/64 scope link dynamic
       valid_lft forever preferred_lft forever

Look for your interface, mine was eth0
2 lines down, you will see a line that starts with inet that contains you network address.
Mine was 192.168.0.130


Copy and Paste to the subsystem terminal

Right clicking in the ubuntu terminal will paste.
Highlighting text in the ubuntu terminal and right clicking will copy.

Install mediawiki

sudo apt update && sudo apt upgrade -y

sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring php-intl -y
Does not seem to use systemd on win subsystem.
sudo service apache2 start
If you see error:

(92)Protocol not available: AH00076: Failed to enable ARP_TCP_DEFER_ACCEPT

Don't worry, it should still work. Check status of apache2.
sudo service apache2 status

wget https://releases.wikimedia.org/mediawiki/1.39/mediawiki-1.39.2.tar.gz

tar -zxvf mediawiki-1.39.2.tar.gz

sudo mv mediawiki-1.39.2 /var/www/html/mediawiki

Create database

As this is just for your own computer on your own network, you can keep it super simple:

To Avoid Error:

su: warning: cannot change directory to /nonexistent: No such file or directory

Fix with:
sudo usermod -d /var/lib/mysql/ mysql

sudo service mysql start
sudo mysql -u root
CREATE USER 'wiki'@'localhost';
CREATE DATABASE my_wiki;
use my_wiki;
GRANT ALL ON my_wiki.* TO 'wiki'@'localhost';
quit;

Syntax Database setup:

Login to Mysql as user root: mysql -u $USER

CREATE USER '$USERNAME'@'localhost';
If creating a database password CREATE USER '$USERNAME'@'localhost' IDENTIFIED BY '$PASSWORD';
CREATE DATABASE $DATABASE_NAME;
use $DATABASE_NAME;
GRANT ALL ON $DATABASE_NAME.* TO '$USER'@'localhost';

Config Apache2

sudo $EDITOR /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
        DocumentRoot /var/www/html/mediawiki
</VirtualHost>


Reload Apache2

sudo service apache2 restart

Visit webpage and carry on with normal basic wiki setup

Remember your IP address for your subsystem, Mine was 192.168.0.130, now enter that in a web browser.
You will now find yourself on the mediawiki setup landing page.

MediaWiki 1.36.1 LocalSettings.php not found. Please complete the installation and download LocalSettings.php.

Click complete the installation

Language Page

Just pick a language mate

Welcome to MediaWiki!

read and click Continue

Connect to database - going to need the details from when you created the database.

Database host:localhost Change to 127.0.0.1 to avoid error
Database name:wiki
Database table prefix (no hyphens): LEAVE BLANK
Database username:my_wiki
Database password: LEAVE BLANK

Database Settings

Database account for web access
[x]Use the same account as for installation
Leave ticked

Name

Name of wiki:LocalWiki
Project namespace:
[x]Same as the wiki name:
[ ]Project
[ ]Other (specify)
Administrator account Will be the admin account on the wiki.
CLICK I'm bored already, just install the wiki.

At the end you would of downloaded a file called LocalSettings.php
Now lets send it to the container from host.

Send LocalSettings.php to subsystem

Now i am sure there is a way to send this file to the linux subsystem.
But the only thing i remember and know right now is that i really dont like windows
So open the file LocalSettings.php with notepad and CTRL+A to select all and CTRL+c to copy.
Back on the linux subsystem.
sudo nano /var/www/html/mediawiki/LocalSettings.php
On windows 10 its right click to paste.
Once pasted CTRL+o (will prompt 'File Name to Write: /var/www/html/mediawiki/LocalSettings.php' press enter) and CTRL+x to exit.
Do not refresh your web-browser it will prompt you to download LocalSettings.php again, revisit the IP address from earlier 192.168.0.130. and well come to your wiki.
Now to import CompleteNoobs Wiki content from a xml dump.

Visit https://xml.completenoobs.com and select the latest xml dump, right click and select 'Copy link address' now back to the subsystem
wget https://xml.completenoobs.com/xmlDumps/20_03_23.Noobs/20_03_23.Noobs.xml
TIP:Type wget and then right click to paste the address

now to import the dump.
php /var/www/html/mediawiki/maintenance/importDump.php --conf /var/www/html/mediawiki/LocalSettings.php wikidump_28_07_2021-updated.xml

Not finished yet:
php /var/www/html/mediawiki/maintenance/rebuildrecentchanges.php
php /var/www/html/mediawiki/maintenance/initSiteStats.php
php /var/www/html/mediawiki/maintenance/rebuildall.php

and thats it, Everything apart from the Main_Page is imported.
But thats why we have a Main_Index page.
Edit the home page and add [[Main_Index | Wiki index]] that will take you to the wiki's main index page.

EmbedVideo

In order to view the embedded video's you will need to install the EmbedVideo extension.
If you do not, you will still be able to view the video address.

https://www.mediawiki.org/wiki/Extension:EmbedVideo
apt install unzip
wget https://gitlab.com/hydrawiki/extensions/EmbedVideo/-/archive/v2.9.0/EmbedVideo-v2.9.0.zip
unzip EmbedVideo-v2.9.0.zip -d /var/www/html/mediawiki/extensions/

mv /var/www/html/mediawiki/extensions/EmbedVideo-v2.9.0 /var/www/html/mediawiki/extensions/EmbedVideo

$EDITOR /var/www/html/mediawiki/LocalSettings.php

#Embed Video
wfLoadExtension( 'EmbedVideo' );

Restarting Windows

Restarting windows will fix the display bugs on the wiki.
You will need to open ubuntu and restart mysql and apache2.
sudo service apache2 start
sudo service mysql start

Create Local Domain name shortcut to your local wiki

On windows 10, open Notepad with Run as administrator and open the file C:\Windows\System32\drivers\etc\hosts (you will need to change "Text Documents (*.txt)" to "All Files" to see it.) And add the line at the bottom:

192.168.0.130    mywiki.local

192.168.0.130 is the ip of my ubuntu subsystem and mywiki.local is the domain name on browser i would like forwarded to the local wiki.
Change the IP to your ubuntu subsystem ip and the Domain, you can change the domain name to anything you want.
You can now view your wiki on your browser by entering mywiki.local or whatever you want your local domain called.