Docker Mediawiki Local Install
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: 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. |
Setting Up a Plain MediaWiki Instance with Docker on Ubuntu 24.04
This guide provides a simple, step-by-step process to set up a basic MediaWiki instance locally using Docker and Docker Compose on Ubuntu 24.04.
It is designed for beginners and assumes you have Docker and Docker Compose installed (see Docker_Install_Guide for setup details).
The setup includes MediaWiki with a MariaDB database, running in Docker containers.
Prerequisites
- Ubuntu 24.04
- Docker and Docker Compose installed
- Basic familiarity with terminal commands
- Internet connection for pulling Docker images
Step 1: Create a Project Directory
Create a dedicated directory to organize your MediaWiki setup files.
mkdir mediawiki-docker
cd mediawiki-docker
Step 2: Create a Docker Compose File
Create a docker-compose.yml file to define the MediaWiki and MariaDB services.
nano docker-compose.yml
Paste the following configuration into docker-compose.yml
:
version: '3.8' services: mediawiki: image: mediawiki:1.41 ports: - "8080:80" depends_on: database: condition: service_healthy volumes: # will uncomment line below after init setup of wiki # - ./LocalSettings.php:/var/www/html/LocalSettings.php:ro environment: - MEDIAWIKI_DB_HOST=database - MEDIAWIKI_DB_USER=wikiuser - MEDIAWIKI_DB_PASSWORD=securepassword - MEDIAWIKI_DB_NAME=mediawiki database: image: mariadb:10.11 environment: - MARIADB_ROOT_PASSWORD=securepassword - MARIADB_DATABASE=mediawiki - MARIADB_USER=wikiuser - MARIADB_PASSWORD=securepassword - MARIADB_AUTO_UPGRADE=1 volumes: - db_data:/var/lib/mysql healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] interval: 10s timeout: 5s retries: 5 mem_limit: 512m volumes: db_data:
Save and exit (`Ctrl+O`, `Enter`, `Ctrl+X`).
Explanation:
- The mediawiki service uses MediaWiki 1.41 for stability.
- `database` service uses the MariaDB image for the database.
- Port `8080` maps to MediaWiki's web server port `80`.
- Environment variables set up the database connection.
- A volume persists MariaDB data.
- `LocalSettings.php` will be mounted later after setup.
Step 3: Start the Containers
Run the following command to start the MediaWiki and MariaDB containers:
docker-compose up -d
- `-d` runs containers in the background.
- This pulls the MediaWiki and MariaDB images and starts the services.
Step 4: Verify Containers Are Running
Check that both containers are running:
docker ps
You should see two containers: one for `mediawiki` and one for `mariadb`.
Step 5: Access the MediaWiki Setup Page
Open a web browser and navigate to:
You should see the MediaWiki setup page. If not, ensure containers are running and port `8080` is not blocked.
Step 6: Complete the MediaWiki Web Installer
Follow the on-screen instructions in the browser:
- Select your language and click "Continue."
- Accept the defaults for database settings, these details can be found in your docker-compose.yml file.
- host: database - change from default localhost
- user: wikiuser - change from default root
- password: securepassword
- database name: mediawiki - change from default my_wiki
- Set up an admin user and password for your wiki.
- Complete the installation. At the end, MediaWiki generates a LocalSettings.php file.
Step 7: Download and Place LocalSettings.php
The installer prompts you to download `LocalSettings.php`. Save it to your `mediawiki-docker` directory:
mv ~/Downloads/LocalSettings.php ~/mediawiki-docker/
Ensure the file is named exactly LocalSettings.php.
The Docker Compose configuration mounts this file into the MediaWiki container.
Step 8: Restart Containers
Restart the containers to apply LocalSettings.php:
- Turn off container
docker-compose down
- Edit docker-compose.yml and uncomment the lines
# volumes: # will uncomment these 2 lines after init setup of wiki # - ./LocalSettings.php:/var/www/html/LocalSettings.php:ro
version: '3.8' services: mediawiki: image: mediawiki:1.41 ports: - "8080:80" depends_on: database: condition: service_healthy volumes: # will uncomment these 2 lines after init setup of wiki - ./LocalSettings.php:/var/www/html/LocalSettings.php:ro environment: - MEDIAWIKI_DB_HOST=database - MEDIAWIKI_DB_USER=wikiuser - MEDIAWIKI_DB_PASSWORD=securepassword - MEDIAWIKI_DB_NAME=mediawiki database: image: mariadb:10.11 environment: - MARIADB_ROOT_PASSWORD=securepassword - MARIADB_DATABASE=mediawiki - MARIADB_USER=wikiuser - MARIADB_PASSWORD=securepassword - MARIADB_AUTO_UPGRADE=1 volumes: - db_data:/var/lib/mysql healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] interval: 10s timeout: 5s retries: 5 mem_limit: 512m volumes: db_data:
- start container
docker-compose up -d
Step 9: Access Your Wiki
Visit `http://localhost:8080` again. You should now see your MediaWiki instance. Log in with the admin credentials you set during installation.
Step 10: Basic Usage
- Create and edit pages using the MediaWiki interface.
- Access the wiki at `http://localhost:8080`.
- Manage users and settings via the admin account.
Stopping and Removing Containers
To stop the containers:
docker-compose stop
To stop and remove containers (data persists in the `db_data` volume):
docker-compose down
To remove all data (including the database), also delete the volume:
docker-compose down -v
Network Configuration
By default, your wiki might only be accessible from the host machine where Docker is running, using localhost
or 127.0.0.1
. However, if you want others on your network to access your wiki, you need to make some adjustments.
Current Setup: The computer running Docker Compose has an IP address of 192.168.0.44
.
- You can find the IP address of your computer running Docker using the command:
ip addr
OutPut from ip addr
noob@noob-HP-EliteDesk-800-G1-DM:~$ ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host noprefixroute valid_lft forever preferred_lft forever 2: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000 link/ether 8c:dc:d4:3d:93:49 brd ff:ff:ff:ff:ff:ff altname enp0s25 3: wlxe8de27142be2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether e8:de:27:14:2b:e2 brd ff:ff:ff:ff:ff:ff inet 192.168.0.44/24 brd 192.168.0.255 scope global dynamic noprefixroute wlxe8de27142be2 valid_lft 86357sec preferred_lft 86357sec inet6 fe80::afbe:cc73:73a2:fcdf/64 scope link noprefixroute valid_lft forever preferred_lft forever
My IP is 192.168.0.44
If someone from another computer on the network tries to visit 192.168.0.44:8080
, they might encounter a "cannot connect" error. This happens because MediaWiki, by default, redirects to 127.0.0.1:8080
, which is only accessible from the host machine itself.
Solution: To allow access from other devices on the same network, you need to:
- Edit the
LocalSettings.php
File: This isn't done inside the Docker container but rather in the directory where yourdocker-compose.yml
file is located (~/mediawiki-docker/LocalSettings.php). Here, you need to change the server URL configuration.
- Modify URL Configuration: On lines 34-35 of
LocalSettings.php
, you'll find the following:
Allowing Access from Other Network Devices
Edit LocalSettings.php
in the Docker Compose directory to change the server URL:
- Default - around line 33
## The protocol and server name to use in fully-qualified URLs
$wgServer = 'http://127.0.0.1:8080';
- Changed
## The protocol and server name to use in fully-qualified URLs
$wgServer = 'http://192.168.0.44:8080';
- Restart Docker to apply changes:
docker-compose restart
This allows access to your wiki from other devices on the network using 192.168.0.44:8080
.
This adjustment tells MediaWiki to use the network IP of the host (192.168.0.44
) instead of the local loopback (127.0.0.1
), allowing other devices on the network to access the wiki through 192.168.0.44:8080
. Even after this change, localhost:8080
or 127.0.0.1:8080
will still work on the host machine, but now the wiki is also accessible via the network IP from other devices.
Troubleshooting
- Cannot access localhost:8080: Check `docker ps` to ensure containers are running. Verify port `8080` is not used by another service (`sudo netstat -tuln | grep 8080`).
- Database connection error: Ensure environment variables in `docker-compose.yml` match the installer settings.
- LocalSettings.php not found: Confirm the file is in the `mediawiki-docker` directory and named correctly.
Notes
- The database data is stored in a Docker volume (`db_data`) and persists between container restarts.
- To customize MediaWiki, edit `LocalSettings.php` and restart containers.
- For production, secure `MYSQL_ROOT_PASSWORD` and `MEDIAWIKI_DB_PASSWORD` with stronger values.