<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammadreza Haghiri</title>
    <description>The latest articles on DEV Community by Muhammadreza Haghiri (@prpe).</description>
    <link>https://dev.to/prpe</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F450080%2Faff78f44-d362-4905-b016-5ebb2d42724d.jpeg</url>
      <title>DEV Community: Muhammadreza Haghiri</title>
      <link>https://dev.to/prpe</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prpe"/>
    <language>en</language>
    <item>
      <title>What I've learned in 2020, as a developer. </title>
      <dc:creator>Muhammadreza Haghiri</dc:creator>
      <pubDate>Wed, 30 Dec 2020 15:30:01 +0000</pubDate>
      <link>https://dev.to/prpe/what-i-ve-learned-in-2020-as-a-developer-1a48</link>
      <guid>https://dev.to/prpe/what-i-ve-learned-in-2020-as-a-developer-1a48</guid>
      <description>&lt;p&gt;Although 2020 was like an alien attack to humanity from the beginning, it also had a lot of good opportunities for learning and experiencing new stuff. I know most of us experience loss of the loved ones, disease, economic disaster and the world almost survived possibilities of war and bigger and deadlier plagues. &lt;/p&gt;

&lt;p&gt;Fortunately, the world went that bad and nothing horrible happened besides the pandemic. So we could chill in our homes and learn new stuff. In this post, I will tell you what I've learned in 2020 and those can be the stuff you'll be learning in 2021! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UDq5vHzH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lqv1lyznu08j8gnjkcte.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UDq5vHzH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lqv1lyznu08j8gnjkcte.jpg" alt="2020 vs. Iron Man"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting better at Ruby and Rails
&lt;/h2&gt;

&lt;p&gt;Although I started learning Ruby in 2014, but I really needed to get better at the topic. Why? because it is fun. Despite the lack of documentation on deployment and maintenance, Rails is awesome. I always had the bottleneck of deploying and maintaining my projects, so I learned those as well. &lt;/p&gt;

&lt;p&gt;How? you may ask, I should say it was a very painful way to learn. It was mostly reverse engineering of what other projects like &lt;em&gt;Mastodon&lt;/em&gt; did. &lt;/p&gt;

&lt;p&gt;Finally, I made a few projects using RoR in 2020. I may make a huge one in 2021 as well, but I still doubt about doing that. &lt;/p&gt;

&lt;h2&gt;
  
  
  Learning Docker
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docker.com"&gt;Docker&lt;/a&gt; is awesome. It's really good to learn Docker and use it to manage, develop and deploy projects. Although I have a lot to learn, I added to my knowledge of Docker in 2020 and I won't regret that!&lt;/p&gt;

&lt;h2&gt;
  
  
  Flutter
&lt;/h2&gt;

&lt;p&gt;Mobile app development was never my call. But &lt;a href="http://flutter.dev"&gt;Flutter&lt;/a&gt; did change my mind. How? Because it is really simple and the result is amazing. &lt;/p&gt;

&lt;p&gt;I always had a strong guard against &lt;em&gt;React Native&lt;/em&gt;, why? firstly because it's a javascript library and secondly, because it's not really native despite the name. &lt;/p&gt;

&lt;p&gt;In flutter on the other hand, things work differently. It's still not that native, but has stronger bindings to the native libraries. It also uses &lt;em&gt;Dart&lt;/em&gt; as the programming language, which has a similar syntax to javascript (at least to me, it looks like JS). &lt;/p&gt;

&lt;p&gt;Flutter made me learn a bit of mobile app development and I have an &lt;em&gt;overview&lt;/em&gt; of the process now. &lt;/p&gt;

&lt;h1&gt;
  
  
  A.I.
&lt;/h1&gt;

&lt;p&gt;I made it a bigger(?) section 'cause I worked on different aspects of Artificial Intelligence. I'll explain what I've learned!&lt;/p&gt;

&lt;h2&gt;
  
  
  Image recognition/Identification
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6tr5_A29--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zmf7jgpmon8l6endn3wu.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6tr5_A29--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zmf7jgpmon8l6endn3wu.jpg" alt="Not Hotdog"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember that episode from season 4 of HBO's show &lt;em&gt;Silicon Valley&lt;/em&gt;? The character Jian Yang, designed an application called &lt;em&gt;SeeFood&lt;/em&gt;. What that app did was simply say something is or is not a hotdog. &lt;/p&gt;

