How to set up a new (development) instance of Codidact/QPixel Question
3 answers
You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.
Disclaimer: I have no insight or familiarity with QPixel or any of the packages described below. These are just the variations that got me to a QPixel installation that was working well enough to display the Codidact homepage.
Installing QPixel on Fedora Linux using RVM without brew
If you happen to be installing in this situation, a few things might have different names. Here are some of the differences I had to allow for.
This may or may not be similar for Red Hat and CentOS installations.
ImageMagick
An error occurred while installing rmagick (4.2.6), and Bundler cannot continue.
Instead of the recommended libmagickwand-dev
, which is not available on Fedora, you can use ImageMagick-devel
:
dnf install ImageMagick-devel
I couldn't find an official guide to this but I stumbled upon the alternative name for the package in a guide to Python bindings for ImageMagick. That guide refers to yum
instead of dnf
as it's aimed at Red Hat, but it installed for me on Fedora using dnf
.
MySQL
An error occurred while installing mysql2 (0.5.4), and Bundler cannot continue.
Instead of the recommended mysql-server
, which is not available on Fedora, you can use the community maintained community-mysql-server
:
dnf install community-mysql-server
systemctl enable mysqld
systemctl start mysqld
I found I also needed to install mysql-devel
:
dnf install mysql-devel
The guide to installing MySQL on Fedora also includes instructions for installing Oracle's package instead of the community maintained one if you prefer.
libvips
libvips
is not available under that name on Fedora, instead it is called vips
:
dnf install vips
Redis
I discovered on the Redis Fedora page that redis-server
is not available under that name on Fedora, instead it is called redis
:
dnf install redis
systemctl enable redis
systemctl start redis
storage.yml
I also needed to manually copy config/storage.sample.yml
to config/storage.yml
. I didn't need to change anything, just mentioning that I needed to make the copy, as I couldn't find anything about this in the QPixel installation instructions.
Security
This is not a security guide. Please use your own judgement on whether each command does or does not need to be entered with something like sudo
or su
. I am not qualified to tell you what is safe for your particular system.
0 comment threads
The following users marked this post as Works for me:
User | Comment | Date |
---|---|---|
NoahTheDuke | (no comment) | Nov 15, 2021 at 03:08 |
Before you can get started, you need to check, whether you have all the prerequisites. QPixel is built with Ruby on Rails, therefore you'll need:
- a Linux or Mac computer (Windows WSL is also okay, but slower; running Ruby on Windows is ultra-slow)
- Ruby installed (we recommend RVM or rbenv)
Prerequisites
If you have all of that, we can continue with installing the necessary packages. For Linux, run these commands:
sudo apt update
sudo apt install gcc
sudo apt install make
sudo apt install libmysqlclient-dev libmagickwand-dev
sudo apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev
sudo apt install mysql-server
For Mac, run:
xcode-select --install
brew install mysql bison openssl mysql-client
bundle config --global build.mysql2 --with-opt-dir="$(brew --prefix openssl)"
Next, you need to install the following helper applications:
Installing QPixel
Once you have completed installing the prerequisites, you can download QPixel:
git clone https://github.com/codidact/qpixel
cd qpixel
After downloading QPixel, you need to install all the dependencies. For that, you need to run
bundle install
If Ruby complains, that the Bundler hasn't been installed yet, use gem install bundler
and then re-run the above command.
Setting up the Database
If the database is not already running, start it. On MacOS you can do:
brew services start mysql
Before we can create, set up and seed the database, we need to make sure that we have a MySQL user. Sign into the MySQL console (sudo mysql -u root
for the default installation) and execute the following commands (replace the dummy credentials with secure ones):
CREATE USER [email protected] IDENTIFIED BY 'choose_a_password_here';
GRANT ALL ON qpixel_dev.* TO [email protected];
GRANT ALL ON qpixel_test.* TO [email protected];
GRANT ALL ON qpixel.* TO [email protected];
Then you'll have to tell QPixel which credentials to use. Copy the config/database.sample.yml
to config/database.yml
and fill in the correct host, username and password. You'll also need to copy the Active Storage configuration from config/storage.sample.yml
to config/storage.yml
. Also, you will need to set the Redis connection details there too. Assuming that you always chose the default installation options, you'll only need to make changes to the username and the password from the sample file.
Now we want to create the database and the tables. Run:
rails db:create
rails db:schema:load
rails r db/scripts/create_tags_path_view.rb
rails db:migrate
Before we can continue and seed the data, you'll have to create the record for your (first) community. Open the Rails console with rails c
and run these two commands:
Community.create(name: 'Dev Community', host: 'localhost:3000')
Rails.cache.clear
After that you can call rails db:seed
to fill the database with necessary seed data, such as settings, help posts and default templates.
Now comes the big moment: You can start the QPixel server for the first time. Run:
rails s
Open a web browser and visit your server, which should be running under http://localhost:3000.
Creating an administrator account
On the dev server, create a new account through the "Sign up" route. Then switch back to the console to confirm your account (as sending mails shouldn't have been configured yet) and to promote your account to an administrator one. Open the rails console again and run:
User.last.update(confirmed_at: DateTime.now, is_global_admin: true)
If you prefer confirming accounts from the web, you can visit http://localhost:3000/letter_opener to access the confirmation email and then promote your user to admin with rails r "User.last.update(is_global_admin: true)"
.
Reload the web browser and you should see the elevated access.
New site setup
There's one more thing before your development server is fully up and running: the new site setup.
While being logged into your administrator account, go to http://localhost:3000/admin/setup. Review the settings (if you want; you can change them later) and click "Save and continue" to complete setting up the dev server.
✨ Your dev server is now ready.
I am adding some more information on prerequisites.
For Arch-Based Linux :
sudo pacman -Syyu
sudo pacman -Sy gcc
sudo pacman -Sy make
sudo pacman -Sy ruby autoconf bison base-devel ruby unixodbc
sudo pacman -Sy openssl
sudo snap install mysql --beta Or, sudo pacman -S mysql
For Windows :
You have to follow following method to get started.
- Install RubyInstaller.
-
You have run the following commands in command prompt(I forgot the name, simply called
cmd
)gem install rails
and,gem install bundler
- Download and install mysql.
1 comment thread