Difference between revisions of "2018/04/07"
(Created page with "Loosely following [https://anystack.xyz/how-to-install-mastodon-ubuntu/ these instructions]... I just do everything in root rather than using sudo, because that's how I roll....") |
|||
Line 1: | Line 1: | ||
+ | =Take 1= | ||
Loosely following [https://anystack.xyz/how-to-install-mastodon-ubuntu/ these instructions]... | Loosely following [https://anystack.xyz/how-to-install-mastodon-ubuntu/ these instructions]... | ||
Line 44: | Line 45: | ||
** <code>systemctl restart postgresql</code> | ** <code>systemctl restart postgresql</code> | ||
==Setting Up Ruby== | ==Setting Up Ruby== | ||
− | * <code>apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev</code> | + | * <code>apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev rbenv</code> |
+ | ** Note: the instructions omitted <code>rbenv</code>, but it seems to be needed. | ||
* <code>adduser --disabled-password --disabled-login mastodon</code> | * <code>adduser --disabled-password --disabled-login mastodon</code> | ||
** Just hitting ENTER in response to all questions, "Y" in response to "Y/n". | ** Just hitting ENTER in response to all questions, "Y" in response to "Y/n". | ||
− | * Change to user <code>mastodon</code>: | + | * Change to user <code>mastodon</code> (which also puts you in <code>/home/mastodon</code>): |
** <code>su - mastodon</code> | ** <code>su - mastodon</code> | ||
+ | * <code>git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build</code> | ||
+ | * install Ruby 2.4.1: | ||
+ | ** <code>rbenv install 2.4.1</code> | ||
− | + | That didn't work because rbenv was not installed. (Also not sure this is the best version of Ruby, anymore, but that seems fixable later now that we have the command). So I had to back out to root, <code>apt install rbenv</code>, and then <code>su - mastodon</code> again. | |
+ | |||
+ | * <code>rbenv install 2.4.1</code> | ||
+ | ** This takes a couple of minutes. | ||
+ | * <code>rbenv global 2.4.1</code> | ||
+ | ** This is instantaneous. | ||
+ | * <code>ruby -v</code> | ||
+ | ** response: <code>ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]</code> | ||
+ | *** ...um, okay. | ||
+ | ==Installing Mastodon== | ||
+ | * <code>cd ~</code> | ||
+ | ** This is probably redundant. | ||
+ | * <code>git clone https://github.com/tootsuite/mastodon.git live</code> | ||
+ | * <code>cd live</code> | ||
+ | * <code>git checkout $(git tag | tail -n 1)</code> | ||
+ | ** I don't know what this does. | ||
+ | * "Install bundler to manage the dependencies and disable the gem documentation." | ||
+ | ** <code>echo "gem: --no-document" > ~/.gemrc</code> | ||
+ | ** <code>gem install bundler --no-ri</code> | ||
+ | *** Response: | ||
+ | **** <code>Fetching: bundler-1.16.1.gem (100%)</code> | ||
+ | **** <code>ERROR: While executing gem ... (Gem::FilePermissionError)</code> | ||
+ | **** <code> You don't have write permissions for the /var/lib/gems/2.3.0 directory.</code> | ||
+ | |||
+ | Okay, '''Simon says'''... | ||
+ | * <code>exit</code> | ||
+ | * <code>gem install bundler --no-ri</code> | ||
+ | ** Response: | ||
+ | *** <code>Fetching: bundler-1.16.1.gem (100%)</code> | ||
+ | *** <code>Successfully installed bundler-1.16.1</code> | ||
+ | *** <code>1 gem installed</code> | ||
+ | * <code>su - mastodon</code> | ||
+ | * <code>cd live</code> | ||
+ | * <code>bundle install --deployment --without development test</code> | ||
+ | ** A bunch of stuff happened, and then this error message: | ||
+ | <pre> | ||
+ | Gem::Ext::BuildError: ERROR: Failed to build gem native extension. | ||
+ | |||
+ | current directory: /home/mastodon/live/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.2/ext/nokogiri | ||
+ | /usr/bin/ruby2.3 -r ./siteconf20180407-2653-idvqpi.rb extconf.rb | ||
+ | mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h | ||
+ | |||
+ | extconf failed, exit code 1 | ||
+ | |||
+ | Gem files will remain installed in /home/mastodon/live/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.2 for inspection. | ||
+ | Results logged to /home/mastodon/live/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.2/gem_make.out | ||
+ | |||
+ | An error occurred while installing nokogiri (1.8.2), and Bundler cannot continue. | ||
+ | Make sure that `gem install nokogiri -v '1.8.2'` succeeds before bundling. | ||
+ | |||
+ | In Gemfile: | ||
+ | rails-settings-cached was resolved to 0.6.6, which depends on | ||
+ | rails was resolved to 5.1.4, which depends on | ||
+ | actioncable was resolved to 5.1.4, which depends on | ||
+ | actionpack was resolved to 5.1.4, which depends on | ||
+ | actionview was resolved to 5.1.4, which depends on | ||
+ | rails-dom-testing was resolved to 2.0.3, which depends on | ||
+ | nokogiri | ||
+ | </pre> | ||
+ | Okay, trying that command... | ||
+ | * <code>gem install nokogiri -v '1.8.2'</code> | ||
+ | ** Response: | ||
+ | *** <code>Fetching: mini_portile2-2.3.0.gem (100%)</code> | ||
+ | *** <code>ERROR: While executing gem ... (Gem::FilePermissionError)</code> | ||
+ | *** <code> You don't have write permissions for the /var/lib/gems/2.3.0 directory.</code> | ||
+ | |||
+ | So again, Simon says... | ||
+ | * <code>exit</code> | ||
+ | * <code>gem install nokogiri -v '1.8.2'</code> | ||
+ | ** Response: | ||
+ | <pre>Fetching: mini_portile2-2.3.0.gem (100%) | ||
+ | Successfully installed mini_portile2-2.3.0 | ||
+ | Fetching: nokogiri-1.8.2.gem (100%) | ||
+ | Building native extensions. This could take a while... | ||
+ | ERROR: Error installing nokogiri: | ||
+ | ERROR: Failed to build gem native extension. | ||
+ | |||
+ | current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.8.2/ext/nokogiri | ||
+ | /usr/bin/ruby2.3 -r ./siteconf20180407-2736-1uhzyd6.rb extconf.rb | ||
+ | mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h | ||
+ | |||
+ | extconf failed, exit code 1 | ||
+ | |||
+ | Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.8.2 for inspection. | ||
+ | Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.2/gem_make.out | ||
+ | </pre> | ||
+ | |||
+ | Okay. Let's start over, and use the [https://github.com/staticsafe/mastodon-documentation/blob/master/Running-Mastodon/Production-Guide.md official instructions] this time, leaving off any bits that have already clearly been done. (I don't know why I didn't use them to begin with... I guess these alternate instructions just looked so distro-specific and friendly.) | ||
+ | =Take 2= | ||
+ | As root... | ||
+ | * <code>cd /root</code> | ||
+ | * <code>mkdir setup</code> | ||
+ | * <code>cd setup</code> | ||
+ | * <code>wget https://deb.nodesource.com/setup_6.x</code> | ||
+ | * ...and then "review the script" using <code>less</code> -- as if I'd know how to evaluate it. Glanced at it, what does it mean. Now running it... | ||
+ | * </code>bash setup_6.x</code> | ||
+ | ==Yarn Repository== | ||
+ | * <code>apt -y install curl</code> | ||
+ | ** was already installed, but might not have been if I hadn't tried the other instructions first | ||
+ | * <code>curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -</code> | ||
+ | * <code>echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list</code> | ||
+ | * <code>apt update</code> | ||
+ | * Install [[Yarn]] plus a bunch of other stuff: | ||
+ | ** <code>apt -y install imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev nginx redis-server redis-tools postgresql postgresql-contrib nginx letsencrypt yarn</code> | ||
+ | ==User-Specific Stuff== | ||
+ | * <code>su - mastodon</code> | ||
+ | * <code>git clone https://github.com/rbenv/rbenv.git ~/.rbenv</code> | ||
+ | ** This does not seem to have been done earlier, or at least not with the same command -- but there is a .rbenv folder. So can't do it again, unless we want to erase it. Maybe later, if something seems to be wrong with rbenv. | ||
+ | * <code>cd ~/.rbenv && src/configure && make -C src</code> | ||
+ | ** Response: <code>-su: src/configure: No such file or directory</code> | ||
+ | ** Okay, something seems to be wrong with rbenv. | ||
+ | * <code>cd ~</code> | ||
+ | * <code>rm -rdf .rbenv</code> | ||
+ | * <code>git clone https://github.com/rbenv/rbenv.git ~/.rbenv</code> | ||
+ | * <code>cd ~/.rbenv && src/configure && make -C src</code> | ||
+ | * <code>echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc</code> | ||
+ | * <code>echo 'eval "$(rbenv init -)"' >> ~/.bashrc</code> | ||
+ | * Restart the shell: | ||
+ | ** <code>exec bash</code> | ||
+ | * Check if rbenv is correctly installed: | ||
+ | ** <code>type rbenv</code> | ||
+ | *** Response:<pre> | ||
+ | rbenv is a function | ||
+ | rbenv () | ||
+ | { | ||
+ | local command; | ||
+ | command="${1:-}"; | ||
+ | if [ "$#" -gt 0 ]; then | ||
+ | shift; | ||
+ | fi; | ||
+ | case "$command" in | ||
+ | rehash | shell) | ||
+ | eval "$(rbenv "sh-$command" "$@")" | ||
+ | ;; | ||
+ | *) | ||
+ | command rbenv "$command" "$@" | ||
+ | ;; | ||
+ | esac | ||
+ | }</pre> | ||
+ | * Install ruby-build as rbenv plugin: | ||
+ | ** <code>git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build</code> | ||
+ | * <code>rbenv install 2.4.1</code> | ||
+ | ** This is probably redundant now, but why not. | ||
+ | ** It still takes a couple of minutes, though. | ||
+ | * <code>rbenv global 2.4.1</code> | ||
+ | ==Installing Mastodon== | ||
+ | Much of this has already been done -- but this instruction set does explain it a bit. Skipping redundant bits... | ||
+ | * Install bundler (again, but without the options): | ||
+ | ** <code>gem install bundler</code> | ||
+ | * Use bundler to install the rest of the Ruby dependencies (this might be redundant, but maybe not): | ||
+ | ** <code>bundle install --deployment --without development test</code> | ||
+ | *** Response: <code>Could not locate Gemfile</code> | ||
+ | |||
+ | I have to stop for tonight. |
Revision as of 00:52, 8 April 2018
Take 1
Loosely following these instructions...
I just do everything in root rather than using sudo, because that's how I roll.
Things done:
- Create droplet (4GB- 2CPU - 80GB - $20, Ubuntu 16.04, SFO2, IPv6, Gonzo key)
apt update
apt upgrade
- install node.js:
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
apt install imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev nodejs
npm install -g yarn
- install redis-server:
apt install redis-server redis-tools
- install PostgreSQL (Pg):
apt install postgresql postgresql-contrib
- switch to postgres user, create Mastodon user in Pg:
su - postgres
psql
CREATE USER mastodon CREATEDB;
\q
Now, we're trying to enable ident auth in Pg so users can log in without a password.
- I don't understand why we want to do this; seems like bad security.
- I tried to do this bit exactly as written, because it looked like it might be user-sensitive, but it didn't work (see below).
- Can this be done as all one line?
sudo sed -i '/^local.*postgres.*peer$/a host all all 127.0.0.1/32 ident' \
/etc/postgresql/9.?/main/pg_hba.conf
That didn't work, because after the second line it asked for a password for postgres, which I don't have, and wouldn't accept a blank. So, backing out and trying as root (and all one line):
sed -i '/^local.*postgres.*peer$/a host all all 127.0.0.1/32 ident' /etc/postgresql/9.?/main/pg_hba.conf
No error, but also no success message. I will assume successful.
- install ident daemon:
apt install pidentd
systemctl enable pidentd
- Response:
pidentd.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable pidentd
systemctl start pidentd
systemctl restart postgresql
Setting Up Ruby
apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev rbenv
- Note: the instructions omitted
rbenv
, but it seems to be needed.
- Note: the instructions omitted
adduser --disabled-password --disabled-login mastodon
- Just hitting ENTER in response to all questions, "Y" in response to "Y/n".
- Change to user
mastodon
(which also puts you in/home/mastodon
):su - mastodon
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
- install Ruby 2.4.1:
rbenv install 2.4.1
That didn't work because rbenv was not installed. (Also not sure this is the best version of Ruby, anymore, but that seems fixable later now that we have the command). So I had to back out to root, apt install rbenv
, and then su - mastodon
again.
rbenv install 2.4.1
- This takes a couple of minutes.
rbenv global 2.4.1
- This is instantaneous.
ruby -v
- response:
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
- ...um, okay.
- response:
Installing Mastodon
cd ~
- This is probably redundant.
git clone https://github.com/tootsuite/mastodon.git live
cd live
git checkout $(git tag | tail -n 1)
- I don't know what this does.
- "Install bundler to manage the dependencies and disable the gem documentation."
echo "gem: --no-document" > ~/.gemrc
gem install bundler --no-ri
- Response:
Fetching: bundler-1.16.1.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.3.0 directory.
- Response:
Okay, Simon says...
exit
gem install bundler --no-ri
- Response:
Fetching: bundler-1.16.1.gem (100%)
Successfully installed bundler-1.16.1
1 gem installed
- Response:
su - mastodon
cd live
bundle install --deployment --without development test
- A bunch of stuff happened, and then this error message:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /home/mastodon/live/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.2/ext/nokogiri /usr/bin/ruby2.3 -r ./siteconf20180407-2653-idvqpi.rb extconf.rb mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h extconf failed, exit code 1 Gem files will remain installed in /home/mastodon/live/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.2 for inspection. Results logged to /home/mastodon/live/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.2/gem_make.out An error occurred while installing nokogiri (1.8.2), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.8.2'` succeeds before bundling. In Gemfile: rails-settings-cached was resolved to 0.6.6, which depends on rails was resolved to 5.1.4, which depends on actioncable was resolved to 5.1.4, which depends on actionpack was resolved to 5.1.4, which depends on actionview was resolved to 5.1.4, which depends on rails-dom-testing was resolved to 2.0.3, which depends on nokogiri
Okay, trying that command...
gem install nokogiri -v '1.8.2'
- Response:
Fetching: mini_portile2-2.3.0.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.3.0 directory.
- Response:
So again, Simon says...
exit
gem install nokogiri -v '1.8.2'
- Response:
Fetching: mini_portile2-2.3.0.gem (100%) Successfully installed mini_portile2-2.3.0 Fetching: nokogiri-1.8.2.gem (100%) Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.8.2/ext/nokogiri /usr/bin/ruby2.3 -r ./siteconf20180407-2736-1uhzyd6.rb extconf.rb mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h extconf failed, exit code 1 Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.8.2 for inspection. Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.2/gem_make.out
Okay. Let's start over, and use the official instructions this time, leaving off any bits that have already clearly been done. (I don't know why I didn't use them to begin with... I guess these alternate instructions just looked so distro-specific and friendly.)
Take 2
As root...
cd /root
mkdir setup
cd setup
wget https://deb.nodesource.com/setup_6.x
- ...and then "review the script" using
less
-- as if I'd know how to evaluate it. Glanced at it, what does it mean. Now running it... - bash setup_6.x
Yarn Repository
apt -y install curl
- was already installed, but might not have been if I hadn't tried the other instructions first
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt update
- Install Yarn plus a bunch of other stuff:
apt -y install imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev nginx redis-server redis-tools postgresql postgresql-contrib nginx letsencrypt yarn
User-Specific Stuff
su - mastodon
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
- This does not seem to have been done earlier, or at least not with the same command -- but there is a .rbenv folder. So can't do it again, unless we want to erase it. Maybe later, if something seems to be wrong with rbenv.
cd ~/.rbenv && src/configure && make -C src
- Response:
-su: src/configure: No such file or directory
- Okay, something seems to be wrong with rbenv.
- Response:
cd ~
rm -rdf .rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
- Restart the shell:
exec bash
- Check if rbenv is correctly installed:
type rbenv
- Response:
rbenv is a function rbenv () {
local command; command="${1:-}"; if [ "$#" -gt 0 ]; then shift; fi; case "$command" in rehash | shell) eval "$(rbenv "sh-$command" "$@")" ;; *) command rbenv "$command" "$@" ;; esac
}
- Install ruby-build as rbenv plugin:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install 2.4.1
- This is probably redundant now, but why not.
- It still takes a couple of minutes, though.
rbenv global 2.4.1
Installing Mastodon
Much of this has already been done -- but this instruction set does explain it a bit. Skipping redundant bits...
- Install bundler (again, but without the options):
gem install bundler
- Use bundler to install the rest of the Ruby dependencies (this might be redundant, but maybe not):
bundle install --deployment --without development test
- Response:
Could not locate Gemfile
- Response:
I have to stop for tonight.