Guest User

Untitled

a guest
Jan 15th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.64 KB | None | 0 0
  1. apt -y install tmux
  2. apt -y install curl
  3. curl -sL https://deb.nodesource.com/setup_6.x | bash -
  4. curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
  5. echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
  6. apt update
  7. apt -y install imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core 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 letsencrypt yarn libidn11-dev libicu-dev
  8. adduser mastodon
  9. sudo su - mastodon
  10. git clone https://github.com/rbenv/rbenv.git ~/.rbenv
  11. cd ~/.rbenv && src/configure && make -C src
  12. echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
  13. echo 'eval "$(rbenv init -)"' >> ~/.bashrc
  14. exec bash
  15. type rbenv
  16. git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
  17. rbenv install 2.4.2
  18. rbenv global 2.4.2
  19. cd ~
  20. git clone https://github.com/tootsuite/mastodon.git live
  21. cd ~/live
  22. git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
  23. gem install bundler
  24. bundle install --deployment --without development test
  25. yarn install --pure-lockfile
  26. su
  27. sudo -u postgres psql
  28. CREATE USER mastodon CREATEDB;
  29. \q
  30. cd /etc/nginx/sites-available
  31. vi /etc/nginx/sites-available/kemoshi.co.conf
  32.  
  33. ----
  34.  
  35. map $http_upgrade $connection_upgrade {
  36. default upgrade;
  37. '' close;
  38. }
  39.  
  40. server {
  41. listen 80;
  42. listen [::]:80;
  43. server_name kemoshi.co;
  44. root /home/mastodon/live/public;
  45. # Useful for Let's Encrypt
  46. location /.well-known/acme-challenge/ { allow all; }
  47. location / { return 301 https://$host$request_uri; }
  48. }
  49.  
  50. server {
  51. listen 443 ssl http2;
  52. listen [::]:443 ssl http2;
  53. server_name kemoshi.co;
  54.  
  55. ####################
  56. # SECURITY WARNING #
  57. ####################
  58. #
  59. # Providing a state of the art TLS configuration
  60. # is beyond the scope of this documentation.
  61. #
  62. # You need to replace this comment with a proper
  63. # ssl configuration template for nginx.
  64. #
  65. # If you don't know were to start, you can get one here :
  66. # https://mozilla.github.io/server-side-tls/ssl-config-generator/
  67. #
  68. # This configuration file won't work without ssl configuration directives.
  69.  
  70. keepalive_timeout 70;
  71. sendfile on;
  72. client_max_body_size 0;
  73.  
  74. root /home/mastodon/live/public;
  75.  
  76. gzip on;
  77. gzip_disable "msie6";
  78. gzip_vary on;
  79. gzip_proxied any;
  80. gzip_comp_level 6;
  81. gzip_buffers 16 8k;
  82. gzip_http_version 1.1;
  83. gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
  84.  
  85. location / {
  86. try_files $uri @proxy;
  87. }
  88.  
  89. location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) {
  90. add_header Cache-Control "public, max-age=31536000, immutable";
  91. try_files $uri @proxy;
  92. }
  93.  
  94. location /sw.js {
  95. add_header Cache-Control "public, max-age=0";
  96. try_files $uri @proxy;
  97. }
  98.  
  99. location @proxy {
  100. proxy_set_header Host $host;
  101. proxy_set_header X-Real-IP $remote_addr;
  102. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  103. proxy_set_header X-Forwarded-Proto https;
  104. proxy_set_header Proxy "";
  105. proxy_pass_header Server;
  106.  
  107. proxy_pass http://127.0.0.1:3000;
  108. proxy_buffering off;
  109. proxy_redirect off;
  110. proxy_http_version 1.1;
  111. proxy_set_header Upgrade $http_upgrade;
  112. proxy_set_header Connection $connection_upgrade;
  113.  
  114. tcp_nodelay on;
  115. }
  116.  
  117. location /api/v1/streaming {
  118. proxy_set_header Host $host;
  119. proxy_set_header X-Real-IP $remote_addr;
  120. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  121. proxy_set_header X-Forwarded-Proto https;
  122. proxy_set_header Proxy "";
  123.  
  124. proxy_pass http://127.0.0.1:4000;
  125. proxy_buffering off;
  126. proxy_redirect off;
  127. proxy_http_version 1.1;
  128. proxy_set_header Upgrade $http_upgrade;
  129. proxy_set_header Connection $connection_upgrade;
  130.  
  131. tcp_nodelay on;
  132. }
  133.  
  134. error_page 500 501 502 503 504 /500.html;
  135. }
  136.  
  137. ----
  138.  
  139. cd /etc/nginx/sites-enabled
  140. ln -s ../sites-available/kemoshi.co.conf
  141. systemctl stop nginx
  142. letsencrypt certonly --standalone -d kemoshi.co
  143. systemctl start nginx
  144. letsencrypt certonly --webroot -d kemoshi.co -w /home/mastodon/live/public/
  145. vi /etc/cron.daily/letsencrypt-renew
  146.  
  147. ----
  148.  
  149. letsencrypt renew
  150. systemctl reload nginx
  151.  
  152. ----
  153.  
  154. chmod +x /etc/cron.daily/letsencrypt-renew
  155. systemctl restart cron
  156.  
  157. ----
  158.  
  159. sudo su - mastodon
  160. cd ~/live
  161. cp .env.production.sample .env.production
  162. vi .env.production
  163.  
  164. ----
  165.  
  166. # Your Redis host
  167. REDIS_HOST=127.0.0.1
  168. # Your Redis port
  169. REDIS_PORT=6379
  170. # Your PostgreSQL host
  171. DB_HOST=/var/run/postgresql
  172. # Your PostgreSQL user
  173. DB_USER=mastodon
  174. # Your PostgreSQL DB name
  175. DB_NAME=mastodon_production
  176. # Leave DB password empty
  177. DB_PASS=Krmt.k2011po
  178. # Your DB_PORT
  179. DB_PORT=5432
  180.  
  181. # Your instance's domain
  182. LOCAL_DOMAIN=mstdn.kemoshi.co
  183. # We have HTTPS enabled
  184. LOCAL_HTTPS=true
  185.  
  186. # Application secrets
  187. # Generate each with `RAILS_ENV=production bundle exec rake secret`
  188. PAPERCLIP_SECRET=
  189. SECRET_KEY_BASE=
  190. OTP_SECRET=
  191.  
  192. # Web Push VAPID keys
  193. # Generate with `RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key`
  194. VAPID_PRIVATE_KEY=
  195. VAPID_PUBLIC_KEY=
  196.  
  197. # All SMTP details, Mailgun and Sparkpost have free tiers
  198. SMTP_SERVER=smtp.kemono-friends.xyz
  199. SMTP_PORT=587
  200. SMTP_LOGIN=confirm_kemoshi.co@kemono-friends.xyz
  201. SMTP_PASSWORD=krmt#k2011po
  202. SMTP_FROM_ADDRESS=
  203.  
  204. ----
  205.  
  206. RAILS_ENV=production bundle exec rails db:setup
  207. RAILS_ENV=production bundle exec rails assets:precompile
Add Comment
Please, Sign In to add comment