Back in 2016, I was asked for setting up GitLab, Redmine, and MediaWiki on a single Linux machine for our development team at work. This blog is just a record for how I built all stuff from scratch. At that time, it was based on Ubuntu 14.04, but in this blog I will go through all the steps based on Ubuntu 18.04.
Due to the compatibility issues on plugins for Redmine that I setup earlier, I will keep its version for now. The other two, GitLab and MediaWiki, will be upgraded to the latest versions (as of 2019).
Goal
- To run GitLab, Redmine, MediaWiki on Apache web server
- Redmine and MediaWiki use MySQL database (No change for GitLab which uses PostgreSQL by default)
- Each one of services will be running in its
sub-URI
. For example:- GitLab: http://localhost/gitlab
- Redmine: http://localhost/redmine
- MediaWiki: http://localhost/mediawiki
Environment
- LAMP
- Linux Ubuntu 18.04: http://releases.ubuntu.com/18.04/
- Apache 2.4.29
- MySQL 5.0.12
- PHP 7.2.19
- GitLab Community Edition (CE): https://about.gitlab.com/install/#ubuntu
- Redmine 3.3.9 - http://www.redmine.org/releases/
- Redmine Guide
- MediaWiki 1.32.2 - https://www.mediawiki.org/wiki/Download
- MediaWiki Installation Guide
Prerequisite
Install basic packages
1
2sudo apt update
sudo apt install -y bash-completion nano git curlUpdate locale on Linux machine
1
2
3sudo locale-gen "en_US.UTF-8"
sudo update-locale LANG=en_US.UTF8
localectl
Install LAMP
LAMP
is an archetypal model of web service stacks, named as an acronym of the names of its original four open-source components: theLinux
operating system, theApache
HTTP Server, theMySQL
relational database management system (RDBMS), and thePHP
programming language.
Following packages are required for setting up Redmine and MediaWiki.
1 | sudo apt install -y apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring |
Configure and run MySQL
1 | sudo service mysql stop |
Add your server domain name to the end of Apache config file /etc/apache2/apache2.conf
. For demo purpose, I use localhost
here.
1 | sudo nano /etc/apache2/apache2.conf |
Add ServerName localhost at the end of the file.
Restart the Apache service:
1 | sudo service apache2 restart |
Reference:
How to install MediaWiki on Debian or Ubuntu
Now your Apache web server should be up and running on http://127.0.0.1 and you should be able to see Apache test page as follow.

