Yep, it’s Tech Monday on a Wednesday again…
Okay, so I’m lumbered with these Fisher Price “My First Server” things. They run Linux (Yay!) but a strangely butchered and hobbled version (Boo!) and as I need them to run Drupal, I need to get some things working properly. And, of course, they don’t have APT or RPM on there, that would be too easy. And by “things”, I mean Drush – essential for command line maintenance of all your Drupal sites.
Apologies for the technical nature of this post, I didn’t have time to paint it or build it to scale.
First thing needed is php7. Synology has a package for php7, so that’s not a big problem. It’s currently stuck at 7.0 but I expect we’ll see 7.1 and 2 soon (for a certain definition of “soon”, it took them long enough to get MariaDB 10 on there). Install that package and you’re good to go forward. Once the package is installed, nip into the configuration website and enable ALL THE EXTENSIONS EVER.
Drush itself. First off, I had to create my own home directory as somewhere to put things that stay vaguely safe between DSM updates. Weirdly, my Synology boxes didn’t create home directories for users (you know, the way normal operating systems do), so there were chunks of things always throwing errors. Do this for your username…
sudo mkdir /volume1/homes/<username>
Sorted. Golden. Etc. You’ll probably need your root password to do this, then you’ll need to chown it to your user before you can use it properly…
cd into that directory, head over to http://docs.drush.org/en/8.x/install/ and grab the latest 8 release from GitHub. At time of writing, it’s 8.1.16
Okay. This is where it gets technical. More technical, sort of.
Sure, you could just run
php70 ~/drush.phar pm-update
But (a) it’s tedious to type that in all the time and (b) it’ll fail because pm-update calls php pm-updatestatus and that’ll fail because php is not the same as php70 and doesn’t have all the extensions installed.
So we need to perform some surgery in /bin.
Step 1. Get /bin/php to point to the *right* php.
sudo su <password> cd /bin mv php php56 which php70 (assuming /usr/local/bin/php70, if not then substitute appropriately) ln -s /usr/local/bin/php70 php exit php --version
Now when you run php –version you’ll see a lovely, shiny, 7.0 there instead of the dull, old, tedious 5.6.
Step 2, get Drush in place.
sudo su cd /bin cp /volume1/homes/<username>/drush.phar drush chmod a+x drush exit
Now you can run drush from anywhere on the server, without having to specify a version of php or a location for the drush.phar file. Ain’t that a treat!
And if you’re being clever, you’ll see that you could have both drush 8 and 9 installed at the same time – just have different filenames in /bin – you could have “Doctor” running drush 8 and “Master” running 9. Jeeves and Wooster. Armstrong and Miller. Bonnie and Clyde. Any pairing you like, really. Or you could be boring and have “drush8” and “drush9”. Up to you, really.
Word of warning 1 – If you do this to /bin/php it will alter your default command line php for everything. Shouldn’t be a problem, in fact it will probably make life easier. But worth bearing in mind if you suddenly start getting weirdness with scripts you’re triggering through cron jobs (and don’t get me started on Synology’s implementation of cron, that makes no sense).
Word of warning 2 – There will come a day when, totally unexpectedly, you’ll type “drush” and your Synology box will reply with “What the f*ck is drush?” Or the Linux equivalent, usually a bit more polite – imagine Jeeves stepping smartly yet unobtrusively forward, coughing politely, whispering “I’m terribly sorry, sir, but I can’t find that command”, then stepping back into the butler’s pantry. This means your Synology box has updated the Disk Station Manager software and reset ALL of your configuration tweaks. Go back into php.ini and reset that max_upload_size from 32M again. Fix those timeout values. And redo steps 1 and 2, above, assuming you’re lucky enough to still have a home directory with drush.phar in it.
If this has helped you, good. And I hope you find a way to get to a real server sooner rather than later!
2 responses to “Synology and Drush 8.1.16 – Finally Working”
Thanks for this quick share! I know enough to glean a slight understanding, unfortunately not enough for anything actionable! I was searching for a solution to get my drupal install updated though synology and your blog showed up in the results but with “drush”. I’ve never heard of that so I got curious!
Thanks for sharing.
This is really fabulous. Thanks so much. I almost have it working. But I get the “needs a higher bootstrap level” error no matter what directory I run “drush ups” from.
Following is the output of “drush status”. Does the drush version have to match the drupal version? I’m also suspicious of the URI value.
Drupal version : 7.63
Site URI : http://default
Database driver : mysql
Database username : xxxxxx
Database name : xxxxxx
PHP configuration : /usr/local/etc/php72/cli/php.ini
PHP OS : Linux
Drush script : /usr/bin/drush
Drush version : 8.1.18
Drush temp directory : /tmp
Drush configuration :
Drush alias files :
Drupal root : /volume1/web/drupal
Drupal Settings File : sites/default/settings.php
Site path : sites/default
Any advice would be appreciated.
Thanks,
Barton