Kirby development on Linux

Hey everybody :slight_smile:
I recently got a cheap new laptop, because I wanted to try out Elementary OS. I usually develop on Mac OS and have never used Linux before. I think I saw Elementary OS being used at least in one screenshot in the forum, so I wanted to ask all the Linux people to share some workflow tips. Specifically, I am looking for something like Laravel Valet to make new sites work with no prior setup, but also more general inspiration or tips for a Linux newcomer are very welcome :~)
x

I use https://github.com/cpriego/valet-linux and it works like a charm.

2 Likes

ah nice! i saw this but am a bit unsure how to install things on this OS. do i just clone the repo and run it from there?
edit: ah I see, there’s documentation here https://cpriego.github.io/valet-linux/

1 Like

Krita and Gravit are useful for graphics stuff, and Gravit is reasonable equivalent to Sketch.

Both are free (Gravit is free to a point)

https://krita.org/en/

I liked Elementory OS alot, and wanted to stick with it but hit the odd road block with the Software Center. Ended up switiching to Solus Linux which is really developer freindly and looks great too!

https://getsol.us/home/

3 Likes

@sebastiangreger I’ve spent the better part of the last couple of hours trying to get valet-linux to work, but even after following the steps mentioned here https://github.com/cpriego/valet-linux/issues/35 i still get the output valet: command not found.
I also reinstalled composer three times (following their official docs, via apt, and following a manual tutorial on digitalocean) - nothing seems to work.
Did the tool work for you out of the box or did you have to change anything? I really don’t know what else to do except ask someone with personal experience :confused:
@jimbobrjames - thank you for your recommendations! i’ll be sure to check them out. Solus was one of the distros I thought about installing as well. What do you mean about the Software Center road block?

Elementary OS has a closed software respitory that the os makers maintain and curate. That means you have to wait for them to add it before you can easily download and install it. Its not always the most recent version available. You can get around this if you know what your doing but depending on what the software is, this can be tricky (you may have to build from source code, which requires a bunch of stuff and nerves of steel). Solus is less restrictive and updated more quickly. You can also use Snap in addition to he built in Software Center.

okay, I’ve read about this, but also heard that the software center starts listing external software once you’ve downloaded your first third-party-software. Maybe this was referring to something else though. I also found tools on the software center which allow for easy installation and management of .deb files, and am already using snap for some tools :slight_smile: thanks for your recommendation again!

I guess theyve added Snap since i left it then. It wasnt there when i switched to Solus.

@bruno If you cant get the Linux port of Valet working, I used to use Laraval Homestead on LInux just fine. It does need Virtual Box and Vagrant, but its pretty good. I bought the Pro version of Scotchbox too, which is very good.

I am on Linux Mint Cinnamon with apache.

There are some packages that do the stack installation for you (php, apache, mysql if you need it…), I usually don’t have any problems with this, but last time I did everything ‘manually’ and hit one or two roadblocks.

I configured Apache to serve files from ~/public_html which is very convenient to deal with file permissions.

On that subject I tend to recursively add the apache user ‘www-data’ as group owner to the kirby installation folder, and then to give this group read write and execute (g+rwX) permissions also recursively. I sometimes have to repeat this step, particularly if I manually add files to content folder or other folders where Kirby needs writing permissions.

Then I have a personal kirby kit based on the plainkit. In the kit I basically re-use html-pre and post snippets, and the assets folder structure. I also have a gulp installation compile sass and minify it, and minify js. Gulp means installing node and npm of course.

So I just duplicate and rename the kit folder, git init, add a remote and start coding.

For the remote I usually use a --bare repo, with a post-receive hook that deploys the site using checkout -f

And that is my setup/workflow. Let me know if there is anything I may help you with.

Good luck!

1 Like

@bruno, sorry to hear you ran into complications. It’s been a few months since I set it up, but I cannot remember any issues - the ease of getting it to run, along with the comfort of Valet, is the main reason I like this lean solution so much.

My system runs on Linux Mint 19.3 Cinnamon (Nginx). I had long planned to turn my notes into a blog post, so I took the opportunity to do just that: https://sebastiangreger.net/2020/04/kirby-local-dev-environment-linux

Based on the error message you got, it sounds like setting up the PATH variable might be where you are stuck - does the command echo $PATH in your terminal output a PATH variable that includes the location of your Composer instance?

