Ruby + Apache + MySQL for Linux

Source: Internet
Author: User

Ruby + Apache + MySQL for Linux

Ruby is a very interesting open-source scripting language that supports Windows/Linux and other platforms. It can be used to develop games, network applications, and system management,
CGI program, etc. It is concise, elegant, and highly efficient to execute, and now there are many mature frameworks to support it. However, it is currently not widely used in China. If you are interested, try it.

The following describes how to install Apache, MySQL, and Ruby Based on Web applications.

I. Software List

Apache httpd-2.0.54.tar.gz http://httpd.apache.org
MySQL mysql-4.0.25.tar.gz http://dev.mysql.com
Mod_ruby mod_ruby-1.2.4.tar.gz http://modruby.net
Eruby eruby-1.0.5 http://modruby.net
Ruby ruby-1.8.2.tar.gz http://www.ruby-lang.org
Ruby-MySQL ruby-mysql-0.2.6.tar.gz http://www.tmtm.org

Ii. Software Installation (assuming that all current operations are performed under/root)

1. Install MySQL

# Tar zxvf mysql-4.0.25.tar.gz # Extract
# Cd mysql-4.0.25
#./Configure -- prefix =/usr/local/MySQL # Configuration
# Make
# Make install
#./Scripts/mysql_install_db # initialize the database
# Useradd MySQL # Add a MySQL user

# Permission settings
# Chown-r root/usr/local/MySQL
# Chgrp-r MySQL/usr/local/MySQL
# Chown-r root/usr/local/MySQL/bin
# Chgrp-r MySQL/usr/local/MySQL/bin
# Chown-r root/usr/local/MySQL/var
# Chgrp-r MySQL/usr/local/MySQL/var
# Chmod 777/usr/local/MySQL/var
# Chown-r root/usr/local/MySQL/var/MySQL
# Chgrp-r MySQL/usr/local/MySQL/var/MySQL
# Chmod 777/usr/local/MySQL/var/MySQL
# Chown-r root/usr/local/MySQL/var/MySQL /*
# Chgrp-r MySQL/usr/local/MySQL/var/MySQL /*
# Chmod 777/usr/local/MySQL/var/MySQL /*
# Chmod 777/usr/local/MySQL/lib/MySQL/libmysqlclient.

#/Usr/local/bin/mysqld_safe -- user = MySQL & # Use user MySQL to run the MySQL daemon

2. Install Ruby

# Tar-zxvf ruby-1.8.2.tar.gz
# Cd ruby-1.8.2
#./Configure -- prefix =/usr/local/Ruby
# Make
# Make install

3. install Apache

# Tar zxvf httpd-2.0.54.tar.gz
# Cd httpd-2.0.54
#./Configure -- prefix =/usr/local/Apache -- enable-module = So # configure Apache installation directory and module Loading
# Make
# Make install

4. Install mod_ruby

# Tar zxvf mod_ruby-1.2.4.tar.gz
# Cd mod_ruby-1.2.4
#./Configure. RB -- With-apxs =/usr/local/Apache/bin/apxs # specify the directory of the Apache module
# Make
# Make install

# Merge Apache and mod_ruby

Edit the/usr/local/Apache/CONF/httpd. conf file and add the following content:

Loadmodule ruby_module/usr/local/Apache/modules/mod_ruby.so

<Ifmodule mod_ruby.c>
# For Apache: rubyrun
Rubyrequire Apache/ruby-run

# Exec files under/Ruby as Ruby scripts.
<Location/Ruby>
Sethandler ruby-Object
Rubyhandler Apache: rubyrun. Instance
Options + execcgi
</Location>

# Exec *. RBx as Ruby scripts.
<Files *. RBx>
Sethandler ruby-Object
Rubyhandler Apache: rubyrun. Instance
</Files>

# For Apache: erubyrun
# Rubyrequire Apache/eruby-run
#
# Handle files under/eruby as eruby files by eruby.
# <Location/eruby>
# Sethandler ruby-Object
# Rubyhandler Apache: erubyrun. Instance
# </Location>
#
# Handle *. rhtml as eruby files.
# <Files *. rhtml>
# Sethandler ruby-Object
# Rubyhandler Apache: erubyrun. Instance
# </Files>

# For Apache: erbrun
# Rubyrequire Apache/ERB-run
#
# Handle files under/ERB as eruby files by ERB.
# <Location/ERB>
# Sethandler ruby-Object
# Rubyhandler Apache: erbrun. Instance
# </Location>

# For debug
# Rubyrequire auto-Reload
</Ifmodule>

# Start Apache
#/Usr/local/Apache/bin/apachectl start

5. Install eruby

# Tar-zxvf eruby-1.0.5.tar.gz
# Cd eruby-1.0.5
#./Configure. Rb
# Make
# Make install

6. Install ruby-MySQL

# Tar-zxvf ruby-mysql-0.2.6
# Cd ruby-mysql-0.2.6

# Use any text editor to open the./ruby-mysql-0.2.6/setup. RB file and modify the content:
Sock = 'mysql _ config -- socket '. Chomp
Is
Sock = '/usr/local/MySQL/bin/mysql_config -- socket'. Chomp
Save and exit

#/Usr/local/Ruby/bin/Ruby./setup. Rb
#/Usr/local/Ruby/bin/Ruby./test. RB 127.0.0.1 root #./test. RB host User Password
#/Usr/local/Ruby/bin/Ruby./install. Rb

7. Test

#/Usr/local/Apache/bin/apachectl restart # restart Apache

Open the browser and enter http: // localhost to view the "Apache installation page" and other content. If an error occurs, the following information should be exposed:

Apache/2.0.52 (UNIX) mod_ruby/1.2.4 server at localhost port 80

If necessary, you can install a PHP and Apache tool to facilitate the installation of tools such as phpMyAdmin.

-- Test code: (save as test. Rb )--

STR = "Content-Type: text/html; charset = UTF-8/n"
STR + = "<HTML> Puts Str

Put the file in the CGI directory you set and access: http: // localhost/cgi-bin/test. Rb in the browser. The output will be displayed. Otherwise, an error will occur.

* Reference: http://www.ruby-cn.org/phpbb/viewtopic.php? T = 72

Writetime: 2005-09-03 23:21
Author: heiyeluren

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.