Create a phpinfo test page:
1 | echo '<?php phpinfo(); ?>' | sudo tee /var/www/html/phpinfo.php |
Navigate to http://localhost/phpinfo.php on your browser and you should be able to see outputs information for your PHP’s configuration.
Setup Ruby on Rails
Ruby on Rails, or Rails, is a server-side web application framework written in Ruby under the MIT License. Rails is a model–view–controller (MVC) framework, providing default structures for a database, a web service, and web pages.
Redmine runs on Rails. It is why we need to install Ruby and Rails. Depending on the version of Redmine, you may have different requirements on Ruby and Rails.
For more information, please see:
https://www.redmine.org/projects/redmine/wiki/RedmineInstall
In my case, I am going to install Redmine 3.3.9, so I will have to install Ruby 2.4.x and Rails 4.2.x.
Reference:
https://gorails.com/setup/ubuntu/18.04
Install Ruby
The first step is to install dependencies for Ruby and Rails:
1 | curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - |
1 | sudo apt update |
Then, install Ruby by rbenv
:
1 | cd ~ |
1 | git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build |
1 | rbenv install 2.4.9 |
Finally, install the latest bundler and rehashes shims.
1 | gem install bundler |
- From time to time you’ll need to rebuild your shim files. You can always run
rbenv rehash
manually. - All versions of bundler: https://rubygems.org/gems/bundler/versions
Install Rails
1 | gem install rails -v 4.2.11.1 |
- In case if you run into the issue as
sprockets requires Ruby version >= 2.5.0.
, you can install the old version of sprockets by issuing following command:1
gem install sprockets -v 3.7.2
Setup Services
MediaWiki
MediaWiki is a free and open-source wiki engine. It was developed for use on Wikipedia in 2002, and given the name “MediaWiki” in 2003. It remains in use on Wikipedia and almost all other Wikimedia websites, including Wiktionary, Wikimedia Commons and Wikidata; these sites continue to define a large part of the requirement set for MediaWiki. MediaWiki was originally developed by Magnus Manske and improved by Lee Daniel Crocker. Its development has since then been coordinated by the Wikimedia Foundation.
Install MediaWiki
Download MediaWiki source code:
1 | cd ~ |
In our case, we supposed to have more than one people to manage the services. Therefore, we setup a group so that all users, who are in the same group, will have the same permissions to take care of the services.
1 | sudo groupadd mediawiki |
Make sure directories and files have correct permissions:
1 | sudo chown -R root.mediawiki /opt/mediawiki-1.32.2 |
Create the database for MediaWiki, where the name of database is wikiDB
, the owner of the database wikiDB
is wikiAdmin
, the password of the user wikiAdmin
is wikiPassword
. You can choose your own DB name and username/password.
1 | # mysql -u root -p # for Ubuntu 16.04 or before |
Configure MediaWiki
In order to run in sub-URI, create a symbolic link for MediaWiki under /var/www/html/
:
1 | sudo ln -s /opt/mediawiki-1.32.2/ /var/www/html/mediawiki |
Run http://localhost/mediawiki on your browser, and go through the steps to configure your MediaWiki. LocalSettings.php
file will be generated in the end of configuration process.
Below is the changes I made on LocalSettings.php
file:
1 | $wgSitename = "MY_WiKi"; |
For more details on configuration:
https://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Debian_or_Ubuntu
Test
You should be able to see your MediaWiki on http://localhost/mediawiki
Redmine
Redmine is a free and open source, web-based project management and issue tracking tool. It allows users to manage multiple projects and associated subprojects. It features per project wikis and forums, time tracking, and flexible, role-based access control. It includes a calendar and Gantt charts to aid visual representation of projects and their deadlines. Redmine integrates with various version control systems and includes a repository browser and diff viewer.
Reference:
https://www.redmine.org/
Create a group for redmine, and add the user to the group.
1 | sudo groupadd redmine |
Download Redmine source code
1 | cd ~ |
Make sure directories and files have correct permissions:
1 | sudo chown -R root.redmine /opt/redmine-3.3.9 |
Database connection configuration
1 | # mysql -u root -p # for Ubuntu 16.04 or before |
As you can see, the name of database is redmineDB
, the owner of the database redmineDB
is redmineAdmin
, the password of the user redmineAdmin
is redminePassword
.
The above information will be needed for config/database.yml
. Here’s my database config file:
1 | production: |
For more info, please see:
https://www.redmine.org/projects/redmine/wiki/RedmineInstall#Step-3-Database-connection-configuration
Dependencies Installation
Due to the versions of Redmine (v3.3.9) and Ruby (v2.4.6) we use, we need to downgrade the version of bundler
for v1.17.3 to be able to install dependencies.
1 | cd /opt/redmine-3.3.9/ |
Other Configurations
1 | RAILS_ENV=production bundle exec rake generate_secret_token # Session store secret generation |
(Optional) Setup SMTP for Sending Notification E-mails
1 | # default configuration options for all environments |
IP address points to your SMTP server. By default, the port of SMTP should be 25
.
Test
In order to run in sub-URI, create a symbolic link for Redmine under /var/www/
:
1 | sudo ln -s /opt/redmine-3.3.9/ /var/www/redmine |
Before we test Redmine, let’s setup GitLab first.
GitLab Community Edition
GitLab is a web-based DevOps lifecycle tool that provides a Git-repository manager providing wiki, issue-tracking and CI/CD pipeline features, using an open-source license, developed by GitLab Inc. The software was created by Dmitriy Zaporozhets and Valery Sizov, and is used by several large tech companies.
Reference:
https://about.gitlab.com/install/#ubuntu
Enable Apache Modules
1 | sudo a2enmod proxy |
Install Dependencies
1 | sudo apt update |
(Optional) Install Postfix for Sending Notification E-mails
1 | sudo apt install -y postfix |
Install GitLab CE
1 | curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash |
Note that the certificate is required if you prefer https
.
[Issue] In case if you run into an issue and get stuck like blow:
1
2
3
4...
...
...
* ruby_block[wait for redis service socket] action runTo solve the problem, open a new terminal and issue the following command:
1
/opt/gitlab/embedded/bin/runsvdir-start
Passenger
By default, GitLab uses NGINX
as web server and Unicorn
as Rack HTTP server to serve Ruby web applications. Since we want all services, GitLab, Redmine, and MediaWiki, running on Apache web server instead, we therefore disable NGINX
and Unicorn
, and enable Passenger
(Phusion Passenger
) as our application server.
Passenger
is perfectly integrated with Apache as an Apache module, and you can configure it by Apache configuration file.
Build Passenger Apache module:
1 | sudo apt install -y apache2-dev libapr1-dev libaprutil1-dev |
It will take a while to compile the source. After it’s done, follow the instructions provided on the screen to configure Passenger module correctly for Apache.
Following is an example of my Apache configuration for Passenger.
1 | LoadModule passenger_module /home/jocodoma/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/passenger-6.0.4/buildout/apache2/mod_passenger.so |
1 | <IfModule mod_passenger.c> |
Enable Passenger module and then restart the Apache service:
1 | sudo a2enmod passenger |
Configuration Options
GitLab is configured by setting the relevant options in /etc/gitlab/gitlab.rb
. See package defaults for a list of default settings and visit the gitlab.rb.template
for a complete list of available options. New installations starting from GitLab 7.6, will have all the options of the template as of installation listed in /etc/gitlab/gitlab.rb
by default.
Below are the changes I made:
1 | external_url 'http://localhost/gitlab' |
Reconfigure GitLab:
1 | sudo gitlab-ctl reconfigure |
References:
- https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
- https://docs.gitlab.com/omnibus/settings/unicorn.html
Test
In order to run in sub-URI, create a symbolic link for GitLab under /var/www/
:
1 | sudo ln -s /opt/gitlab/embedded/service/gitlab-rails/ /var/www/gitlab |
Let’s move on to the final configuration for sub-URIs on Apache, then we’ll do the tests to verify both Redmine and GitLab.
Apache Configuration for Sub-URIs
Create a folder for gitlab logs:
1 | sudo mkdir -p /var/log/apache2/gitlab/ |
Here’s my Apache sites configuration:
1 | ### |
Create a symbolic link to enable the configuration.
1 | cd /etc/apache2/sites-enabled/ |
- Remember to remove the default configuration file,
000-default.conf
.
Restart the Apache service:
1 | sudo service apache2 restart |
Restart GitLab:
1 | sudo gitlab-ctl restart |
Test
Check following URLs on your browser:
http://localhost/gitLab
http://localhost/redmine
http://localhost/mediawiki
Congratulations! We made it!
(Optional) DirectoryIndex
In case if you want to change the order of index files:
1 | sudo pico /etc/apache2/mods-available/dir.conf |
Update Services
Redmine
Download the latest version of 3.3.x from: http://www.redmine.org/releases/
Update
1
2
3
4
5
6
7
8cd /opt/redmine-3.3.x/
# RAILS_ENV=production bundle install --without development test
RAILS_ENV=production bundle _1.17.3_ install --without development test
RAILS_ENV=production bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake redmine:plugins:migrate
RAILS_ENV=production bundle exec rake tmp:cache:clear tmp:sessions:clear
sudo service apache2 restartRemove plugin
1
RAILS_ENV=production bundle exec rake redmine:plugins:migrate NAME={plugin} VERSION=0
Reset database
Note that ALL OF YOUR DATA IN DATABASE WILL BE GONE.1
RAILS_ENV=production bundle exec rake db:migrate:reset
Backup Services
Redmine
Redmine Database
1
2export MYPATH=$PWD
mysqldump -h localhost -u root --password=redminePassword redmineDB | gzip > ${MYPATH}/backup_redmine_DB_`date +20%y_%m_%d`.gzRedmine Files
1
2export MYPATH=$PWD
cd /opt/redmine-3.3.9/ && tar zcf ${MYPATH}/backup_redmine_files_`date +20%y_%m_%d`.tgz .
MediaWiki
MediaWiki Database
1
2export MYPATH=$PWD
mysqldump -h localhost -u root --password=wikiPassword wikiDB | gzip > ${MYPATH}/backup_wiki_DB_`date +20%y_%m_%d`.gzMediaWiki Files
1
2export MYPATH=$PWD
cd /opt/mediawiki-1.32.2/ && tar zcf ${MYPATH}/backup_wiki_files_`date +20%y_%m_%d`.tgz .
Restore Databases from Backup
Before you follow the steps to restore database from backup, make sure that the corresponding database is created. Please refer to Install Redmine, or Install MediaWiki.
Reference:
https://www.redmine.org/projects/redmine/wiki/RedmineBackupRestore
Redmine
1 | # gunzip -c backup_redmine_DB.gz | mysql -u root -p redmineDB ## for old version |
MediaWiki
1 | # gunzip -c backup_wiki_DB.gz | mysql -u root -p wikiDB ## for old version |
Run on Chromebook (crouton)
Install iptables package
1
2sudo apt update
sudo apt install -y iptablesBelow is the script to run all services
/etc/rc.local 1
2
3
4
5
6
7
sudo /opt/gitlab/embedded/bin/runsvdir-start &
sudo service mysql restart
sudo service apache2 restart
sudo /sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT ## Accept TCP port 22 for SSH
sudo /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT ## Accept TCP port 80 for HTTP
sudo /sbin/iptables -P INPUT DROP ## Block all other inputs