Btw: in my original setup, I created separate subfolders with a complete Kirby instance for every website. I haven’t yet had the time to change that, but check out the cookbook recipe https://getkirby.com/docs/cookbook/setup/multisite-variant for a comfortable way of setting up multiple Kirby sites on one server - this would be my choice for a fresh setup today, as it makes it even more elegant.

3 Likes

Yes, was going to do that as well but haven’t got round to it yet. Makes it so much easier to swap Kirby versions…

it was clearly a problem with the PATH variable but I just couldn’t make sense of it. I moved files around and changed $PATH around 50 times - now it’s FINALLY working but I have no clue why and how. Your tutorial looks like it could have worked but I saw it too late. Anyways I’m happy I will be able to work with Valet :sunglasses:

re: multisite setup. I don’t understand how I would work with a multisite setup in terms of hosting the sites. I ususally have separate kirby installs (usually as git submodules or composer) that i push to production servers. How would I upload my different sites to my clients’ servers without having to manually install kirby and changing index and roots? Do you (and @texnixe) run your own server? What’s the production workflow here? :confused:

the git setup sounds very nice. I’ve started working on a personal kirby kit but it’s not quite done yet. Maybe I will work on this! What are some things you include in every project? Do you have a public repo that you’d care to share? :upside_down_face: I haven’t really been using compile/build tools so far but i’ll make sure to check that out. Do you run a gulp build script on the remote in the post-receive hook?

I don’t have a public repo, sorry, but I’ll try to find time to build one on github and share it here.

Things included in my personal kirby kit are:

  • kirby folder (updated)
  • .htaccess + index.php (taken from plainkit)
  • a basic content folder with site, home and error
  • gulpfile.js (to build and minify js and css)
  • package-lock.json & node_modules/ folder (used by gulp)
  • custom .gitignore (I don’t track content or Sublime Text project file)
  • .editorconfig (to homogenize things like indent style when collaborating)
  • html-pre.yml and html-post.yml snippets with all the html basics, css and js builds load, things like Open Graph and Twitter card, google schema, etc.

I also include the assets folder structure:

css
  build
  vendor
  main.sass
js
  build
  vendor
  main.js

In the gulpfile.js I have buildJS and buildCSS tasks that take files from js/ and css/ and concatenates them with those in vendor/ subfolders, minifies them and outputs them as build.css/.js on the build folder. For example:

gulp.task('buildCSS', function () {

  var vendor = gulp.src('assets/css/vendor/*.css')
    .pipe(postcss([cssnano]));

  var app = gulp.src('assets/css/*.sass')
    .pipe(sass())
    .pipe(postcss([autoprefixer, cssnano]));

  return merge(vendor, app)
    .pipe(concat('build.css'))
    .pipe(gulp.dest('assets/css/build/'));

});

I use a gulp plugin on SublimeText3, so that buildCSS runs when I save a .sass file, and buildJS when I save a .js file.

And I think that is mostly it!

2 Likes

wow, thanks for the extensive intro! very inspiring, i’m sure this will influence my own starter kit.

1 Like

I’ve ran Debian Stable, minimal netinstall for a couple of years now. Manage PHP versions with apt, use Symfony Server for my local development server. Git, composer, npm, etc… all from the CLI. Develop in PHPStorm, which runs well on Linux. Firefox Dev/Chromium to test and i3 as window manager. I like it :slight_smile:

2 Likes

@bruno heres my set up if its helpful… Laraval Mix + NPM Script + rSync Deploys + SEO + Composer updates… it’s plainkit++

1 Like

If you have full control over your box, you can make your live easier by adding the webserver’s user to the primary group of your user and changing the default umask to 002 (from 022).

thanks for your answer! i3 looks really helpful, i’ll give it a try.

re: using apt for updating php. i ran into some errors when trying to require a kirby plugin with composer.
my bash history looks like this:

  273  composer require sylvainjule/pagetable
-> here i realized that my php version is outdated, 
-> preventing the plugin from being installed.
-> i spent 20 minutes looking around for a command like "php update"
-> but all steps below were necessary:
  276  sudo apt install software-properties-common
  277  sudo add-apt-repository ppa:ondrej/php
  282  sudo apt-get install php7.4-gd
  284  sudo apt-get install php7.4-intl
  285  sudo apt-get install php7.4-xsl
  286  composer require sylvainjule/pagetable
-> finally worked

all this didn’t seem too simple. is this the correct way to update the php version with apt or did i miss something?