{"id":19984651,"url":"https://github.com/twilightcoders/freenas-rails-setup","last_synced_at":"2025-07-24T08:38:33.027Z","repository":{"id":18789344,"uuid":"22002986","full_name":"TwilightCoders/FreeNAS-Rails-Setup","owner":"TwilightCoders","description":"Setup for Rails in FreeNAS","archived":false,"fork":false,"pushed_at":"2016-06-18T04:35:52.000Z","size":28,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-04T06:33:38.404Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TwilightCoders.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-19T05:50:58.000Z","updated_at":"2017-11-16T14:39:02.000Z","dependencies_parsed_at":"2022-07-12T22:00:38.165Z","dependency_job_id":null,"html_url":"https://github.com/TwilightCoders/FreeNAS-Rails-Setup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TwilightCoders/FreeNAS-Rails-Setup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwilightCoders%2FFreeNAS-Rails-Setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwilightCoders%2FFreeNAS-Rails-Setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwilightCoders%2FFreeNAS-Rails-Setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwilightCoders%2FFreeNAS-Rails-Setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TwilightCoders","download_url":"https://codeload.github.com/TwilightCoders/FreeNAS-Rails-Setup/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwilightCoders%2FFreeNAS-Rails-Setup/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266815220,"owners_count":23988562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T04:19:47.054Z","updated_at":"2025-07-24T08:38:31.986Z","avatar_url":"https://github.com/TwilightCoders.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 1. Jail\n1. **name:** webserver\n2. **type:** portjail (x64)\n3. Click 'save'\n4. Click 'jails'\n5. Click 'webserver'\n6. Click 'shell'\n\n## 1.1. SSH access\n\n1. `vi /etc/rc.conf`\n2. change `sshd_enable=\"NO\"` to `sshd_enable=\"YES\"`\n3. start ssh daemon (sshd) `/etc/rc.d/sshd start`\n\nparameters: needs to belong to group \"wheel\" - reason? to enable SSH\nalso make sure when choosing a shell input \"bash\" - otherwise csh will default, and this won't work\n\n### 1.1.1. adduser (your own account)\n1. type: `adduser`\n2. Invite to login group 'wheel'\n3. Set shell path to bash (We'll install this in the next steps) `/usr/local/bin/bash`\n\n### 1.1.2. promote www to real user\n1. `mkdir -p /home/www/sites`\n2. `cp ~/.profile /home/www` (Copy our profile over to www, because it never had one to begin with)\n3. `chown -R www:www /home/www`\n4. `chpass www`\n5. set home to `/home/www`\n6. set shell to `/usr/local/bin/bash`\n7. `pw usermod www -G wheel`\n\n## 1.2. Ports\nIn the shell that you launched for the web server jail you created we need to fetch extract and update our ports.\n\n1. portsnap fetch\n1. portsnap extract\n1. portsnap update\n\n### 1.2.1. Port: bash\nThis will prompt for configuration options. Configure as you see fit. I recommend (in the subsequent dependent port installations, disabling EXAMPLES *pic here*\n\n1. `cd /usr/ports/shells/bash`\n2. `make install clean`\n3. I turn off P4 and CVS\n\n### 1.2.2. Port: sudo\n\n1. `cd /usr/ports/security/sudo`\n2. `make install clean`\n3. I like to select `INSULTS` and `LDAP` as options\n4. `vi /usr/local/etc/sudoers`\n5. uncomment (remove '#') this line `# %wheel ALL=(ALL) ALL` (near the bottom of the file)\n6. `wq!` (Write, Quit, Because I Said So)\n\n\nNOTE: AT THIS POINT YOU CAN SSH INTO YOUR BOX IF YOU'D LIKE TO; NO MORE FreeNAS WEBGUI SHELL\nIf you do, and you log in with the user you created earlier, you'll likely need to install ports using the `sudo` command. Oh, how convenient; we just installed that.\n\n### 1.2.3. Port: git\n\n1. `cd /usr/ports/devel/git`\n2. `make install clean`\n3. When it asks about `curl`, I install with LDAP/S and LIBSSH2\n4. When `ca_root_nss-3.16.1` select ETCSYMLINK\n5. DOCS not needed for `xmlto`, `getopt`, `libgcrypt`, `libgpg-error`, `docbook-xsl`, `xmlcatmgr`, `w3m`, `boehm-gc`, `libatomic_ops`\n6. EXAMPLES not needed for `python27`, `p5*`\n\n(this will take a while, but stick with it)\n\n\n### 1.2.4. Port: MySQL\n\n1. `cd /usr/ports/databases/mysql56-server`\n2. `make install clean`\n3. `echo 'mysql_enable=\"YES\" \u003e\u003e /etc/rc.conf`\n\n\n### 1.2.5. Port: sqlite3\n\n1. `cd /usr/ports/databases/sqlite3`\n2. `make install clean`\n3. I turn on `MEMMAN`\n\n\n### 1.2.6. Port: node\nV8 JavaScript for client and server\n\n1. `cd /usr/ports/www/node`\n2. `make install clean`\n\n\n### 1.2.7. Port: nginx\n\n1. `cd /usr/ports/www/nginx`\n2. `make install clean`\n3. I turn on `HTTP_GEOIP`, `HTTP_GZIP_STATIC`, `HTTP_GUNZIP_FILTER`, `HTTP_PERL`, `MAIL`, `MAIL_SSL`, `HTTP_AUTH_LDAP`, `HTTP_AUTH_DIGEST`, `HTTP_FANCYINDEX`, `HTTP_PUSH`, `HTTP_PUSH_STREAM`, `HTTP_REDIS`, `HTTP_RESPONSE`, `HTTP_UPLOAD`, `HTTP_UPLOAD_PROGRESS` (you can always install more or less depending on what your server needs)\n4. `echo 'nginx_enable=\"YES\"' \u003e\u003e /etc/rc.conf`\n5. `mkdir /var/log/nginx`\n6. `chmod g+w /var/log/nginx`\n\n### 1.2.8. Port: rbenv (https://github.com/sstephenson/rbenv)\n\n1. `cd /usr/ports/devel/rbenv`\n2. `make install clean`\n3. echo 'export PATH=\"$HOME/.rbenv/bin:$PATH\"' \u003e\u003e ~/.bash_profile\n4. echo 'eval \"$(rbenv init -)\"' \u003e\u003e ~/.bash_profile\n\n### 1.2.9. Port: ruby-build (https://github.com/sstephenson/ruby-build)\n\n1. `cd /usr/ports/devel/ruby-build`\n2. `make install clean`\n3. You can leave RBENV checked; we already installed it.\n4. Execute the commands we placed into our `.bash_profile`, `source ~/.bash_profile` (or `. ~/.bash_profile`)\n\n### 1.2.10. Port: ruby\nLet's install ruby at the base of our server. We'll be installing localized ruby versions later, (rbenv) but it's nice to have a global ruby present.\n\n1. `cd /usr/ports/lang/ruby21`\n2. `make install clean`\n3. You can pick whatever version you want, but you might as well go with the latest stable.\n\n# 2. Web Server\n\nedit webserver jail get mac address fix router\n\n1. `sudo mkdir /var/run/unicorn`\n2. `chmod g+w /var/run/unicorn`\n\n\nNext we're going to install the things we need to get our server hooked up and running. We'll start with Ruby.\n\n## 2.1. Setup\nFirst however, we need to do all of this inside the `www` user, as it will be running nginx etc.\n\n1. `sudo su - www`\n2. `echo 'export PATH=\"$HOME/.rbenv/bin:$PATH\"' \u003e\u003e ~/.bash_profile`\n3. `echo 'eval \"$(rbenv init -)\"' \u003e\u003e ~/.bash_profile`\n4. `. ~/.bash_profile`\n\n## 2.2. Ruby\n\n1. `rbenv install 2.1.2`\n2. `rbenv global 2.1.2`\n3. `rbenv rehash`\n\n(test to see if Ruby runs - \"ruby -v\" - if not, run \"exec $SHELL -l\")\n\n## 2.3 Rails\nLet's get Bundler and Rails installed, as we'll need those to get a basic project up and running.\n\n1. `gem install bundler rails`\n2. `gem install sqlite3 -- --with-sqlite3-dir=/usr/local`\n3. `rbenv rehash`\n4. `rails new sites/SITE_PROJECT_NAME`\n5. `mv SITE_PROJECT_NAME current`\n6. `mkdir SITE_PROJECT_NAME`\n7. `mv current SITE_PROJECT_NAME`\n\n## 2.4 Unicorn\nPartial credit goes to:\n* http://sirupsen.com/setting-up-unicorn-with-nginx\n\n\n1. `gem install unicorn`\n2. `rbenv rehash`\n3. `curl -fsSL https://raw.github.com/TwilightCoders/FreeNAS-Rails-Setup/master/unicorn.rb -o ~/sites/SITE_PROJECT_NAME/config/unicorn.rb`\n4. Edit the unicorn.rb file that is now in your config directory for the rails project you made earlier. `vi ~/sites/SITE_PROJECT_NAME/config/unicorn.rb`\n5. Set `site_name` to the name of your project (SITE_PROJECT_NAME, or whatever you called it)\n6. `:wq!` (write, quit, because I said so)\n\n\n## 2.5 nginx\nWe've already installed nginx, so now it's time to do a little setup.\n\nPartial credit goes to:\n* http://bsdbox.co/2014/01/12/emp-nginx-mysql-php-fpm-on-freebsd\n* http://theflyingdeveloper.com/server-setup-ubuntu-nginx-unicorn-capistrano-postgres\n\n1. `cd /usr/local/etc/nginx`\n2. `mkdir sites`\n3. `mkdir conf.d`\n4. `curl -fsSL https://raw.github.com/TwilightCoders/FreeNAS-Rails-Setup/master/options -o conf.d/options`\n5. `curl -fsSL https://raw.github.com/TwilightCoders/FreeNAS-Rails-Setup/master/default.rails.site -o default.rails.site`\n6. `curl -fsSL https://raw.github.com/TwilightCoders/FreeNAS-Rails-Setup/master/nginx.conf -o nginx.conf`\n7. `cp default.rails.site sites/SITE_PROJECT_NAME.site`\n\nNow edit that file you just copied over and edit the following:\n\n1. Change `app_server` (line 1) to `SITE_PROJECT_NAME_server`\n2. Change the path on line 2 to match your socket path\n3. Change `server_name` to reflect the domain name you expect to use\n4. Change the `root` path to match your project path\n5. Finally, change the `proxy_pass` (near the bottom) to reflect the change you made in the first step\n\n# 3. Launch!\nAlright! That wasn't too bad, now was it? Just a lot of coffee breaks waiting for things to compile/install.\n\nNow the fun begins. From the 'www' user (`sudo su - www`)\n\n1. `unicorn -c /home/www/sites/SITE_PROJECT_NAME/current/config/unicorn.rb -D`\n2. now exit back out of user www\n2. `/usr/local/etc/rc.d/nginx start`\n3. Direct your web browser to the IP/domain of your server.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwilightcoders%2Ffreenas-rails-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwilightcoders%2Ffreenas-rails-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwilightcoders%2Ffreenas-rails-setup/lists"}