Full SSH root access or a user with sudo privileges.
To connect to your server via SSH as the root user, use the following command:
$ ssh root@IP_ADDRESS -p PORT_NUMBER
and replace IP_ADDRESS
and PORT_NUMBER
with your actual server IP address and SSH port number.
Once logged in, make sure that your server is up-to-date by running the following commands:
$ apt-get update
$ apt-get upgrade
Next, we need to install the MySQL server. Ubuntu 18.04 has the latest stable version of MySQL ready for installation through the pre-installed repositories.
The following command will install the latest MySQL 5.7 server from the official Ubuntu repositories:
$ apt-get install libssl-dev mysql-server
The MySQL server will be started automatically as soon as the installation is completed. You can also enable the MySQL service to automatically start up upon server reboot with the following command:
$ systemctl enable mysql
Run the following command to further secure your installation:
$ mysql_secure_installation
This script will help you to perform important security tasks like setting up a root password, disable remote root login, remove anonymous users, etc. If the script asks for the root password, just press the [Enter] key, as no root password is set by default.
Next, we need to create a database for our Redmine installation. Log in to your MySQL server with the following command and enter your MySQL root password:
$ mysql -uroot -p
In this section, we will create a new MySQL database:
CREATE DATABASE redmine_db;
GRANT ALL PRIVILEGES ON redmine_db.* TO 'redmine_user'@'localhost' IDENTIFIED BY 'Password';
FLUSH PRIVILEGES;
exit;
Make sure to replace the password Password with a real, strong password.
The easiest way to install Ruby on your Ubuntu 18.04 server is through the apt package manager. The current version in the Ubuntu repositories is 2.5.1 which is the latest stable version of Ruby at the time of writing this tutorial.
Install Ruby with the following command:
$ apt-get install ruby-full
To verify everything is done correctly, use the command ruby --version.
The output should be similar to the following:
$ ruby --version
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
To install Nginx on your Ubuntu 18.04 server, you need to enter the following command:
$ apt-get install nginx
Enable Nginx to start on boot and start the service using these two lines:
$ systemctl start nginx
$ systemctl enable nginx
To install Passenger, an Nginx module, start by installing the necessary package prerequisites:
$ apt-get install dirmngr gnupg apt-transport-https ca-certificates
Import the repository GPG key and enable the “Phusionpassenger” repository:
$ apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 561F9B9CAC40B2F7
$ add-apt-repository 'deb https://oss-binaries.phusionpassenger.com/apt/passenger bionic main'
Once the repository is enabled, update the packages list and install the Passenger Nginx module with:
$ apt-get update
$ apt-get install libnginx-mod-http-passenger
We need to install the dependencies necessary to build Redmine:
$ apt-get install build-essential libmysqlclient-dev imagemagick libmagickwand-dev
Go to Redmine’s official website and download the latest stable release of the application. At the time of this article being published, the latest version of Redmine is version 4.0.5.
$ wget https://www.redmine.org/releases/redmine-4.0.5.zip -o /opt/redmine.zip
Once the zip
archive is downloaded, unpack it to the /opt
directory on your server:
$ cd /opt
$ apt-get install unzip
$ unzip redmine.zip
$ mv redmine-4.0.2 /opt/redmine
Now apply the following required file and folder permissions (these are needed in order for Nginx to have access to the files):
$ chown -R www-data:www-data /opt/redmine/
$ chmod -R 755 /opt/redmine/
Configure database settings:
$ cd /opt/redmine/config/
$ cp configuration.yml.example configuration.yml
$ cp database.yml.example database.yml
Open the database.yml file using your preferred text editor and update the username/password details based on the ones you set in Step 3:
$ nano database.yml
production:
adapter: mysql2
database: redmine_db
host: localhost
username: redmine_user
password: "Password"
encoding: utf8
Then save and exit the file.
Navigate to the Redmine directory and install bundler and other Ruby dependencies:
$ cd /opt/redmine/
$ gem install bundler --no-rdoc --no-ri
$ bundle install --without development test postgresql sqlite
Run the following command to generate the keys and migrate the database:
$ bundle exec rake generate_secret_token
$ RAILS_ENV=production bundle exec rake db:migrate
Open your preferred text editor and create the following Nginx server block file:
$ nano /etc/nginx/sites-available/redmine.mydomain.com.conf
Add this configuration to your config file:
# Redirect HTTP -> HTTPS
server {
listen 80;
server_name www.redmine.mydomain.com redmine.mydomain.com;
# include snippets/letsencrypt.conf;
return 301 https://redmine.mydomain.com$request_uri;
}
# Redirect WWW -> NON WWW
server {
listen 443 ssl http2;
server_name www.redmine.mydomain.com;
return 301 https://redmine.mydomain.com$request_uri;
}
server {
listen 443 ssl http2;
server_name redmine.mydomain.com;
root /opt/redmine/public;
# SSL parameters will be injected by Certbot in a later step
# log files
access_log /var/log/nginx/redmine.mydomain.com.access.log;
error_log /var/log/nginx/redmine.mydomain.com.error.log;
passenger_enabled on;
passenger_min_instances 1;
client_max_body_size 10m;
}
Remember to replace redmine.mydomain.com with your own custom domain Then save and exit the file.
Install certbot:
$ apt-get install certbot python-certbot-nginx
Generate the certificate and configuration for Nginx
$ certbot --nginx
follow the instructions provided by certbot
. at the end, the certificate should be installed and verified.
To enable the server configuration that we just created, run the following command:
$ ln -s /etc/nginx/sites-available/redmine.mydomain.com.conf /etc/nginx/sites-enabled/redmine.mydomain.com.conf
Now, check the config file to make sure that there are no syntax errors. Any errors could crash the web server on restart.
$ nginx -t
Output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
If there are no errors, you can reload the Nginx config.
Now reload Nginx
$ service nginx reload
Thank you! This is work fine with Redmine 4.1.1 on Ubuntu 18.04