&lt;p&gt;I learned the theory behind the app, and I also implemented a simple version of that as well. I think I need to learn about the whole thing a bit more, because it's really cool!&lt;/p&gt;

&lt;h2&gt;
  
  
  Voice assistant
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;MCU&lt;/em&gt; (stands for &lt;em&gt;Marvel Cinematic Universe&lt;/em&gt;) has a lot of ideas for you, if you &lt;strong&gt;seriously&lt;/strong&gt; want to create super hero stuff. &lt;/p&gt;

&lt;p&gt;There's the current-time representation of Edwin Jarvis, who served Howard Stark and later Tony Stark in the comic books as &lt;strong&gt;J.A.R.V.I.S&lt;/strong&gt;, which is a smart assistant. &lt;/p&gt;

&lt;p&gt;Re-watching the whole franchise, gave me the idea of re-making it. I made my own personal assistant and I also called it Jarvis as well (but later I realized Jarvis is one of the most used names for assistants so I need a better name!). I added machine learning to my assistant and now it works very well! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rcqdWB82--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cjsg2p8oiwmyc3ffau70.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rcqdWB82--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cjsg2p8oiwmyc3ffau70.jpg" alt="Django Reinhardt"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  And last, but not the least : Django and Django ReST framework
&lt;/h2&gt;

&lt;p&gt;After years of &lt;em&gt;playing&lt;/em&gt; with Python, I did a lot with that amazing language. Besides A.I, I also started learning DRF. Why? Because it can help me find a job easier. I actually did not spend a lot of time on that, but I'm sure I can make a really &lt;em&gt;big&lt;/em&gt; project in DRF. And I may do it in weeks. &lt;/p&gt;

&lt;h1&gt;
  
  
  What should I do for 2021?
&lt;/h1&gt;

&lt;p&gt;I don't really know. I may learn PHP as well, I may learn React or Vue, there are always a lot of ways. For now, just have happy and nice holidays!&lt;/p&gt;

</description>
      <category>developer</category>
      <category>devops</category>
      <category>programming</category>
      <category>mobile</category>
    </item>
    <item>
      <title>A friendly guide to what you should do BEFORE deploying your rails application!</title>
      <dc:creator>Muhammadreza Haghiri</dc:creator>
      <pubDate>Fri, 30 Oct 2020 09:09:19 +0000</pubDate>
      <link>https://dev.to/prpe/a-friendly-guide-to-what-you-should-do-before-deploying-your-rails-application-5ll</link>
      <guid>https://dev.to/prpe/a-friendly-guide-to-what-you-should-do-before-deploying-your-rails-application-5ll</guid>
      <description>&lt;p&gt;Deploying a rails app, can be really painful and hard. One of my friends once said &lt;em&gt;deploying a rails app is like founding a company&lt;/em&gt;. By the way, it's part of founding your internet company or startup, if you chose RoR as your backend framework. &lt;/p&gt;

&lt;p&gt;Recently, I had to deploy an application for one of my friends. To be honest, I wrote a guide on how you can deploy rails app before. You can find it &lt;a href="https://dev.to/prpe/a-friendly-guide-to-deploy-a-rails-app-using-nginx-no-docker-needed-2p34"&gt;here&lt;/a&gt;. In this article, I tell you whatever I didn't tell in the previous post. So, fasten your seat belts and let's dive deep into the ocean of rails apps. &lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Ruby
&lt;/h2&gt;

&lt;p&gt;I personally use &lt;a href="http://rvm.io"&gt;RVM&lt;/a&gt; to install ruby. I don't explain how you can install ruby on your machine. Just click on the link and learn how you can do it yourself! &lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Your Application Ready
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Setting your environment up
&lt;/h3&gt;

&lt;p&gt;This part, is actually everything you need to know about pre-deploy stage. Other parts of this article are not as important as this part to be honest. &lt;/p&gt;

