Configuring Ubuntu VM in Windows Hyper-V with wi-fi

Contents

References

Initial setup

Ensure local package repository and packages are up to date

sudo apt-get update sudo apt-get upgrade

Install Apache and MySQL

sudo apt-get install git build-essential zlibc zlib1g-dev zlib1g sudo apt-get install apache2 apache2-prefork-dev libapr1-dev libaprutil1-dev sudo apt-get install curl libcurl4-openssl-dev libssl-dev libopenssl-ruby sudo apt-get install libreadline6 libreadline6-dev sudo apt-get install mysql-server mysql-client

Setting up RVM/Ruby/Rails

Install prerequisites

sudo apt-get install bash patch bzip2 git-core sudo apt-get install openssl sudo apt-get install libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev sudo apt-get install autoconf libc6-dev libgdbm-dev sudo apt-get install ncurses-dev automake libtool bison subversion sudo apt-get install pkg-config libffi-dev nodejs

Install RVM

sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

Set up users and groups

sudo adduser deployment-user-name sudo adduser deployment-user-name rvm sudo adduser user-name deployment-user-name sudo adduser user-name rvm sudo chown -R deployment-user-name:deployment-user-name /var/www sudo chmod g+w /var/www

Log out and in again and then install Ruby and other bits

rvm install ruby-version rvm --default use ruby-version gem install bundler

Create a new Rails app

rvm use ruby-version-p0@app-name --create rvm --default use ruby-version-p0@app-name gem install rails --version rails-version cd /var/www/ rails new app-name -d mysql cd app-name/

Fix up database configuration in database.yml

Add log-in info created for database into configuration file.

Setting up Passenger

Install prerequisites

sudo apt-get install libcurl4-openssl-dev sudo apt-get install apache2-prefork-dev sudo apt-get install libapr1-dev sudo apt-get install libaprutil1-dev

Install Passenger using these instructions

git clone https://github.com/FooBarWidget/passenger.git cd passenger/ gem build passenger.gemspec gem install passenger-4.0.0.rc5.gem cd .. rm -rf passenger/ rvmsudo passenger-install-apache2-module

Create file /etc/apache2/mods-available/passenger.load with following content:

LoadModule passenger_module /usr/local/rvm/gems/ruby-ruby-version-p0/gems/passenger-4.0.0.rc5/libout/apache2/mod_passenger.so

Create file /etc/apache2/mods-available/passenger.conf with following content:

PassengerRoot /usr/local/rvm/gems/ruby-ruby-version-p0/gems/passenger-4.0.0.rc5 PassengerRuby /usr/local/rvm/wrappers/ruby-ruby-version-p0/ruby

Modify /etc/apache2/apache2.conf by adding following to end

ServerName localhost

Activate Passenger and restart Apache

sudo a2enmod passenger sudo service apache2 restart

Move the default page and update /etc/apache2/sites-available/default using these instructions

mkdir /var/www/default mv /var/www/index.html /var/www/default/index.html

Fix deployment-user-name's access to web

sudo chown -R deployment-user-name:deployment-user-name /var/www

Deployment of app

Log in as deployment-user-name and simulate deployment/migration

cd /var/www/app-name/ rvm use ruby-version-p0 --default bundle install --deployment --without development test bundle exec rake db:migrate RAILS_ENV=production bundle exec rake assets:precompile touch /var/www/app-name/tmp/restart.txt

Log back in as regular user and configure virtual host /etc/apache2/sites-available/app-name

<VirtualHost _default_:80> # ServerName www.example.com # Commented out for default DocumentRoot /var/www/app-name/public/ <Directory /var/www/app-name/public/> AllowOverride all Options -MultiViews </Directory> </VirtualHost>

Enable Rails app

sudo a2ensite app-name sudo service apache2 reload sudo a2dissite default