Move Redmine Server whilst keeping external database - redmine

I currently have redmine running on an nginx server. The actual MySQL database is on an external server and everything is working fine.
Now I would like to move it to an Apache Server on a different machine, ideally without changing/moving the database.
Is this possible, or do I always need to export/import the database regardless? Happy to stick with the same version of redmine (in my case 4.0.1., Ruby 2.5.1-p57, Rails 5.2.2, no plugins installed). If positive, what are the conditions on Ruby/Rails versions? Do they all have to be exactly what I had on the old one?

Database scheme is not affected by ruby version, only by Redmine's version, because new versions might add or remove stuff in database.
So in your case, copy-pasting your old Redmine to new server should work.
However you must ensure that new Redmine server (probably new IP) has proper privileges to access MySQL database.
And you must follow upgrade tutorial, because your new server needs to pull and install Ruby Gems, clear old cache from tmp folder etc...
https://www.redmine.org/projects/redmine/wiki/RedmineUpgrade

Aleksander's answers gave me confidence that it can be done, but I ended up persevering with my initial approach until I got that working rather than changing to his proposals.
I am afraid that I lost track of the sources for various bits, its primarily from the redmine help pages.
My complete solution was
sudo apt update
sudo apt upgrade
sudo apt install build-essential libmysqlclient-dev imagemagick libmagickwand-dev ruby-full
sudo apt install apache2 libapache2-mod-passenger
sudo gem update
sudo gem install bundler
sudo curl -L https://www.redmine.org/releases/redmine-4.0.1.tar.gz -o /tmp/redmine.tar.gz
sudo tar zxf /tmp/redmine.tar.gz
sudo mv redmine-4.0.1 /opt/redmine
sudo touch /opt/redmine/Gemfile.lock
sudo chown www-data:www-data /opt/redmine/Gemfile.lock
sudo chmod a+w /opt/redmine/Gemfile.lock
sudo cp /opt/redmine/config/database.yml.example /opt/redmine/config/database.yml
sudo ln -s /opt/redmine/public /var/www/html/redmine
cd /opt/redmine
mkdir -p /opt/redmine/app/assets/config && echo '{}' > /opt/redmine/app/assets/config/manifest.js
bundle install
bundle exec rake generate_secret_token
Note the manifest line above only applies to my particular redmine version which was incompatible with later sprockets versions. Also note that changing the permissions a+w is possibly excessive, but I struggled with permissions otherwise.
Then we have to do a few more manual tweaks. Open the file with your text editor:
sudo nano /opt/redmine/config/database.yml
and change production to be the following
production:
adapter: mysql2
database: myredminedatabasename
host: mysqlserver.somewhere.com
username: dbusername
password: "dbpassword"
encoding: utf8
Need to add the PassengerDefaultUser line to /etc/apache2/mods-available/passenger.conf (leave the other two lines the same even if slightly different)
<IfModule mod_passenger.c>
PassengerDefaultUser www-data
PassengerRoot /usr
PassengerRuby /usr/bin/ruby
</IfModule>
Change /etc/apache2/sites-available/000-default.conf to insert the following with the other sections so that apache knows to follow the symlink into Rails. Also note the first line setting DocumentRoot, which was oone of my personal stumbling blocks.
DocumentRoot /var/www/html/redmine
<Directory /var/www/html/redmine>
RailsBaseURI /redmine
PassengerResolveSymlinksInDocumentRoot on
</Directory>
We also need to copy the contents of files folder from /opt/redmine/files on older server to the new server in same location.
Also copy the email settings across in /opt/redmine/config/configuration.yml.
Then restart your server and it should be working.

Related

Changes in Apache SuperSet .less templates are not being applied to interface after build