&lt;p&gt;For deploying our app, we need to set something up. I just list them below : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;RAILS_ENV&lt;/code&gt; : This environment variable actually determines the environment of your choice. If you don't set it up properly, it will put your app in &lt;em&gt;development&lt;/em&gt; environment and not &lt;em&gt;production&lt;/em&gt;. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SECRET_KEY_BASE&lt;/code&gt; : This environment variable is also for the secret key that your app uses. For this one, please be careful. Because other frameworks or apps can be using the same variable name, it may make your project less secure to deploy all of those apps with the same user or in the same environment. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Fine! Now you know what we're going to add to our environment. Open &lt;code&gt;~/.bashrc&lt;/code&gt; or &lt;code&gt;~/.zshrc&lt;/code&gt; on your server (in case you use FreeBSD, you may have the option of &lt;code&gt;~/.cshrc&lt;/code&gt; as well) and add this line at the end :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export RAILS_ENV=production
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now navigate to your app's directory (I assume it's on your home folder so it is in &lt;code&gt;~/myrailsapp&lt;/code&gt;) and then run this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rake secret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It gives you a key. Copy it and back to &lt;code&gt;~/.bashrc&lt;/code&gt; (or &lt;code&gt;~/.zshrc&lt;/code&gt; or &lt;code&gt;~/.cshrc&lt;/code&gt;) and then add this line to that file as well :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export SECRET_KEY_BASE="iamthekeythatrakegaveyoudeardeveloper"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more information, replace what I have put in double quotes says "I am the key that rake gave you dear developer". So of course you have to put the key you've got from &lt;code&gt;rake&lt;/code&gt; here. &lt;/p&gt;

&lt;h3&gt;
  
  
  Further settings
&lt;/h3&gt;

&lt;p&gt;Now everything is all set. Just remember this part is not that hard to understand because you may have done it before reading my article. &lt;/p&gt;

&lt;h3&gt;
  
  
  MySQL database settings
&lt;/h3&gt;

&lt;p&gt;I've got a Mac, and surprisingly, when I made an app which used MySQL/MariaDB, my &lt;code&gt;config/database.yml&lt;/code&gt; looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;default: &amp;amp;default
  adapter: mysql2
  encoding: utf8mb4
  pool: &amp;lt;%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %&amp;gt;
  username: root
  password:
  socket: /tmp/mysql.sock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But I assume you're a Linux user on the server side as well. So for the love of God, change it to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;default: &amp;amp;default
  adapter: mysql2
  encoding: utf8
  pool: &amp;lt;%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %&amp;gt;
  username: root
  password:
  host: localhost
  port: 3306
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By the way, MySQL port and host may differ in your case. So mind all of differences. &lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up database and assets
&lt;/h3&gt;

&lt;p&gt;Finally the easiest part! Just run these:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails db:setup
rails db:migrate 
rails assets:precompile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you also may need to run this as well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn install --check-files
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you can deploy your app and enjoy! &lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>mysql</category>
    </item>
    <item>
      <title>Reddit Junkie, a CLI tool for downloading images from Reddit!
</title>
      <dc:creator>Muhammadreza Haghiri</dc:creator>
      <pubDate>Fri, 02 Oct 2020 08:17:21 +0000</pubDate>
      <link>https://dev.to/prpe/reddit-junkie-a-cli-tool-for-downloading-images-from-reddit-5b1o</link>
      <guid>https://dev.to/prpe/reddit-junkie-a-cli-tool-for-downloading-images-from-reddit-5b1o</guid>
      <description>&lt;p&gt;What would you say, if I tell you there's a tool installed on my Ubuntu machine which makes downloads from reddit much easier?&lt;/p&gt;

&lt;p&gt;In past few days, I was busy creating a machine learning project. I needed tons of images and I haven't found anywhere better than reddit, the front page of the internet for crawling and downloading pictures I needed. Pictures are provided by people and most of them are &lt;em&gt;real world&lt;/em&gt; pictures and not fancy advertisements for a luxury restaurant.&lt;/p&gt;

&lt;p&gt;So, I couldn't crawl reddit using &lt;code&gt;BeautifulSoup&lt;/code&gt; or &lt;code&gt;Nokogiri&lt;/code&gt;. But I realized something. For a project, I have used JSON API to get a bunch of pictures. So, I wanted an automation for the downloads! I opened up my VS Code, grabbed a cup of coffee, went to my black metal playlist on Spotify and started coding.&lt;/p&gt;

&lt;p&gt;Now, I have this really cool tool which can help me create datasets for my A.I. project!&lt;/p&gt;

&lt;h2&gt;
  
  
  CLI tool
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Installing the reddit_junkie tool
&lt;/h2&gt;

&lt;p&gt;On a Linux, BSD, macOS or WSL machine, you need to install ruby first. my personal preference is always &lt;a href="http://rvm.io"&gt;RVM&lt;/a&gt;, but as long as what you have installed can handle &lt;code&gt;httparty&lt;/code&gt; gem, that's OK.&lt;/p&gt;

