This bash script automates the installation and initial configuration of MediaWiki on Ubuntu 22.04 LTS with Apache, MariaDB, and PHP 8.1.
- Automatic installation of all required dependencies
- MariaDB database creation
- Apache virtual host configuration
- PHP optimization for MediaWiki
- Local development environment setup
- Backup directory creation
- Detailed post-installation instructions
- Ubuntu 22.04 LTS
- Root or sudo privileges
- Internet connection
- VM with dual core virtual cpu
- 2GB ram
- 20 gb of storage
- Download the installation script:
git clone https://github.com/eugeniogiusti/automated-mediawiki-deploy/
- Make the script executable:
chmod +x install_mediawiki.sh
- Run the script:
sudo ./install_mediawiki.sh
- Updates the system packages
- Installs Apache web server
- Installs MariaDB database server
- Installs PHP 8.1 and required extensions
- Creates a database and user for MediaWiki
- Downloads and installs MediaWiki 1.39.3
- Configures Apache virtual host
- Sets up proper file permissions
- Configures PHP settings for optimal performance
- Creates a backup directory
- Adds local domain to hosts file
After the script completes, you will need to:
- Visit http://your_local_ip in your web browser
- Complete the MediaWiki web-based configuration
- Use the database credentials displayed at the end of the installation
- Download and place the generated LocalSettings.php file in /var/www/html/mediawiki/
- The script generates a random database password
- Appropriate file permissions are set
- Apache is configured with secure defaults
You can modify the following variables in the script:
DB_NAME
: Database nameDB_USER
: Database usernameMEDIAWIKI_VERSION
: MediaWiki version to install- PHP settings in the php.ini configuration section
Common issues and solutions:
-
If Apache fails to start, check:
sudo systemctl status apache2 sudo journalctl -u apache2
-
If database connection fails:
sudo systemctl status mariadb
-
Check Apache error logs:
sudo tail -f /var/log/apache2/mediawiki_error.log
The script creates a backup directory at /var/www/html/mediawiki/backups
. It's recommended to:
- Regularly backup your database
- Keep copies of your LocalSettings.php
- Backup any uploaded files
- This script is intended for fresh Ubuntu 22.04 installations.
- During the installation of some libraries, you might see a message like: Daemons using outdated libraries. Which services should be restarted?(screenshoot below)"
This message indicates that some libraries have been updated, but the daemons using them are still running with the previous version loaded in memory. It is not necessary to restart the services immediately, as the system will continue to function normally with the old libraries. To proceed:
- Press the TAB key to select "OK" and confirm.
- Continue with the installation without restarting the services. If you encounter any issues or instability later, try restarting the virtual machine to ensure the services use the latest versions of the libraries.