This guide shows how I was able to setup discourse and import 10.000+ users and 38.000+ posts from kunena.
I was running an outdated Joomla! 2.5.28 version with kunena 3.0.8 on top and it was hacked. Therefore I was looking for a new solution for my site. I knew discourse from another forum I use as a visitor, not as an owner. For me, without other skills than basic SSH and unix skills, I found it very hard to install and import. I’m a medical doctor, a GP, not a programmer… I have spent a week of my spare time of trial and error as I knew nothing about docker at all. I still don’t, but it seems like my board is running now !
First I did setup a new server at vultr.com I chose the 5dollars 1 cpu, 1gb memory, 25gb ssd solution. I did choose Ubuntu 17.10 x64 (64 bit OS) as the OS
I made a local SSH key and added it to the server during the setup.
Then I connected to my new server
First I did get the latest Ubuntu updates for the version
sudo apt-get update sudo apt-get upgrade
Then I installed docker
I did use this guide to install docker: discourse/INSTALL-cloud.md at master · discourse/discourse · GitHub
wget -qO- https://get.docker.com/ | sh
Then the install of discourse
sudo -s mkdir /var/discourse git clone https://github.com/discourse/discourse_docker.git /var/discourse cd /var/discourse
And then run the setup. I use elasticemail as a smtp host.
In Admin >> Settings change the following
- download remote images to local → enable
- download remote images max days old → 10000
- slug_generation_method → ascii
- disable edit notifications → enable
After I have finished my setup via the email activation I got my vanilla board up running. It was time for a reboot
Now the database fun
Entering the docker container called app. And that was a step I missed in the beginning. You have to enter the container to see the import scripts, oooh. Newbie I am.
cd /var/discourse ./launcher enter app
First it have to be up to date
sudo apt-get update sudo apt-get upgrade
Let us install the software needed in the container
sudo apt-get install mariadb-server libmysqlclient-dev nano
Test if mysql is available
If you get this error
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2 “No such file or directory”)
Run this tutorial. After this is done try the mysql command again. If it works you are ready for the next step.
sudo gem install mysql2 echo "gem 'mysql2', require: false" >> /var/www/discourse/Gemfile cd /var/www/discourse su discourse -c 'bundle install --no-deployment --without test --without development'
And you get a error like this:_ sudo: no tty present and no askpass program specified_
Connect to the database
mysql -u root -p CREATE USER 'kunena'@'localhost' IDENTIFIED BY 'kunena'; CREATE DATABASE kunena; GRANT ALL PRIVILEGES ON kunena . * TO 'kunena'@'localhost'; FLUSH PRIVILEGES; Exit
To ensure that the database is created login to the database with the new user: kunena and password kunena:
mysql -u kunena -pkunena
If you want to show the table status
show table status from kunena;
If you want to see the databases the user kunena got access to
Import the old Joomla/kunena database
First I did clean up my old forum. I did ensure I only had a 1 level structure (so NO subforms).
Forum 1 Forum 2 ….
I had to rename the tabels prefix to “jos_” even then the script let you edit the prefix - but I was getting some error.
I did export using phpmyadmin and did exported kunena and standart Joomla tables only.
Upload file to server
Upload your file to root in your server using the password you find in the vult server manager and port 22
Restart your shell to connect to your servers root and not being inside your docker app.
To be able to to see the file in the app directory you have to copy the file inside the app dir.
docker cp databasefilename.sql app:/var/www/discourse/databasename.sql
Start the app container
cd /var/discourse ./launcher enter app ls -ls
Do you see the file on the list of files? I hope so!
Import the sql file into the new database
First you have to set the right owner of the file
chown discourse:discourse databasename.sql
Now import the sql file to the kunena database using the kunena user and password
mysql -ukunena -pkunena kunena < databasename.sql
Let us ensure the database isn’t empty. If you see rows it worked
mysql -u kunena -pkunena show table status from kunena; exit
Edit the import script
We need nano to be able to edit files. If you didn’t install nano earlier, do it now
sudo apt-get install nano
Now we can edit the import script file
sudo nano script/import_scripts/kunena3.rb
export DB_HOST="localhost" export DB_NAME="kunena" export DB_USER="kunena" export DB_PW="kunena" export KUNENA_PREFIX=“jos_” # "iff_" sometimes export IMAGE_PREFIX="http://URL/media/kunena/attachments" export PARENT_FIELD="parent_id"
Go to your old server and chmod 777 the “media/kunena/attachments” folder.
Back in your vultr server. And inside the app container we need the screen script to be installed before we run the import script. In my case it took 5 hours to run.
sudo apt-get install screen
Brew some coffee and then In the screen window
su discourse -c 'RAILS_ENV=production ruby script/import_scripts/kunena3.rb'
Then the show begins…
loading existing groups... loading existing users... loading existing categories... loading existing posts... loading existing topics... fetching Joomla users data from mysql fetching Kunena user data from mysql creating users 8 / 8 (100.0%) %) creating topics and posts 38888 / 38888 (100.0%) [196 items/min] updating bumped_at on topics updating last posted at on users updating last seen at on users Updating topic reply counts... 10625 / 10623 (100.0%) [8242 items/min] .Updating first_post_created_at... Updating user post_count... Updating user topic_count... updating featured topic users 15723 / 15723 (100.0%) updating featured topics in categories 12 / 12 (100.0%) updating user topic reply counts 10623 / 10623 (100.0%) resetting topic counters 15723 / 15723 (100.0%) Done (04h 27min 25sec)
When it is done you can remove the packages we don’t want to use… I hope this little guide will save you time!