&lt;p&gt;For installing, just run this command:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem install reddit_junkie
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and it'll be available as a command line tool for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Downloading 25 images, in the default "images" directory
&lt;/h2&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reddit_junkie --subreddit SUB
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;for example, if you want the latest things from &lt;a href="http://reddit.com/r/skyporn"&gt;r/skyporn&lt;/a&gt; you just run :&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reddit_junkie --subreddit skyporn
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Downloading 25 images in a custom directory
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reddit_junkie --subreddit SUB --directory DIR
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;For example, you've built a folder called &lt;code&gt;sky&lt;/code&gt; and you want to save the pictures there. Also, if you haven't created the folder, &lt;code&gt;reddit_junkie&lt;/code&gt; will create it for you.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reddit_junkie --subreddit skyporn --directory sky
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Downloading more than 25 images in default "images" directory
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reddit_junkie --subreddit SUB --count COUNT
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;For example, you want to download 300 pictures of the sky :&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reddit_junkie --subreddit skyporn --count 300
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Downloading more than 25 images in a custom directory
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reddit_junkie --subreddit SUB --count COUNT --directory DIR
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;For example, you want to download 300 pictures of the sky, in your &lt;code&gt;sky&lt;/code&gt; directory :&lt;/p&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reddit_junkie --subreddit skyporn --count 300 --directory sky&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Known issues / not tested&lt;br&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The CLI tool isn't tested with the &lt;code&gt;--endpoint&lt;/code&gt; flag yet. It seems OK though.&lt;/li&gt;
&lt;li&gt;In case of more than 100 images, you only can do the download for numbers dividable by 100. Like 300 or 1000 or 25000. As I made this tool to help me make a dataset, I haven't spent much time on fixing this issue.&lt;/li&gt;
&lt;li&gt;CLI flags/parameters reading isn't really good. It works just fine, but not absolutely in the POSIX way.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/prp-e/reddit_image_downloader"&gt;Github&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://rubygems.org/gems/reddit_junkie"&gt;Ruby Gems&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ruby</category>
      <category>webscrapping</category>
    </item>
    <item>
      <title>A friendly guide to deploy a rails app using nginx (no docker needed)</title>
      <dc:creator>Muhammadreza Haghiri</dc:creator>
      <pubDate>Wed, 19 Aug 2020 13:10:09 +0000</pubDate>
      <link>https://dev.to/prpe/a-friendly-guide-to-deploy-a-rails-app-using-nginx-no-docker-needed-2p34</link>
      <guid>https://dev.to/prpe/a-friendly-guide-to-deploy-a-rails-app-using-nginx-no-docker-needed-2p34</guid>
      <description>&lt;p&gt;In past six years, I developed a huge skill set in ruby programming. Although it may seem a bit stupid, but after knowing such a great company like &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt; uses &lt;a href="http://rubyonrails.org"&gt;Ruby on Rails&lt;/a&gt; as their backend framework and great FLOSS projects such as &lt;a href="http://gitlab.com"&gt;Gitlab&lt;/a&gt; or &lt;a href="http://joinmastodon.org"&gt;Mastodon&lt;/a&gt; are written in rails as well, you will find out it might be a smart choice. &lt;/p&gt;

