Debian installs the ruby + nginx + Apache development environment.

Source: Internet
Author: User

Install software

1. Very simple. If Apache, MySQL, and nginx are not installed.

# Apt-Get installapache2 nginx

2. Enable Apache rewrite.

# A2enmod rewrite

# Apt-Get install mysql-Server

3. the ruby, Apache Ruby module, MySQL Ruby support, and VIM rails support will be installed below.

# Apt-Get install Ruby rails rubygems rake libapache2-mod-ruby libdbi-Ruby libdbd-mysql-Ruby vim-rails Ri libruby libfcgi-ruby1.9.1 libxml-Ruby libxml2-dev


View installed Ruby versions
Common gem commands

  • Gem list of installed packages
  • Gem install XXX installation package
  • Gem uninstall XXX uninstall the installation package
  • Gem query XXX search package
  • Gem cleanup clear Cache
  • Gem help.

[email protected]:/home/ruby# gem list*** LOCAL GEMS ***rubyzip (1.1.3)

Test the link between Ruby and MySQL.

Compile a simple script to test the link. If the mysql version is displayed, it will be OK.

# Gvim test. Rb

# test.rb - test MySQL script using Ruby DBI modulerequire "dbi"begin    # connect to the MySQL server    dbh = DBI.connect("dbi:Mysql:mysql:localhost", "root", "")    # get server version string and display it    row = dbh.select_one("SELECT VERSION()")    puts "Server version: " + row[0]rescue DBI::DatabaseError => e    puts "An error occurred"    puts "Error code: #{e.err}"    puts "Error message: #{e.errstr}"ensure    # disconnect from server    dbh.disconnect if dbhend
<span style="background-color: rgb(102, 102, 102);"><span style="color:#ffffff;">[email protected]:/home/ruby# ruby ./test.rb Server version: 5.5.37-0+wheezy1-log</span></span>


Test rails
# Run CD/home/WWW To Go To The WWW directory of Apache and nginx. # rails new_project to create a rails project. # cd new_project # rm-RF public/index.html Delete the default page here, so as not to always jump here. # Vim config/database. modify the database of the Development Mode in yml: ruby_test # mysql-uroot-P to enter MySQL and create a database of ruby_test.
[email protected]:/home/www# mysql -u root -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 40Server version: 5.5.37-0+wheezy1-log (Debian)Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.[email protected](none) 12:02:44>create database ruby_test;Query OK, 1 row affected (0.00 sec)
# Script/generate controller blog create a blog controller # script/Server start server, you can use http: // localhost: 3000/access now to implement Hello world # Vim APP/controllers/blog_controller.rb add def index render: text => "Hello World" End


Debian installs the ruby + nginx + Apache development environment.

Related Article

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.