{"id":20719260,"url":"https://github.com/tom-weatherhead/rails-stack-example","last_synced_at":"2025-09-07T23:44:41.582Z","repository":{"id":40234756,"uuid":"104581491","full_name":"tom-weatherhead/rails-stack-example","owner":"tom-weatherhead","description":"An example of a Ruby on Rails project that uses RVM, Unicorn, Nginx, PostgreSQL, Systemd, and SELinux on Fedora.","archived":false,"fork":false,"pushed_at":"2023-01-19T11:15:47.000Z","size":78,"stargazers_count":0,"open_issues_count":10,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T07:49:31.001Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tom-weatherhead.png","metadata":{"files":{"readme":"README.macos.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-23T16:22:34.000Z","updated_at":"2019-11-26T04:06:56.000Z","dependencies_parsed_at":"2023-01-28T16:16:17.110Z","dependency_job_id":null,"html_url":"https://github.com/tom-weatherhead/rails-stack-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tom-weatherhead/rails-stack-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom-weatherhead%2Frails-stack-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom-weatherhead%2Frails-stack-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom-weatherhead%2Frails-stack-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom-weatherhead%2Frails-stack-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tom-weatherhead","download_url":"https://codeload.github.com/tom-weatherhead/rails-stack-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom-weatherhead%2Frails-stack-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274112920,"owners_count":25224332,"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-09-07T02:00:09.463Z","response_time":67,"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-17T03:16:25.302Z","updated_at":"2025-09-07T23:44:41.555Z","avatar_url":"https://github.com/tom-weatherhead.png","language":"Ruby","readme":"# README\n\nThis README would normally document whatever steps are necessary to get the application up and running.\n\nThings you may want to cover:\n\n* Ruby version\n\n* System dependencies\n\n* Configuration\n\n* Database creation\n\n* Database initialization\n\n* How to run the test suite\n\n* Services (job queues, cache servers, search engines, etc.)\n\n* Deployment instructions\n\n* ...\n\n# This tutorial is from http://guides.rubyonrails.org/getting_started.html\n\n# Link to the project: http://localhost:3000\n\n###\n\nSoftware Stack Setup Guide: PostgreSQL + nginx + rvm + Unicorn + Ruby on Rails on Fedora 26 LXDE + Systemd + SELinux\n\nSeptember 18-23, 2017\n\nThis \"blog\" example app is from http://guides.rubyonrails.org/getting_started.html\n\n*** Begin ****\n\n1) Install and configure Fedora 26 LXDE\n\t# dnf update\n\t# dnf install curl firefox git gpg2\n\n\t- Create a non-privileged user named \"deployer\":\n\t# useradd -p [password] deployer\n\t\t- To delete the user: # userdel -r deployer\n\t\t- Test the login process for the user via: $ ssh deployer@localhost (package openssh-server must be installed and running)\n\n2) Globally install and configure rvm version ?\n\t- See https://rvm.io/rvm/install\n\n\t# gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB\n\t# \\curl -sSL https://get.rvm.io | bash -s stable --ruby\n\t# source /usr/local/rvm/scripts/rvm\n\t# rvm list\n\t# which ruby\n\t# ruby -v\n\t# usermod -a -G rvm deployer\n\t\t- Add the user \"deployer\" to the group \"rvm\" so that \"deployer\" can install Ruby gems globally (e.g. when installing the app by running \"bundle\").\n\n\tX Not necessary: Ensure that Bash shells start with the \"-l\" (login) option\n\t\t- Put a shortcut to LXTerminal on the desktop. Then right-click on it and go to Properties -\u003e Desktop Entry -\u003e Command. Set tis value to: lxterminal -e \"bash -il\"\n\n3) Install and configure PostgreSQL version 9.6.4-1.fc26.x86_64\n\t- See https://wiki.postgresql.org/wiki/First_steps\n\t\t- The default authentication mode is set to 'ident' which means a given Linux user xxx can only connect as the postgres user xxx.\n\n\t- If there is an existing PostgreSQL data directory, blow it away. Hint: Look for /usr/local/var/postgres\n\n\t# Install PostgreSQL\n\t$ brew install postgresql\n\n\t# Initialize PostgreSQL's data directory\n\t$ initdb -D /usr/local/var/postgres/data -U postgres\n\n\t# Start the PostgreSQL server\n\t$ pg_ctl -D /usr/local/var/postgres/data -l logfile start\n\n\t# Connect to the database 'postgres' as the current user\n\t$ psql -d postgres\n\n\tpostgres=# CREATE USER \"deployer\" WITH SUPERUSER PASSWORD '[password]';\n\n\t\t- See https://dba.stackexchange.com/questions/146087/postgresql-cannot-login-with-created-users\n\t\t! Do not confuse the PostgreSQL user named \"deployer\" with the Linux user named \"deployer\".\n\n\tpostgres=# CREATE DATABASE \"rails_stack_example_development\" OWNER \"deployer\";\n\tpostgres=# CREATE DATABASE \"rails_stack_example_test\" OWNER \"deployer\";\n\tpostgres=# CREATE DATABASE \"rails_stack_example_staging\" OWNER \"deployer\";\n\tpostgres=# CREATE DATABASE \"rails_stack_example_production\" OWNER \"deployer\";\n\tpostgres=# \\q\n\n\t- Test deployer's ability to access the databases:\n\t\n\t$ psql -d rails_stack_example_development -U deployer\n\n\tdeployer=# \\q\n\n\t$ psql -d rails_stack_example_test -U deployer\n\n\tdeployer=# \\q\n\n\t$ psql -d rails_stack_example_staging -U deployer\n\n\tdeployer=# \\q\n\n\t$ psql -d rails_stack_example_production -U deployer\n\n\tdeployer=# \\q\n\n4) Install and configure Unicorn version ?\n\t# gem install unicorn\n\n5) Install and configure the Ruby and Rails application (the \"blog\" app from the Rails \"Getting Started\" page: http://guides.rubyonrails.org/getting_started.html )\n\t# gem install bundler\n\t$ cd /var/www/apps/rails-stack-example\n\tNot necessary? : $ chgrp -R rvm .\n\t$ bundle\n\t$ rake db:migrate\n\t$ RAILS_ENV=test rake db:migrate\n\t$ rails server\n\t- Browse to http://localhost:3000 and smoke-test the app.\n\t- When asked to authenticate, use username \"tomw\" and password \"secret\".\n\n\t$ sudo -i\n\t# chown -R deployer:deployer /var/www/apps/rails-stack-example/\n\t# su - deployer\n\t$ unicorn -c /var/www/apps/rails-stack-example/install/unicorn.rb -E development (-D)\n\t\t- Or: $ bin/bundle exec \"unicorn -c /var/www/apps/rails-stack-example/install/unicorn.rb -E development (-D)\"\n\n6) Install and configure nginx version 1.12.1\n\t# dnf install nginx\n\t- The Unicorn process launched by rails-stack-example.service will run as the user \"deployer\", who must be a member of the \"nginx\" group.\n\t# usermod -a -G nginx deployer\n\t# cd /etc/nginx\n\t# mv nginx.conf nginx.original.conf\n\t# ln -sf /var/www/apps/rails-stack-example/install/nginx.conf\n\t# ls -lZ nginx*\n\t# chcon -h -u system_u -t httpd_config_t nginx.conf\n\t# chcon -u system_u -t httpd_config_t nginx.conf\n\n\t- Ensure that the statically-served assets in \"public\" are readable by nginx:\n\t# chmod -R +x /var/www/apps/rails-stack-example/public\n\t# chcon -Rt httpd_sys_content_t /var/www/apps/rails-stack-example/public\n\t\t- See https://thecruskit.com/fixing-403-errors-when-using-nginx-with-selinux/\n\n\tAs deployer: $ chgrp -R nginx /var/www/apps/rails-stack-example/tmp/sockets/\n\t\t- The .sock file, must be readable and writable by user deployer and group nginx.\n\t\t- Setting the group sticky bit (chmod g+s) will ensure that any files created in this directory will have the same group as the directory itself (i.e. nginx).\n\t\t$ chmod g+s /var/www/apps/rails-stack-example/tmp/sockets/\n\n\t# systemctl restart nginx.service\n\t$ ps aux | grep nginx\n\t- Ensure that the service starts at boot time: # systemctl enable nginx.service\n\n7) Create an SELinux policy module that will allow nginx to read from and write to the Unicorn Unix socket\n\t- To see the current status of SELinux: $ sestatus\n\t- Ensure that the app works with SELinux temporarily disabled\n\t\t- To temporarily disable SELinux: # setenforce 0\n\t- Test the app with SELinux enabled, so that SELinux's audit logs will include nginx's failed attempts to access the socket /var/www/apps/rails-stack-example/tmp/sockets/unicorn.sock\n\t- I had to repeat this process twice, because two different kinds of errors needed to be logged in audit.log before a sufficient policy could be created:\n\t\t- Attempt to GET http://localhost:8008\n\t\t# mkdir /home/deployer/SELinux[n]\n\t\t# cd /home/deployer/SELinux[n]\n\t\t# grep nginx /var/log/audit/audit.log\n\t\t# grep nginx /var/log/audit/audit.log | audit2allow -m nginx \u003e nginx.te\n\t\t# checkmodule -M -m -o nginx.mod nginx.te\n\t\t# semodule_package -o nginx.pp -m nginx.mod\n\t\t# semodule -i nginx.pp\n\t\tX (Reboot.) -\u003e A reboot is not required.\n\n8) Configure systemd to start the \"rails-stack-example\" service automatically at boot time.\n\t- The services \"nginx.service\" and \"postgresql.service\" are found in /usr/lib/systemd/system\n\t\t- \"# systemctl enable ...\" creates symlinks in /etc/systemd/system/multi-user.target.wants/\n\t# cd /etc/systemd/system\n\t# ln -sf /var/www/apps/rails-stack-example/install/rails-stack-example.service\n\t# chcon -h -u system_u -t systemd_unit_file_t rails-stack-example.service\n\t# chcon -u system_u -t systemd_unit_file_t rails-stack-example.service\n\t# systemctl daemon-reload\n\t# systemctl enable rails-stack-example.service\n\t# systemctl status rails-stack-example.service\n\t# systemctl start rails-stack-example.service\n\t# systemctl status rails-stack-example.service\n\n*** End ***\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftom-weatherhead%2Frails-stack-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftom-weatherhead%2Frails-stack-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftom-weatherhead%2Frails-stack-example/lists"}