&lt;p&gt;Although the whole process of building an app in rails is quiet easy and just needs a lot of search (or if you're like me, you can ask your questions in &lt;a href="http://reddit.com/r/rails"&gt;rails subreddit&lt;/a&gt; and get help from a lot of great fellas there). Everything in Rails is pretty straight forward, except one things. &lt;strong&gt;THE DEPLOYMENT&lt;/strong&gt;. It's really a hell of pain. But fortunately, I found a way which can work to some extent. &lt;/p&gt;

&lt;h2&gt;
  
  
  Gaining HTTPS access for your domain/subdomain
&lt;/h2&gt;

&lt;p&gt;In this tutorial, I will use &lt;a href="http://ubuntu.com"&gt;Ubuntu&lt;/a&gt; and &lt;a href="http://debian.org"&gt;Debian&lt;/a&gt; as an example. I'm sure the package names are mostly similar in other Linux distributions. In case of &lt;a href="http://freebsd.org"&gt;FreeBSD&lt;/a&gt;, I will give you the proper package name, do not worry. &lt;/p&gt;

&lt;p&gt;For having HTTPS on your domain, first you have to install &lt;code&gt;certbot&lt;/code&gt;. As we're going to use nginx, this package will be enough :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install python-certbot-nginx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;For FreeBSD, install &lt;code&gt;py37-certbot-nginx&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;After certbot installation, you need to get certificates :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo certbot --nginx -d example.com -d www.example.com 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;NOTE: Make sure that you set both root and www records on your DNS service provider.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Now, you have certificates! Let's deploy. &lt;/p&gt;

&lt;h2&gt;
  
  
  Installing ruby and rails
&lt;/h2&gt;

&lt;p&gt;Even on servers, I prefer &lt;a href="http://rvm.io"&gt;RVM&lt;/a&gt;. So, I skip the &lt;em&gt;installation&lt;/em&gt; part. &lt;/p&gt;

&lt;h2&gt;
  
  
  Deployment
&lt;/h2&gt;

&lt;p&gt;Are curious how I came up with this idea? It wasn't really easy though. One or two months ago, one of my friends at work just said &lt;em&gt;Mastodon has an LXC image available&lt;/em&gt;. It made me a bit happy, 'cause I was thinking of my own instance of Mastodon. &lt;/p&gt;

&lt;p&gt;Two weeks ago, I made a simple rails app and wanted to deploy it. I took a look at docker and lxc images of other rails projects and understood nothing. But I knew that I have access to a server with Mastodon running. I still don't have my own instance, that server belongs to a friend of mine. I just connected to the server and found how it's deployed. So for deploying your app, follow the following instructions .&lt;/p&gt;

&lt;h3&gt;
  
  
  Authenticity Token Problem
&lt;/h3&gt;

&lt;p&gt;Open up your controllers and add this line to them :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;skip_before_action :verify_authenticity_token
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I'm not sure if this makes your app unsafe or not, and if adding it to the file &lt;code&gt;app/controllers/application_controller.rb&lt;/code&gt; makes it global or not. Please let me know in the comments or where I shared the article with you. &lt;/p&gt;

&lt;h3&gt;
  
  
  Doing migrations and stuff
&lt;/h3&gt;

&lt;p&gt;I assume you know that you should do database migrations, asset compilations, etc. So I skip this part as well. &lt;/p&gt;

&lt;h3&gt;
  
  
  Running the app
&lt;/h3&gt;

&lt;p&gt;Fine, for running the app, I usually set &lt;code&gt;RAILS_ENV=production&lt;/code&gt; in &lt;code&gt;.bashrc&lt;/code&gt; or &lt;code&gt;.zshrc&lt;/code&gt;, depending on the shell I use. After that, I open a &lt;code&gt;screen&lt;/code&gt; session like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;screen -S rails-app-appname
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;then, I run my app :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails s -b 0.0.0.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And by pressing &lt;code&gt;CTRL + A&lt;/code&gt; then pressing &lt;code&gt;D&lt;/code&gt;, I deatch from that session. I suggest this way for you as well. &lt;/p&gt;

&lt;p&gt;After running your app, just edit nginx configurations as following. &lt;/p&gt;

&lt;p&gt;First, open the configuration file :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo vi /etc/nginx/sites-enabled/default
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then, look for your domain name (&lt;code&gt;certbot&lt;/code&gt; adds your address to this configuration file). Under the server section which includes your domain name, just create this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   location @railsapp {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Proxy "";
        proxy_pass_header Server;
        proxy_pass http://127.0.0.1:3000;
        proxy_buffering off;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        tcp_nodelay on;
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And then modify your root address to the &lt;code&gt;public&lt;/code&gt; folder of your project. &lt;/p&gt;

&lt;p&gt;For example on one of my server, the default root is &lt;code&gt;/home/git/www&lt;/code&gt; and I have changed that to &lt;code&gt;/home/my_user/rails_app/public&lt;/code&gt; for that particular domain name. &lt;/p&gt;

&lt;p&gt;Then, make your root location like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;location / {
    try_files $uri @railsapp;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After that, do this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl reload nginx
sudo systemctl restart nginx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;on FreeBSD (or Linux distributions without &lt;code&gt;systemd&lt;/code&gt;) just do this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo service nginx restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And happy using your app! &lt;/p&gt;

&lt;h2&gt;
  
  
  Why not docker?
&lt;/h2&gt;

&lt;p&gt;It's a personal preference I believe. I have a server with two gigabytes of RAM, and to my experience, these container solutions waste a lot of RAM. Also, for one who doesn't know how to work with docker (specially myself!) it will be really hard to get things work fine. Such as database connections, etc. &lt;/p&gt;

&lt;p&gt;In conclusion, if you have enough knowledge and resource, using docker might be even a better choice. But if you like the classic ways, I wrote this article for you. &lt;/p&gt;

&lt;p&gt;Happy coding :-) &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
