Thin: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{lowercase title}} | |||
http://code.macournoyer.com/thin/ | http://code.macournoyer.com/thin/ | ||
http://articles.slicehost.com/2008/5/6/ubuntu-hardy-apache-rails-and-thin | http://articles.slicehost.com/2008/5/6/ubuntu-hardy-apache-rails-and-thin | ||
== To Restart Just One Web Site == | |||
If you have many site configs in <code>/etc/thin</code> and you don't want to restart them all, do this: | |||
<pre> | |||
sudo /usr/local/bin/thin -C /etc/thin/mysite.yml restart | |||
</pre> | |||
== Install == | == Install == | ||
Line 19: | Line 26: | ||
timeout: 30 | timeout: 30 | ||
wait: 30 | wait: 30 | ||
port: | port: 5000 | ||
log: log/thin.log | log: log/thin.log | ||
max_conns: 1024 | max_conns: 1024 | ||
Line 27: | Line 34: | ||
#environment: development | #environment: development | ||
environment: production | environment: production | ||
servers: | servers: 3 | ||
daemonize: true | daemonize: true | ||
chdir: /var/www/myapp | chdir: /var/www/myapp | ||
Line 39: | Line 46: | ||
a2enmod proxy_http | a2enmod proxy_http | ||
a2enmod rewrite | a2enmod rewrite | ||
</pre> | |||
The virtual host file should look something like this: | |||
<pre> | |||
<VirtualHost *:80> | |||
ServerName myapp.com | |||
ServerAlias www.myapp.com | |||
LogLevel warn | |||
ErrorLog /var/log/apache2/myapp-error.log | |||
CustomLog /var/log/apache2/myapp-access.log combined | |||
DocumentRoot /var/www/myapp/public | |||
RewriteEngine On | |||
<Proxy balancer://thinservers> | |||
BalancerMember http://127.0.0.1:5000 | |||
BalancerMember http://127.0.0.1:5001 | |||
BalancerMember http://127.0.0.1:5002 | |||
</Proxy> | |||
# Redirect all non-static requests to thin | |||
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f | |||
RewriteRule ^/(.*)$ balancer://thinservers%{REQUEST_URI} [P,QSA,L] | |||
ProxyPass / balancer://thinservers/ | |||
ProxyPassReverse / balancer://thinservers/ | |||
ProxyPreserveHost on | |||
<Proxy *> | |||
Order deny,allow | |||
Allow from all | |||
</Proxy> | |||
</VirtualHost> | |||
</pre> | </pre> |
Latest revision as of 19:25, 6 February 2014
http://code.macournoyer.com/thin/
http://articles.slicehost.com/2008/5/6/ubuntu-hardy-apache-rails-and-thin
To Restart Just One Web Site
If you have many site configs in /etc/thin
and you don't want to restart them all, do this:
sudo /usr/local/bin/thin -C /etc/thin/mysite.yml restart
Install
as root:
gem install thin thin install update-rc.d -f thin defaults (to have thin restart on reboot)
Config File
put this into /etc/thin/myapp.yml
:
--- pid: tmp/pids/thin.pid address: 0.0.0.0 timeout: 30 wait: 30 port: 5000 log: log/thin.log max_conns: 1024 require: [] max_persistent_conns: 512 #environment: development environment: production servers: 3 daemonize: true chdir: /var/www/myapp
Use with Apache
Set up modules:
a2enmod proxy a2enmod proxy_balancer a2enmod proxy_http a2enmod rewrite
The virtual host file should look something like this:
<VirtualHost *:80> ServerName myapp.com ServerAlias www.myapp.com LogLevel warn ErrorLog /var/log/apache2/myapp-error.log CustomLog /var/log/apache2/myapp-access.log combined DocumentRoot /var/www/myapp/public RewriteEngine On <Proxy balancer://thinservers> BalancerMember http://127.0.0.1:5000 BalancerMember http://127.0.0.1:5001 BalancerMember http://127.0.0.1:5002 </Proxy> # Redirect all non-static requests to thin RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteRule ^/(.*)$ balancer://thinservers%{REQUEST_URI} [P,QSA,L] ProxyPass / balancer://thinservers/ ProxyPassReverse / balancer://thinservers/ ProxyPreserveHost on <Proxy *> Order deny,allow Allow from all </Proxy> </VirtualHost>