Flarum Management

Repo : https://github.com/kulga/flarummanagement

In command line instructions. Should be run by normal user with sudo privileges

wget 'https://raw.githubusercontent.com/kulga/flarummanagement/master/flarum_management' -O flarum_management
chmod u+x flarum_management

Welcome to my 2nd version of a install script for flarum.
Some features

  • Setup of LEMP stack
  • Ability to install multiple instances of flarum
    • Supports a ip address or domain names
  • Configure flarum with ssl (or not)
    • You may only gain ssl certification with domain names
  • Decreased dependence of versions of operating system.
  • Ability to remove existing installs and perform cleanup of both ssl and the database
  • Ability to reconfigure a existing flarum install with ssl or to remove ssl.
  • Auto-renewal of ssl certificates when close to expiry
  • Works on new 1024MB droplet

Additionally, the script has been split into functions, making it easier to support alternative distros.

Additional notes:

  • Tested and working on Ubuntu 16.04 and 16.10 17.10, 18.10
  • It uses php7.*
  • Some parts of ssl will take awhile on its first run

Usage examples:

### Invoke help message
./flarum_management
./flarum_management -h
# Install Flarum site mysite.domain.tld; 
# install myextrasite.domain.tld as well (second command)
./flarum_management -f mysite.domain.tld
./flarum_management -f mysite.domain.tld -f myextrasite.domain.tld
# Install flarum site with ssl configured. 
# On a existing install, it reconfigures the flarum site with ssl support.

./flarum_management -sf mysite.domain.tld
# Install LEMP stack; install flarum site with ssl configured as well
./flarum_management -i
./flarum_management -isf mysite.domain.tld
# Remove flarum site; remove ssl certificate for domain as well
./flarum_management -r mysite.domain.tld
./flarum_management -sr mysite.domain.tld
# Install LEMP stack, remove flarum site and its domain certificate and install new flarum
# site with ssl configured.
./flarum_management -isr mysite.domain.tld -f myextrasite.domain.tld

    Ahh, I've been waiting for this updated script!
    Gonna make it so much easier to move my website to another VPS.

    23 days later

    Backups!

    flarum_management now supports backing and restoral of your site.

    I have mostly tested this throughly -

    ... on a Ubuntu 16.04 vanilla install but please backup everything before trusting it fully (oh the irony)
    And if it happens to go haywire, create a issue or report it here ?

    Usage:

    # Backup mysite.domain.tld
    ./flarum_management -b mysite.domain.tld
    # Restore mysite.domain.tld
    ./flarum_management -a mysite.domain.tld

    But this isn't just exporting to a tarball ?
    The backups are incremental. This means that if you keep running the backup, you only use up a small bit of extra space. Did I mention you can run the backup repeatedly and it will create a new backup each time?
    The backups are site specific and dated. If you run more then once in a day, it adds up from 1 (date_n)

    $ for i in *; do du -hs $i; done
    44M    2017-04-07
    44M    2017-04-07_1
    44M    2017-04-07_10
    44M    2017-04-07_11
    44M    2017-04-07_12
    44M    2017-04-07_13
    44M    2017-04-07_14
    44M    2017-04-07_2
    44M    2017-04-07_3
    44M    2017-04-07_4
    44M    2017-04-07_5
    44M    2017-04-07_6
    44M    2017-04-07_7
    44M    2017-04-07_8
    44M    2017-04-07_9
    44M    source
    $ du -hs ./
    128M    ./

    Restoral is automatic. It will restore from your most recent backup. If you want a backup prior to that, you must either do it manually or touch another directory (eg touch 2017-04-07_14) and then run the restore.
    Backups older then 14 days are deleted.

    real nice, hope theres for centos.

      mgilang I've put in some time for working on centos. However, I never managed to get that working so it's on the backburner for now. I should put what I've done on a branch though if you're interested

      I'd love to integrate this with my Developer Tools extension somehow, especially with site and DB backups ?

      mgilang real nice, hope theres for centos.

      @Kulga I should put what I've done on a branch though if you're interested

      Ok! Hopefully I did that correctly, there should now be a centos branch with what I have done. Feel free to experiment. It's not working all the way though (from what I last touched that part of it)

        18 days later

        When I go to my site it says 403? This is after running the script

          TorchPE more detail is needed, what OS are you running?

          You're replying to my post about a centos branch which I've explicity mentioned is not functional.
          For this script right now, you need should run on a 1024MB Ubuntu droplet (AKA the $10 droplet)
          After testing, you may also run it on the $5 one (512MB droplet) on Ubuntu

          EDIT:

          I've now just tested it and it is indeed running successfully on a 1024MB Ubuntu 16.04 droplet with these commands

          wget 'https://raw.githubusercontent.com/kulga/flarummanagement/master/flarum_management' -O flarum_management
          chmod u+x flarum_management
          ./flarum_management -if ipaddrofserver # Eg 345.3464.234 or domain.tld

          EDIT(2):
          It also seems to work on a 512MB droplet!

            TorchPE It tells you this at the end of the script.
            It will look something like below. The password is always different. The username and database are partially taken from your domain or ip address and partially hashed (to reduce the odds that very similar domains crash in naming)

            #############################
            
            Database Credentials Generated!
            Copy the below credentials to your website at
            138.197.200.40
            
            Flarum database -> flrm_138.197.abb
            Flarum username -> flrm_138.197.abb
            Flarum database password -> eith5ohMuL1Sahthahpi
            
            Ensure you have completed the web install PRIOR to hitting enter
            if you are installing flarum more then once
            
            #############################

            If this was unclear, is there anyway I should to make the above information more prevalent when running this script?

              Note that the details will be there, I was just skipping through everything and didn't think that they would be there

                Kulga Also, can I make my own db and user? Will it still work?

                  TorchPE Note that the details will be there, I was just skipping through everything and didn't think that they would be there

                  Hmm. The issue is credentials are not always going to be generated as it can do other things (like enable ssl or install the software needed like nginx).
                  However, I can put it on this page.

                  TorchPE Also, can I make my own db and user? Will it still work?

                  yes, the script creates a empty database. You may use any that you like. But if you do, you will also need to manually remove them once done, and backups (once I get them working) won't use the manual one.
                  So yes, but responsibility of managing it is yours if you choose that path. You may also install phpmyadmin to make that easier (which this script does not do)

                  a month later

                  @Kulga The only thing I really had to do manually was to install php-zip on my own and it installed these for me as well:

                  libzip4 php7.0-cli php7.0-common php7.0-curl php7.0-fpm php7.0-gd php7.0-json php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-readline
                  php7.0-xml php7.0-zip

                  It's just easier to run this script than to do everything manually ?

                  2 months later

                  I want to install Flarum and ssl only using this script ( I already have a LAMP stack installed manually) but I have an error -

                  chown: invalid group: ‘chope:php_flarum’

                  How do you go about this? Will manually creating and adding the $user to the user group solve this?

                    Chope

                    In the script look at this line

                    unprivileged_php_user="php_flarum"

                    Change this to the unprivileged php user you are actually using. It might be www-data
                    However, it expects a LEMP stack (Nginx not Apache) so when it enables ssl it'll be writing to a nginx file.

                    Yeah, it's LEMP stack not LAMP. Sorry for the mix up.
                    As per the edits, will sudo nano do it?

                    'php_flarum', is it a user or group?
                    Thought the user is always the one I am logged with which the user variable $user represents.