Forked from rotexdegba/linux-rails-and-redmin-in-ubuntu-1604-mint18.txt
Last active
June 8, 2018 02:20
-
-
Save gachiemchiep/d4bbf48f832c9318cd6660b9ed5c81ed to your computer and use it in GitHub Desktop.
Installing Rails and Redmine in Ubuntu 16.04 LTS / Linux Mint 18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make sure you have already installed apache and mysql; | |
# see https://gist.github.com/rotexdegba/d0cab757b5194a58c93db5ab6df7dc67 | |
# for instructions. | |
# install rails | |
# https://help.ubuntu.com/lts/serverguide/ruby-on-rails.html | |
sudo apt install rails | |
# install comman dependencies | |
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev make libmysqlclient-dev imagemagick \ | |
libmagickcore-dev libmagickwand-dev | |
#install passenger mod for apache to run rails | |
sudo apt-get install libapache2-mod-passenger | |
sudo mkdir -p /opt/redmine | |
# download redmine and move it (e.g `sudo mv /download/path/redmine-3.3.1 /opt/redmine/`) to | |
# /opt/redmine so we get some thing like /opt/redmine/redmine-3.3.1 | |
# then cd /opt/redmine/redmine-3.3.1 | |
# Run the SQL statement below; Don't forget to replace your_password_here with the password that you specified in the | |
# config/database.yml file while you were configuring the database for Redmine. | |
CREATE DATABASE redmine CHARACTER SET UTF8; | |
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'your_password_here'; | |
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost'; | |
sudo mv ./config/database.yml.example ./config/database.yml | |
# edit ./config/database.yml with the correct db credential values | |
sudo gem install bundler | |
bundle install --without development test | |
# create a secret token for the Redmine session | |
bundle exec rake generate_secret_token | |
# Next, we need to create the structure (tables, indexes, and so on) of the Redmine database: | |
RAILS_ENV=production bundle exec rake db:migrate | |
# Finally, we need to insert initial data (such as trackers, the administrator account, and so on) into the database: | |
RAILS_ENV=production bundle exec rake redmine:load_default_data | |
# Now Configure Apache | |
cd /etc/apache2 | |
# Now, create the redmine.conf file in the sites-available subdirectory with the following content (do this under root): | |
<VirtualHost *:3000> | |
RailsEnv production | |
DocumentRoot /opt/redmine/redmine-3.2.0/public | |
<Directory "/opt/redmine/redmine-3.2.0/public"> | |
Allow from all | |
Require all granted | |
</Directory> | |
</VirtualHost> | |
# This is the configuration of the virtual host that will run Redmine. However, this is not the only virtual host that we currently have. | |
# Please note that Redmine, which is installed and configured this way, is going to run from your user account. | |
# If you prefer to use another user, www-data, for example, you need to add PassengerDefaultUser www-data | |
# to your virtual host configuration, and change the owner of the redmine-3.2.0 directory by executing | |
# chown www-data:www-data /opt/redmine/redmine-3.2.0 -R. | |
# enable the redmine.conf | |
sudo a2ensite redmine | |
# add port 3000 to the /etc/apache2/ports.conf file like so: | |
Listen 3000 | |
# restart apache | |
sudo service apache2 reload | |
# Good books for redmine: | |
# https://www.packtpub.com/networking-and-servers/mastering-redmine-second-edition | |
# https://www.packtpub.com/big-data-and-business-intelligence/redmine-cookbook | |
# Follow instructions here http://www.redmine.org/projects/redmine/wiki/RedmineInstall | |
# then login into Redmine with the following use and password | |
# admin admin | |
# Change http to https (ssl) (letsencrypt) | |
# goto : https://certbot.eff.org/lets-encrypt/ubuntuxenial-apache | |
# and install certbot | |
sudo certbot --apache | |
..... | |
Enter email address (used for urgent renewal and security notices) (Enter 'c' to | |
cancel): email | |
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org | |
------------------------------------------------------------------------------- | |
Please read the Terms of Service at | |
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must | |
agree in order to register with the ACME server at | |
https://acme-v01.api.letsencrypt.org/directory | |
------------------------------------------------------------------------------- | |
(A)gree/(C)ancel: A | |
------------------------------------------------------------------------------- | |
Would you be willing to share your email address with the Electronic Frontier | |
Foundation, a founding partner of the Let's Encrypt project and the non-profit | |
organization that develops Certbot? We'd like to send you email about EFF and | |
our work to encrypt the web, protect its users and defend digital rights. | |
------------------------------------------------------------------------------- | |
(Y)es/(N)o: Yes | |
Starting new HTTPS connection (1): supporters.eff.org | |
No names were found in your configuration files. Please enter in your domain | |
name(s) (comma and/or space separated) (Enter 'c' to cancel): fae-redmine.japanwest.cloudapp.azure.com | |
Obtaining a new certificate | |
Performing the following challenges: | |
http-01 challenge for fae-redmine.japanwest.cloudapp.azure.com | |
Enabled Apache rewrite module | |
Waiting for verification... | |
Cleaning up challenges | |
We were unable to find a vhost with a ServerName or Address of fae-redmine.japanwest.cloudapp.azure.com. | |
Which virtual host would you like to choose? | |
(note: conf files with multiple vhosts are not yet supported) | |
------------------------------------------------------------------------------- | |
1: 000-default.conf | | | Enabled | |
2: redmine.conf | | | Enabled | |
------------------------------------------------------------------------------- | |
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2 | |
Created an SSL vhost at /etc/apache2/sites-available/redmine-le-ssl.conf | |
Enabled Apache socache_shmcb module | |
Enabled Apache ssl module | |
Deploying Certificate to VirtualHost /etc/apache2/sites-available/redmine-le-ssl.conf | |
Enabling available site: /etc/apache2/sites-available/redmine-le-ssl.conf | |
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. | |
------------------------------------------------------------------------------- | |
1: No redirect - Make no further changes to the webserver configuration. | |
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for | |
new sites, or if you're confident your site works on HTTPS. You can undo this | |
change by editing your web server's configuration. | |
------------------------------------------------------------------------------- | |
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2 | |
Enabled Apache rewrite module | |
Redirecting vhost in /etc/apache2/sites-enabled/redmine.conf to ssl vhost in /etc/apache2/sites-available/redmine-le-ssl.conf | |
------------------------------------------------------------------------------- | |
Congratulations! You have successfully enabled | |
.... | |
You should test your configuration at: | |
........ | |
------------------------------------------------------------------------------- | |
IMPORTANT NOTES: | |
.................. | |
# Add sudo certbot --apache to crontab (monthly) | |
# | |
cat /etc/cron.d/certbot | |
0 0 1 * * sudo certbot --apache | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment