Created
June 6, 2012 16:46
-
-
Save conanr/2883179 to your computer and use it in GitHub Desktop.
How to stand up a Vagrant box instance and host JSBlogger using Nginx|Passenger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant box add precise32 http://files.vagrantup.com/precise32.box | |
vagrant init precise32 | |
# update Vagrantfile to port forward: ln 32 => "config.vm.forward_port 80, 8080" | |
vagrant up | |
vagrant ssh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in 'vagrant ssh' terminal ... | |
sudo apt-get update | |
sudo apt-get install curl | |
sudo apt-get install git-core | |
sudo apt-get install build-essential | |
sudo apt-get install libcurl4-openssl-dev | |
sudo apt-get install libpq-dev | |
sudo apt-get install libxml2 | |
sudo apt-get install libxml2-dev | |
sudo apt-get install libxslt1-dev | |
sudo apt-get install postgresql | |
bash < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) | |
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc | |
source /home/vagrant/.rvm/scripts/rvm | |
rvm install 1.9.3 | |
rvm use 1.9.3 | |
gem install passenger | |
rvmsudo passenger-install-nginx-module --auto --auto-download --prefix /opt/nginx | |
sudo -u postgres psql | |
create user jsblogger with password 'jsblogger' CREATEDB; | |
\q | |
mkdir -p /home/vagrant/websites | |
cd /home/vagrant/websites | |
git clone https://github.com/JumpstartLab/jsblogger_advanced.git | |
# update JS_blogger Gemfile to include 'therubyracer' & replace "sqlite3" gem with "pg" for postgres | |
cd jsblogger_advanced | |
bundle | |
# update jsblogger_advanced/config/database.yml to use contents of database.yml below | |
bundle exec rake db:create RAILS_ENV=production | |
bundle exec rake db:migrate RAILS_ENV=production | |
# update /opt/nginx/conf/nginx.conf to use contents of nginx.conf below | |
ln -s jsblogger_advanced/public/ blogger | |
sudo /opt/nginx/sbin/nginx | |
bundle exec rake assets:precompile | |
# now visit http://localhost:8080/blogger in your browser; it ^should^ just work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
development: | |
adapter: postgresql | |
database: jsblogger_dev | |
username: jsblogger | |
password: jsblogger | |
host: localhost | |
test: | |
adapter: postgresql | |
database: jsblogger_test | |
username: jsblogger | |
password: jsblogger | |
host: localhost | |
production: | |
adapter: postgresql | |
database: jsblogger_live | |
username: jsblogger | |
password: jsblogger | |
host: localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#user nobody; | |
worker_processes 1; | |
#error_log logs/error.log; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
#pid logs/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
passenger_root /home/vagrant/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12; | |
passenger_ruby /home/vagrant/.rvm/wrappers/ruby-1.9.3-p194/ruby; | |
include mime.types; | |
default_type application/octet-stream; | |
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
# '$status $body_bytes_sent "$http_referer" ' | |
# '"$http_user_agent" "$http_x_forwarded_for"'; | |
#access_log logs/access.log main; | |
sendfile on; | |
#tcp_nopush on; | |
#keepalive_timeout 0; | |
keepalive_timeout 65; | |
#gzip on; | |
server { | |
listen 80; | |
server_name localhost; | |
passenger_enabled on; | |
#charset koi8-r; | |
#access_log logs/host.access.log main; | |
location / { | |
root /home/vagrant/websites; | |
passenger_enabled on; | |
passenger_base_uri /blogger; | |
} | |
#error_page 404 /404.html; | |
# redirect server error pages to the static page /50x.html | |
# | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root html; | |
} | |
# proxy the PHP scripts to Apache listening on 127.0.0.1:80 | |
# | |
#location ~ \.php$ { | |
# proxy_pass http://127.0.0.1; | |
#} | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
# | |
#location ~ \.php$ { | |
# root html; | |
# fastcgi_pass 127.0.0.1:9000; | |
# fastcgi_index index.php; | |
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; | |
# include fastcgi_params; | |
#} | |
# deny access to .htaccess files, if Apache's document root | |
# concurs with nginx's one | |
# | |
#location ~ /\.ht { | |
# deny all; | |
#} | |
} | |
# another virtual host using mix of IP-, name-, and port-based configuration | |
# | |
#server { | |
# listen 8000; | |
# listen somename:8080; | |
# server_name somename alias another.alias; | |
# location / { | |
# root html; | |
# index index.html index.htm; | |
# } | |
#} | |
# HTTPS server | |
# | |
#server { | |
# listen 443; | |
# server_name localhost; | |
# ssl on; | |
# ssl_certificate cert.pem; | |
# ssl_certificate_key cert.key; | |
# ssl_session_timeout 5m; | |
# ssl_protocols SSLv2 SSLv3 TLSv1; | |
# ssl_ciphers HIGH:!aNULL:!MD5; | |
# ssl_prefer_server_ciphers on; | |
# location / { | |
# root html; | |
# index index.html index.htm; | |
# } | |
#} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment