Docker Mediawiki Local Install: Difference between revisions
Created page with "= 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..." |
|||
Line 38: | Line 38: | ||
database: | database: | ||
condition: service_healthy | condition: service_healthy | ||
volumes: # will uncomment line below after init setup of wiki | |||
# - ./LocalSettings.php:/var/www/html/LocalSettings.php:ro | # - ./LocalSettings.php:/var/www/html/LocalSettings.php:ro | ||
environment: | environment: |
Latest revision as of 20:35, 1 September 2025
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.