I'm currently running Apache Superset which is working very well.
However, I've now received a requirement to make a few structural changes to the CSS layout and formatting of the Superset interface. Making changes to the dashboard CSS templates and config.py won't be sufficient. So what I would like to achieve is to make changes to the superset .less templates and have chose changes applied to the interface. However, so far I've not been able to successfully making any changes to the interface by changing the .less templates.
What I've tried to far is to:
Follow all the instructions to build my Apache Superset from source using the instructions here: https://github.com/apache/superset/blob/master/CONTRIBUTING.md#setup-local-environment-for-development
Make changes to the .less templates as described here: https://debaatobiee.wordpress.com/2019/08/04/customizing-apache-superset-ui-config-theme-changes/
However, after making changes to the .less templates, and rebuilding using "npm run build" and "npm run dev-server" in directory superset-frontend, it seems that those changes are not being applied.
Am I doing any steps incorrectly? I'm using a aws t3.large machine with Ubuntu Server 20.04 LTS (HVM) x86 and I run the following commands from machine creation:
sudo apt update
sudo apt upgrade
sudo apt-get install build-essential libssl-dev libffi-dev python3-dev python3-pip libsasl2-dev libldap2-dev libmysqlclient-dev python3.8-venv
git clone https://github.com/apache/superset.git
cd superset
python3 -m venv venv
. venv/bin/activate
pip install -r requirements/development.txt
pip install pymssql
pip install -e .
superset db upgrade
superset fab create-admin
superset init
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.0/install.sh | bash
source ~/.nvm/nvm.sh
cd superset-frontend
nvm install --lts
nvm use --lts
npm ci
I edit the file ~/superset/superset-frontend/src/assets/stylesheets/less/variables.less as follows:
Replace #primary-color: #20a7c9 with #primary-color: #00ff00
Now in one command prompt I run the following command:
FLASK_ENV=development superset run -p 8088 -h 0.0.0.0 --with-threads --reload --debugger
And in another command prompt I run the following:
npm run build
npm run dev-server
I can successfully connect to the page on port 9000. However, even after ctrl+f5 the css never seems to change according to the changes I made in the .less templates. In this example I would have expected the color to have changed (no more #20a7c9 in the css, but #00ff00 instead).
What am I doing incorrectly in my approach? Or is there an easier way to do what I'm trying to do (make site-wide LESS/CSS changes)? I've tried using Docker but I wasn't successful in making that work.
After more testing I found that my changes from the .less templates were in fact being applied using the approach I mentioned. I had just not made enough changes in the .less templates to notice the difference. So by making more changes, and checking in the right places, I could change the Superset interface. Moving forward I've learned to make more rigorous changes and figure out how they influence the interface through trial and error. Still feels like an inefficient approach though - if there would be a quicker way to apply & test css / less changes instead of rebuilding that would be helpful.

Linode/Django Can't see site when I runserver at ip:8000

I had started a fresh linode running ubuntu 19.04 and the first time I used the directions at:
https://www.rosehosting.com/blog/how-to-install-mezzanine-cms-on-ubuntu-18-04/
To install Mezzanine CMS it worked just fine, I could run the runserver command and see the django website. Eventually it started giving me a problem after trying 50 ways to deploy the site using apache and mod_wsgi.
I gave up and rebuilt the server and then still couldn't see the new install at the IP when I ran run server. I figured maybe it was because I accidentally installed some things using "python" and others with "python3" so I rebuilt the server.
This third time I followed the direction perfectly, the only difference is I didn't install a mysql server just kept the default SQLlite server and created a DB and Django Superuser.
I have added my ip as a host in settings.py and local_settings.py
I have already ran makemigrations and migrate
I did check to see if maybe the IP had changed when I rebuilt, it hadn't
My local environment on my laptop works fine, just not the linode
Any suggestions on anything I'm missing?
Deployment Guide
Step 1 (Installation)
Install apache2 mod_wsgi
Install virtualenv
Install virtualenv
Install Nginx for asynchronous event-driven approach to handle multiple client requests
Install mysql
sudo apt-get update
sudo apt-get install python3-pip python3-dev apache2 libapache2-mod-wsgi-py3
sudo apt-get install virtualenv ufw
sudo apt-get install nginx
sudo apt-get install mysql-server libmysqlclient-dev
sudo mysql_secure_installation
Step 2 (Apache & Hostname & User)
Set hostname and add it into /etc/hosts with hostname and your Server IP
Create new user and give add to the group sudo for safety
sudo adduser username
sudo usermod -aG sudo
Enable SSH authentication for login & Edit default port of ssh in /etc/ssh/sshd_config. https://askubuntu.com/questions/1074034/not-able-to-change-ssh-port-on-ubuntu-18-04-1-lts
Edit /etc/apache2/site-availabledefault-000.conf for your new Django configuration
Step 3 (Firewall)
sudo ufw allow 8000
sudo ufw allow http
sudo ufw allow ssh
sudo ufw default allow outgoing
sudo ufw default deny incoming
Enable all other required port numbers
ssh sudo ufw enable
Step 4 (Django configuration)
Chown static and media forlders and edit it's permission recursively
Add allowed host in settings.py
Checkout deployment checklist in django official website and do it.
Step 5 (Please checkout)
For apache configuration please visit https://pythonprogramming.net/deploying-to-server-django-tutorial/
Edit the path given in your apache configuration (path for WSGI Script,python-path, python-home ) if any errors found like Internal server error, miss configuration etc
For reference of python-home path please refer Get virtualenv's bin folder path from script
You can also add python-path to WSGIDaemonProcess
Additionally, you can visit puttygen for public and private key generation to login through SSH
For this particular problem turned out I just needed to suddenly bind dev server to 0.0.0.0
the command to do so was
python manage.py runserver 0.0.0.0:8000
Rinshans answers is definetley the details for deployment, I've followed those steps just kept making some mistake in the config and wsgi scripts. I'm going to try deploying with Gunicorn or use the Fabric self-deployment tools built in to Mezzanine CMS, just haven't done so yet.

How about manage system dependencies when using azk?

I'm using azk and my system depends on extra packages. I'd be able to install them using (since I'm using an Ubuntu-based image):
apt-get -yq update && apt-get install -y libqtwebkit-dev qt4-qmake
Can I add this steps to provision? In the Azkfile.js, it would look like:
// ...
provision: [
"apt-get -yq update",
"apt-get install -y libqtwebkit-dev qt4-qmake",
"bundle install --path /azk/bundler",
"bundle exec rake db:create",
"bundle exec rake db:migrate",
]
Or it's better to create a new Docker image?
Provision steps are run in a separated container, so all the data generated inside of it is lost after the provision step, unless you persist them. That's why you probably have bundle folders as persistent folders.
Since that, you should use a Dockerfile in this case. It'll look like this:
FROM azukiapp/ruby:2.2.2 # or the image you were using previously
RUN apt-get -yq update && \
apt-get install -y libqtwebkit-dev qt4-qmake && \
apt-get clean -qq && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Keeping the image as small as possible
After that, you should edit your Azkfile.js and replace the image property of your main system to use the created Dockerfile (you can check azk docs here):
image: { dockerfile: './PATH_TO_DOCKERFILE' },
Finally, when you run azk start, azk will build this Dockerfile and use it with all your dependencies installed.
Tip: If you want to force azk to rebuild your Dockerfile, just pass -B flag to azk start.
As it looks like you're using a Debian-based Linux distribution, you could create (https://wiki.debian.org/Packaging) your own Debian virtual package (https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics.en.html#s-virtual) that lists all the packages it depends on. If you just do that one thing, you can dpkg -i (or apt-get install if you host a custom debian repository yourself) your custom package and it will install all the dependencies you need via apt.
You can then move on to learning about postinst and prerm scripts in Debian packages (https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics.en.html#s-maintscripts). This will allow you to run commands like bundle and gem as the last step of the package installation and the first step of package removal.
There are a few advantages to doing it this way:
1. If you host a package repository somewhere you can use a pull method of dependency installation in a dynamic scaling environment by simply having the host apt-get update && apt-get install custom-dependencies-diego
2. Versioning your dependency list - Using dpkg -l you can tell what version everything is on a given host, including the version of your dependency virtual package.
3. With prerm scripts, you can ensure that removing your virtual package will also have the effect of removing the changes your installation scripts made so you can get a host back to a "clean" state".
The disadvantage of doing it this way is that it's debian/apt specific. If you wanted to deploy to Slack or RHEL you'd have to change things a bit. Changing to a new distro wouldn't be particularly hard, but it's definitely not as portable as using Bash, for example.

yum update from wrong repository i

I am running a AWS Linux AMI in AWS, it seems to be RHEL under the covers and uses yum (kernel 3.4.62-53.42.amzn1.x86_64) . The amazon repo includes nginx 1.4.2 which is out of date so I removed it and re-installed using the repo given at nginx website. I did this as such:
sudo yum remove nginx*
sudo yum --disablerepo="*" --enablerepo="nginx" install nginx
Note that yum priorities are disabled. I tried messing around with setting priority= in the repo files but decided disabling priorities made sense after reading up on it.
/etc/yum.repos.d files :
amzn-main.repo contains:
[amzn-main]
name=amzn-main-Base
mirrorlist=http://repo.us-east-1.amazonaws.com/$releasever/main/mirror.list
mirror_expire=300
metadata_expire=300
priority=10
failovermethod=priority
fastestmirror_enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-amazon-ga
enabled=1
retries=5
timeout=10
report_instanceid=yes
[amzn-main-debuginfo]
name=amzn-main-debuginfo
mirrorlist=http://repo.us-east-1.amazonaws.com/$releasever/main/debuginfo/mirror.list
mirror_expire=300
metadata_expire=300
priority=10
failovermethod=priority
fastestmirror_enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-amazon-ga
enabled=0
retries=5
timeout=10
report_instanceid=yes
nginx.repo contains:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/6/$basearch/
gpgcheck=0
enabled=1
priority=1
Now doing the update once nginx 1.4.3 is installed, it tries to install the old version from the amazon main repo:
$ sudo yum update
Loaded plugins: update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 0:1.4.3-1.el6.ngx will be updated
---> Package nginx.x86_64 1:1.4.2-1.12.amzn1 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
So not sure why its picking up the older version. Is there a way to configure yum to only update if the version is newer than currently installed? If there is no way, is there a way to skip nginx package when I do a general update and then update nginx using another command as described above that disables all repos and uses only nginx repo, here it is again:
sudo yum --disablerepo="*" --enablerepo="nginx" install nginx
To ignore any specific package in a single yum repository, one may add the following line to their /etc/yum.repos.d/${amazonreponame}.repo configuration file:
exclude=package_name*
Example:
[amzn-main]
name=amzn-main-Base
mirrorlist=http://repo.us-east-1.amazonaws.com/$releasever/main/mirror.list
mirror_expire=300
metadata_expire=300
priority=10
failovermethod=priority
fastestmirror_enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-amazon-ga
enabled=1
retries=5
timeout=10
report_instanceid=yes
exclude=nginx*
The exclude=* option may also be added globally (i.e., all repos) to /etc/yum.conf

How do you install Docutils from the Terminal so that Django admindocs will work?

Docutils is a great package. If you are using Django the admindocs package needs docutils. Instructions are available for installing with a web browser, but what if you are remote and logging in with a terminal over SSH? How to install in that case? What if you just want a quick recipe to do the job with the terminal?
I know I'm rather late to this question, but the accepted answer doesn't really reflect the common best practices from Python community members (and even less so from the Django community members.) While the outlined manual installation process does work, is is far more pains taking and error prone than the following:
You really should be using Pip. With Pip installing docutils system wide is as simple as:
$ sudo pip install docutils
This not only works for docutils but nearly any package on the 'Cheese Shop' as well as many other code repositories (Github, Bitbucket, etc.)
You may also want to look into other common Python best practice tools like virtualenv and virtualenvwrapper so that you can avoid global package installation.
To install Pip on Ubuntu/Debain I generally do the following:
$ sudo apt-get install python-pip
BTW: for virtualenv 'sudo apt-get install python-virtualenv' and for virtualenvwrapper 'sudo apt-get install virtualenvwrapper'.
The key to the install is to use the curl utility. The following will install docutils:
mkdir docutilsetup
cd docutilsetup
curl -o docutils-docutils.tar.gz http://docutils.svn.sourceforge.net/viewvc/docutils/trunk/docutils/?view=tar
gunzip docutils-docutils.tar.gz
tar -xf docutils-docutils.tar
cd docutils
sudo python setup.py install
This performs the following steps: Create a directory to download docutils into. cd into the directory just made, and use curl to download the zipped version of docutils. Unzip the file which creates a subdirectory docutils. cd into that directory and install with root permissions.
If you are using Django you will have to restart Django for admindocs to start working.
Although it is an old thread, I want to share the answer I found. To install type command
sudo apt install python-docutils
or
sudo apt install python3-docutils
This will install the dependencies too. Yesterday, I installed docutils using this command for Geany editor and it is working fine.