User:Bawolff/MediaWiki developer tutorial/environment
- Introduction and prerequisites
- Installing MediaWiki and setting up your environment
- Cloning the tutorial project
- Hello world
- Adding some formatting
- Adding some JS and CSS
- Internationalization
- Database
- Hooks and dependency injection
- PHPUnit testing
- content handler (maybe)
- Parser
- Parser tags
- Parser functions
- Media handler (maybe)
- Advanced topics
In this tutorial, we prepare your computer's environment so that it can run MediaWiki.
There are many ways to install MediaWiki. This is but one particular method. This tutorial assumes that you are using a Debian or Ubuntu based operating system. This could either be directly as your main machine, a server in the cloud or a virtual machine. Other operating systems would follow similar steps, but the specific commands differ.
Virtual Machine
editIf you are not using a virtual machine, skip ahead to the next step.
- Install virtualbox (or another program to manage virtual machines)
- Install Ubuntu
- Generally speaking, follow the steps in this tutorial: https://ubuntu.com/tutorials/how-to-run-ubuntu-desktop-on-a-virtual-machine-using-virtualbox#1-overview
Creating a developer account
editBefore beginning you should create a developer account. This will be needed for later when you submit patches. This is a separate account from your Wikipedia or MediaWiki.org account however, to avoid confusion it is usually best to use the same username for both. You can create this account at https://wikitech.wikimedia.org/wiki/Special:CreateAccount.
Installing dependencies
editOpen a terminal emulator. Run the following commands
sudo apt install composer git openssh-client php-cli php-mbstring php-xml php-json php-intl php-sqlite3
Configuring git
editRun the following commands replacing the value with values appropriate to you. You should use the same email as you used on the sign up form of your developer account:
git config --global user.email "REPLACEWITHMYEMAIL@example.com" git config --global user.name "MY_NAME_HERE"
Setting up an SSH key
editFor more detailed instructions, see SSH keys.
If you already have an SSH key setup, feel free to use that. Otherwise generate a new one with the following command
ssh-keygen -t ed25519
You can just use the default answers to any questions asked. This should produce two files. One will be called ~/.ssh/id_ed25519.pub
the other will be called ~/.ssh/id_ed25519
. The first is your public key. You will share this with servers you want to communicate with. The second is your private key. Treat this second file like a password and do not share it with anyone.
Next you need to add your SSH key to gerrit:
- Log into the </tvar> web interface for Gerrit. The username and password for your Gerrit are the same as for your Wikimedia Developer account you created earlier. Use your username not your "shell" name here
- Click on your username in the top right corner, then choose "Settings".
- Click "SSH Keys" in the menu on the left.
- Paste your SSH Public Key (The contents of the file
~/.ssh/id_ed25519.pub
) into the corresponding field and click "ADD NEW SSH KEY".
This can be a complex step, so if you want to test you did everything right, run the following command from the terminal emulator:
ssh -p 29418 USERNAME@gerrit.wikimedia.org
Replacing USERNAME with the "shell name" field you used when signing up for your developer account. You may get a warning about being unable to verify the authenticity of the host. This is normal, just say yes. After that, if everything worked you should get a message saying "Welcome to Gerrit Code Review" and that interactive shells are disabled.
Cloning MediaWiki
editNow we have to download the MediaWiki files. Run the following commands:
git clone ssh://USERNAMEHERE@gerrit.wikimedia.org:29418/mediawiki/core.git mediawiki git clone ssh://USERNAMEHERE@gerrit.wikimedia.org:29418/mediawiki/skins/Vector.git mediawiki/skins/Vector
Replacing USERNAMEHERE with the shell name you used when registering your wikitech developer account
Run composer
editChange directories into the MediaWiki directory, and run composer install
cd mediawiki composer install
Start the webserver
editStill in the mediawiki directory, run the following command:
php -S 127.0.0.1:8080
php -S 0.0.0.0:8080
Launch your web browser
editNow that everything is installed, lets see if it works. Launch your web browser and go to the website http://localhost:8080
. If everything was done correctly you should be greeted with the MediaWiki logo and a message saying "LocalSettings.php not found. Please set up the wiki first.". Setting up your wiki will be the topic of the next page in this tutorial.
.