Today I am going to install ruby on rails with mysql database on Ubuntu 12.04.
We can install MySQL server by using this command
hareram@hareram:~$ sudo apt-get install mysql-server
Then follow the message shown by mysql and finally it will asked for password and repeat password.Give same the password for both.
Now the MySQL server is installed. You can checkout by running below command
hareram@hareram:~$ mysql -u root -p
Now check if your system has already installed curl or not by running the below command.
If you see the below one then curl is not installed on your system.
The program 'curl' is currently not installed. You can install it by typing: sudo apt-get install curl
Then install curl on your system using the below command
hareram@hareram:~$ sudo apt-get install curl
We are installing the curl because we need to install rvm using curl.
Now we are ready to install rvm .
We can install rvm using the below command
hareram@hareram:~$\curl -L https://get.rvm.io | bash -s stable
If you will get warning like below one
* WARNING: You're using ~/.profile, make sure you load it, add the following line to ~/.bash_profile if it exists otherwise add it to ~/.bash_login: source ~/.profile
Then add “source ~/.profile” to bash_profile file.
Also run the below command
hareram@hareram:~$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
Now check the requirements for installing ruby using below command
hareram@hareram:~$ rvm requirements
After running the above command you will get the additional list of application need to be installed before ruby is installed
# For ruby: sudo apt-get --no-install-recommends install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev
Run the above command to install the other application before installing the ruby.
Now we can install the ruby 1.9.3 using the below command
hareram@hareram:~$ rvm install 1.9.3
Now the set default ruby using
hareram@hareram:~$ rvm use 1.9.3 --default
Now install current version rails using the below command
hareram@hareram:~$ gem install rails
Now creata a demoapp using rails
hareram@hareram:~$ rails new demoapp -d mysql
We have passed “-d mysql” for using mysql database for application.
If you get the below error of mysql2 gem install
An error occurred while installing mysql2 (0.3.11), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.
Then you have to install the below application to complete the mysql2 gem installation.
sudo apt-get install libmysql-ruby sudo apt-get install libmysqlclient-dev
Now Ruby on Rails with mysql database are installed on your system and you are ready to fly in the world of Ruby on Rails.
Thanks for reading post ….. 🙂
Please put your queries if you have any?