I am using Digital Ocean for the stack. Digital Ocean is the cheapest cloud solution provider compare to Amazon, Rackspace and other providers.
Create an account with Digital Ocean and create a new droplet in the dashboard from Digital Ocean.
Once you've created the new droplet, you will be given the default with the username "root".
Login to your server with the default password and type passwd and you will be asked for new Unix password .
After the installation is done, Choose Yes to the option(Open Bitnami Stack in Browser) and you are ready to see your stack by providing the ip address of your Digital Ocean droplet.
Go to your server root if you're not there yet by typing cd ~
Bitnami also provide the postgresql module and you can download by typing
./bitnami-postgresql-5.4.11-1-module-linux-installer.run
You will then be asked to choose the folder. Type the folder that you installed Bitnami Stack into. Default is "/opt/rubystack-1.9.3-5/"
Now go to cd /opt/rubystack-1.9.3-5 and run the rubyconsole.
./rubyconsole
go back to your root folder cd ~
create a new shell script file by typing vim run_rc.sh in root folder.
Press "I" for insert mode and type the following
echo "run ruby console..."
cd /opt/rubystack-1.9.3-5/
./rubyconsole
After than Press Shift + ; and write "wq" for write the file and quit from vim.
Give the file permission to runnable by typing
chmod 755 run_rc.sh
Now everytime you login to your console, you just have to type
./run_rc.sh which will redirect to your ruby stack installation folder.
/opt/rubystack-1.9.3-5/apache2/conf/extra
Open the vim httpd-vhosts.conf file and apply the following VHost configuration as you need.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
<VirtualHost *:80>
ServerName yourdomain.com
ServerAlias www.youdomain.com
DocumentRoot /opt/rubystack-1.9.3-5/apps/rails_app_folder/public
<Directory /opt/rubystack-1.9.3-5/apps/rails_app_folder/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
#API Server
<VirtualHost *:80>
ServerName api.youdomain.com
ProxyPass / http://localhost:4567/
ProxyPassReverse / http://localhost:4567/
</VirtualHost>
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
Create an account with Digital Ocean and create a new droplet in the dashboard from Digital Ocean.
Once you've created the new droplet, you will be given the default with the username "root".
Login to your server with the default password and type passwd and you will be asked for new Unix password .
Installing Bitnami Stack
First download the linux stack by using the following command in the root directory.
wget http://downloads.bitnami.org/files/stacks/rubystack/1.9.3-5/bitnami-rubystack-1.9.3-5-linux-installer.runGive the application to runnable permission
chmod 755 bitnami-rubystack-1.9.3-5-linux-installer.runInstall the downloaded stack from ssh
After you've run the downloaded file with shell, you will be asked for all the configurations to be installed with the stack. Carefully read the steps and continue installation.
./bitnami-rubystack-1.9.3-5-linux-installer.runAfter the installation is done, Choose Yes to the option(Open Bitnami Stack in Browser) and you are ready to see your stack by providing the ip address of your Digital Ocean droplet.
Installing Postgresql Server
If you're deploying your web app, you might have to use Postgresql server for database as sqlite might be insufficient solution in long terms.Go to your server root if you're not there yet by typing cd ~
Bitnami also provide the postgresql module and you can download by typing
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
or Direct download and run from
wget http://downloads.bitnami.org/files/stacks/postgresql/5.4.11-1/bitnami-postgresql-5.4.11-1-module-linux-installer.run
Give the application to runnable permission and run with shell
chmod 755 bitnami-postgresql-5.4.11-1-module-linux-installer.run./bitnami-postgresql-5.4.11-1-module-linux-installer.run
You will then be asked to choose the folder. Type the folder that you installed Bitnami Stack into. Default is "/opt/rubystack-1.9.3-5/"
Running the Bitnami Ruby Console
Everytime you're calling the ruby and rails command, you will need to run the rubyconsole inside rubystack.Now go to cd /opt/rubystack-1.9.3-5 and run the rubyconsole.
./rubyconsole
Installing Vim (GUI Version)
sudo apt-get install vim-gnome
sudo apt-get install vim
Creating a shell script for ruby console
Let's make a shell script as you might have to do the previous steps of running rubyconsole everytime you log into the accountgo back to your root folder cd ~
create a new shell script file by typing vim run_rc.sh in root folder.
Press "I" for insert mode and type the following
echo "run ruby console..."
cd /opt/rubystack-1.9.3-5/
./rubyconsole
After than Press Shift + ; and write "wq" for write the file and quit from vim.
Give the file permission to runnable by typing
chmod 755 run_rc.sh
Now everytime you login to your console, you just have to type
./run_rc.sh which will redirect to your ruby stack installation folder.
Configuring VHost file in Apache
Now you can go to the following directory./opt/rubystack-1.9.3-5/apache2/conf/extra
Open the vim httpd-vhosts.conf file and apply the following VHost configuration as you need.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
<VirtualHost *:80>
ServerName yourdomain.com
ServerAlias www.youdomain.com
DocumentRoot /opt/rubystack-1.9.3-5/apps/rails_app_folder/public
<Directory /opt/rubystack-1.9.3-5/apps/rails_app_folder/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
#API Server
<VirtualHost *:80>
ServerName api.youdomain.com
ProxyPass / http://localhost:4567/
ProxyPassReverse / http://localhost:4567/
</VirtualHost>
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
Setting up DNS and name servers
If you're using GoDaddy, make sure you park your domain first if you're using nameservers from your previous hosting services. Go to the domain management dashboard. (All Products->Domain->Domain Management)
Click on your domain to go to the DNS manager. Click Edit Zone and remove the existing Points to and A Records in Host section and add new record which points to your server IP address. and click submit. It might take up to 2 hours so don't worry about it if the DNS is not changed instantly.
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa\ or ssh-keyben
Most Ubuntu OS already has .ssh folder and you can just start from step 2.
You will be prompted for a location to save the keys, and a passphrase for the keys. This passphrase will protect your private key while it's stored on the hard drive and be required to use the keys every time you need to login to a key-based system.
wget http://redis.googlecode.com/files/redis-2.4.16.tar.gz
tar xzf redis-2.4.16.tar.gz
cd redis-2.4.16
make
make test
sudo make install
cd utils
sudo ./install_server.sh
sudo service redis_6379 start
sudo service redis_6379 stop
Use the following command to start redis server at boot
sudo update-rc.d redis_6379 defaults
$ psql -U postgres
postgres=# alter user postgres with password 'YOUR_NEW_PASSWORD';
postgresl=# \q
Generating SSH Keys
Type the following command in consolemkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa\ or ssh-keyben
Most Ubuntu OS already has .ssh folder and you can just start from step 2.
You will be prompted for a location to save the keys, and a passphrase for the keys. This passphrase will protect your private key while it's stored on the hard drive and be required to use the keys every time you need to login to a key-based system.
Installing Thin Server
Update apt list first
sudo apt-get update
Before installing the thin server, g++ needs to be downloaded and installed.
sudo apt-get install g++
you also have to make sure the build environment essential is already installed in your system. If not try installing the build essential
sudo apt-get install build-essential
Now you can install thin server
gem install thin
Installing Nodejs
You will need to install nodejs if you are using javascript and jQuery in your ruby on rails app
sudo apt-get install nodejs (Don't do this)
mkdir ~/node-latest-installcd ~/node-latest-installcurl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1./configure --prefix=~/localmake installcurl http://npmjs.org/install.sh | sh
Installing Coffee script
If you're using coffee scripts in your rails app, you will have to install coffee script as it's not installed by default.
npm install -g coffee-script
Installing Redis Cache Server
Normally : Redis server is already included with Bitnami Stack so check
redis-cli ping first and if you receive pong result, you can skip this step.
sudo apt-get install redis-server
you can check the redis-server working by calling
redis-cli ping and you will receive Pong result
you can just type redis-cli to use all the redis command after that
wget http://redis.googlecode.com/files/redis-2.4.16.tar.gz
tar xzf redis-2.4.16.tar.gz
cd redis-2.4.16
make
make test
sudo make install
cd utils
sudo ./install_server.sh
sudo service redis_6379 start
sudo service redis_6379 stop
Use the following command to start redis server at boot
sudo update-rc.d redis_6379 defaults
Restarting the apache server
After you've done all the configurations including vHosts setting, you will have to restart the apache service. Go to your rubystack installation in my case /opt/rubystack-1.9.3-5/
and run ./ctlscript.sh restart
FTP server permissions
create a new user
root@Server:/etc# sudo chmod 777 passwd
root@Server:/etc# vim passwd
Point to /opt/rubystack1.9.3-5/apache2/htdocs
Changing Permission of phpPGAdmin
go to /opt/bitnami/apache2/apps/phppgadmin/conf/phppgadmin.conf
and change "Allow from 127.0.0.1" to "Allow from all"
and then restart the apache server
after that, go to http://your_ip_address/phppgadmin/ to access postgresql admin panel from web browser.
Changing Postgres default password
Default username is postgres and password is what you defined earlier
$ psql -U postgres
postgres=# alter user postgres with password 'YOUR_NEW_PASSWORD';
postgresl=# \q
Creating new database in Postgresql server
cd ~ to go back to the root
createdb database_name to create a new database and you will be prompted for a password and type the password for the superuser.
No comments:
Post a Comment