First understanding of jruby: deploying jruby on rails on Tomcat

Source: Internet
Author: User
Tags apache tomcat
1. prerequesite assume that the Java environment and MySQL database have been installed on the deployed sever (because MySQL is used as an example here ). In addition, in order to be consistent with the previous blog posts, we still deploy the service on Windows. The actual deployment on Linux is similar. Even if you encounter problems, google is ready for you.2. install and configure Apache Tomcat. First, download the Tomcat compressed package on the Apache Tomcat website. The current version is 7.0. After the download is complete, decompress the package. For example, extract the package to c: \. After the package is decompressed, enter the bin directory and run startup as an administrator. start tomcat in the bat batch file. The default Tomcat port is 8080. Therefore, visit http: // localhost: 8080 in the browser. If the figure is displayed, the installation and configuration of Tomcat are correct. 3. Download and install jruby. Install jruby in the previous blog. I will not go into details here. Install necessary JDBC.
 
Jruby-s gem install activerecord-jdbcmysql-adapter-V 1.3.0.beta2

To package the jruby on Rails project as war and publish it to Tomcat, you must use Warbler GEM:

 
Jruby-s gem install warbler

4. Package the jruby on Rails project. First, check that the database. yml file production environment is correctly configured:

Production: adapter: MySQL encoding: utf8 reconnect: false Database: demo_production Username: User Password: Password HOST: localhost port: 3306

Configure the production database and user password correctly. Create the production database demo_production in the database and grant the user full permissions on the database. Then start the packaging project and run the following command in the rails app root directory:

 
Jruby-s warble

This command will generate a war file under the root directory of the project, such as demo. war. This war will package the necessary gem, so that we can deploy it to Tomcat like a common Java project war file. 5. Deploy the war to copy it to the webapps directory of Tomcat. Wait about a few seconds and Tomcat will automatically release the file to complete the deployment. In the last step, go to the Tomcat release folder demo and generate the database schema:

 
C: \ apache-Tomcat-7.0.35 \ webapps \ demo> jruby-s rake DB: migrate rails_env = "production"

Now you can access http: // localhost: 8080/demo to view the homepage of the rails app.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.