{"id":578,"date":"2015-03-30T20:36:07","date_gmt":"2015-03-30T17:36:07","guid":{"rendered":"https:\/\/kari.world.ikari.fi\/?p=578"},"modified":"2015-03-30T20:36:07","modified_gmt":"2015-03-30T17:36:07","slug":"tuning-up-apache2-passenger","status":"publish","type":"post","link":"https:\/\/kari.world.ikari.fi\/?p=578","title":{"rendered":"Tuning up apache2 + passenger"},"content":{"rendered":"<p>Todays topic to is tuneup a bit more server what was setup earlier.<\/p>\n<p>Goal is to,<\/p>\n<ul>\n<li>Improve logic for redeploy, thus to avoid breaking running server when doing new deploy<\/li>\n<li>Remove dependency into private user account, but use instead account specific to this deploy only<\/li>\n<li>To use server instance specific ruby version instead of globally installed OS default ruby version<\/li>\n<\/ul>\n<p><strong>1)<\/strong> Make my dreams true, aka. use separate release directory via symlink<\/p>\n<p>Cleanup server directory structure<br \/>\n[code]<br \/>\ncd \/home\/www\/virtual\/host.kari.dy.fi<br \/>\nmkdir release_20150330<br \/>\nmv * release_20150330<br \/>\nmv .* release_20150330<br \/>\nln -s release_20150330 current<br \/>\n[\/code]<\/p>\n<p>\/etc\/apache\/vhosts.d\/host.kari.dy.fi.conf<br \/>\nUpdate config<br \/>\n[code]<br \/>\n<VirtualHost *:80><br \/>\n  ServerName host.kari.dy.fi<br \/>\n  # !!! Be sure to point DocumentRoot to &#8217;public&#8217;!<br \/>\n  DocumentRoot \/home\/www\/virtual\/host.kari.dy.fi\/current\/public<\/p>\n<p>  # if not specified, the global error log is used<br \/>\n  ErrorLog \/var\/log\/apache2\/host.kari.dy.fi-error_log<br \/>\n  CustomLog \/var\/log\/apache2\/host.kari.dy.fi-access_log combined<\/p>\n<p>  # to allow symbolic link for server release<br \/>\n  <Directory \/home\/www\/virtual\/host.kari.dy.fi><br \/>\n    Options FollowSymLinks<br \/>\n  <\/Directory><\/p>\n<p>  <Directory \/home\/www\/virtual\/host.kari.dy.fi\/current\/public><br \/>\n    # This relaxes Apache security settings.<br \/>\n    AllowOverride all<br \/>\n    # MultiViews must be turned off.<br \/>\n    Options -MultiViews<br \/>\n    # Uncomment this if you&#8217;re on Apache >= 2.4:<br \/>\n    Require all granted<br \/>\n  <\/Directory><br \/>\n <\/VirtualHost><br \/>\n[\/code]<\/p>\n<p><strong>2)<\/strong> Get of my lawn, aka. use different user<\/p>\n<p>[code]<br \/>\nadduser rails<br \/>\n\/home\/www\/virtual<br \/>\nchown -R rails host.kari.dy.fi<br \/>\n[\/code]<\/p>\n<p>okey, server is going to broken at this point, and will be fixed into running stage in step <strong>(3)<\/strong>. Meanwhile, need to setup ssh keys (<a href=\"https:\/\/help.github.com\/articles\/generating-ssh-keys\/\">Generating SSH keys<\/a>) for &#8221;rails&#8221; user to allow &#8221;bundle install&#8221; to succeed later on<\/p>\n<p>[code]<br \/>\nssh-keygen -t rsa -C &#8221;xxx@gmail.com&#8221;<br \/>\n[\/code]<\/p>\n<p><strong>3)<\/strong> Use server specific ruby version.<\/p>\n<p>This is a bit trickier, i.e. instead of using globally installed ruby version, desire is to use ruby version specific to account owning rails app (aka. user &#8221;rails&#8221; in this case).<\/p>\n<p>\/etc\/apache2\/conf.d\/mod_passenger.conf<br \/>\n[code]<br \/>\n  &#8230;<br \/>\n#  PassengerRuby &#8221;\/usr\/bin\/ruby&#8221;<br \/>\n  PassengerRuby &#8221;ruby&#8221;<br \/>\n  &#8230;<br \/>\n[\/code]<\/p>\n<p>Setup ruby (using RVM)<br \/>\n[code]<br \/>\ncd \/home\/www\/virtual\/host.kari.dy.fi<br \/>\n\\curl -sSL https:\/\/get.rvm.io | bash<br \/>\nrvm install 2.1.5<br \/>\ncd current<br \/>\nbundle<br \/>\ngem install passenger -v 4.0.53<br \/>\n[\/code]<\/p>\n<p>Restart apache2<br \/>\n[code]<br \/>\nservice apache2 restart<br \/>\n[\/code]<\/p>\n<p><strong>Done!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Todays topic to is tuneup a bit more server what was setup earlier. Goal is to, Improve logic for redeploy, thus to avoid breaking running server when doing new deploy Remove dependency into private user account, but use instead account specific to this deploy only To use server instance specific ruby version instead of globally&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,13,23],"tags":[],"class_list":["post-578","post","type-post","status-publish","format-standard","hentry","category-development","category-rails","category-web"],"_links":{"self":[{"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=\/wp\/v2\/posts\/578","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=578"}],"version-history":[{"count":0,"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=\/wp\/v2\/posts\/578\/revisions"}],"wp:attachment":[{"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}