User:Bawolff/MediaWiki developer tutorial/environment

From mediawiki.org

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[edit]

If you are not using a virtual machine, skip ahead to the next step.

If you want to browse MediaWiki from a web browser in your host operating system. You may have to adjust the network configuration


Creating a developer account[edit]

Before 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[edit]

Open 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[edit]

Run 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[edit]

For 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[edit]

Now 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[edit]

Change directories into the MediaWiki directory, and run composer install

cd mediawiki
composer install

Start the webserver[edit]

Still in the mediawiki directory, run the following command:

php -S 127.0.0.1:8080
If you are using a virtual machine, and want to access the website from a browser in your host OS, instead use the command: php -S 0.0.0.0:8080

Launch your web browser[edit]

Now 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.

If you are using a virtual machine and want to access the wiki from your host OS, instead of localhost you may have to use the IP of your virtual machine

.