username<\/span>” with ‘root’ for the root user, or with the name of the admin account you plan to use.<\/p>\nOnce logged in, issue the following commands to update all installed packages to their latest available versions:<\/p>\n
sudo apt-get update\r\nsudo apt-get upgrade<\/pre>\nInstall the required packages using the following command:<\/p>\n
sudo apt-get install curl gcc g++ make \\\r\nimagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core \\\r\nlibprotobuf-dev protobuf-compiler pkg-config autoconf \\\r\nbison build-essential libssl-dev libyaml-dev libreadline-dev \\\r\nzlib1g-dev libncurses5-dev libffi-dev libgdbm-dev \\\r\nlibidn11-dev libicu-dev libjemalloc-dev<\/pre>\nThese packages cover all of the requirements for Mastodon, from media conversion, to streaming services.<\/p>\n
<\/span>Step 2: Install Node.js and Yarn<\/span><\/h2>\nWe will install Node.js and Yarn from their official repositories.<\/p>\n
Enable the NodeSource repository with the following curl command:<\/p>\n
curl -sL https:\/\/deb.nodesource.com\/setup_8.x | sudo bash -<\/pre>\nTo install Node.js 8.x LTS Carbon and npm, run this next command:<\/p>\n
sudo apt-get install nodejs<\/pre>\nImport the Yarn APT repository\u2019s GPG key and enable it by running:<\/p>\n
curl -sL https:\/\/dl.yarnpkg.com\/debian\/pubkey.gpg | sudo apt-key add -\r\necho \"deb https:\/\/dl.yarnpkg.com\/debian\/ stable main\" | sudo tee \/etc\/apt\/sources.list.d\/yarn.list\r\n<\/pre>\nInstall Yarn using the following command:<\/p>\n
sudo apt-get update && sudo apt-get install yarn<\/pre>\n<\/span>Step 3: Install PostgreSQL<\/span><\/h2>\nMastodon can use PostgreSQL as its database back-end.<\/p>\n
If the PostgreSQL server is not already installed on your server, you can install the latest PostgreSQL version by executing the following command:<\/p>\n
sudo apt-get install postgresql postgresql-contrib<\/pre>\nOnce the installation is complete, log in to the PostgreSQL shell:<\/p>\n
sudo -u postgres psql<\/pre>\nCreate a new user for the Mastodon instance:<\/p>\n
CREATE USER mastodon CREATEDB;<\/pre>\n<\/span>Step 4: Install Redis<\/span><\/h2>\nInstalling Redis is pretty straightforward, just run the following command:<\/p>\n
sudo apt-get install redis-server<\/pre>\n<\/span>Step 5: Create a New System User<\/span><\/h2>\nCreate a new system user that will run the Mastodon server:<\/p>\n
sudo adduser --home \/opt\/mastodon --disabled-login --gecos 'Mastodon Application' mastodon<\/pre>\n<\/span>Step 6: Install Ruby<\/span><\/h2>\nWe will install Ruby using the Rbenv script.<\/p>\n
Before cloning the rbenv repository, switch to the new mastodon user that we created in the previous step:<\/p>\n
sudo su - mastodon<\/pre>\nSet up ‘rbenv’ and ‘ruby-build’ with the following commands:<\/p>\n
cd\r\ngit clone https:\/\/github.com\/rbenv\/rbenv.git ~\/.rbenv\r\ncd ~\/.rbenv && src\/configure && make -C src\r\necho 'export PATH=\"$HOME\/.rbenv\/bin:$PATH\"' >> ~\/.bashrc\r\necho 'eval \"$(rbenv init -)\"' >> ~\/.bashrc\r\nexec bash\r\ngit clone https:\/\/github.com\/rbenv\/ruby-build.git ~\/.rbenv\/plugins\/ruby-build\r\n<\/pre>\nOnce both ‘rbenv’ and ‘ruby-build’ are set, install the latest Ruby version with:<\/p>\n
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.6.1\r\nrbenv global 2.6.1\r\n<\/pre>\nUpdate the gem and install bundler so that they work with the version of rbenv that we just installed.:<\/p>\n
gem update --system\r\ngem install bundler --no-document\r\n<\/pre>\nTo verify everything is done correctly, use the command ruby --version<\/code>.<\/p>\nThe output should be similar to the following:<\/p>\n
ruby --version\r\nruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]\r\n<\/pre>\n