国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
How To Setup a Rails 4 App With Apache and Passenger on CentOS 6 | DigitalOcean

The Basics


When the user creates a droplet from a vanilla image (in our case: CentOS 6.4 x64), additional system administration work is needed before a Ruby on Rails application can be run and become available online. This tutorial provides the necessary steps to make that happen.

In order to go through this tutorial, a virtual server with at least 1 GB of RAM is a minimum requirement, because Passenger commands in step #3 are memory intensive.

Also, the tutorial assumes that the user has root access to the VPS (either as a user with root privileges or as the system root).

This tutorial is not intended for production node setup. It involves development library installation and ad hoc compilation on the machine, which is not a good practice when you're setting up a production environment."

Step One – Apache Setup


It all starts with the web server and the simplest way to install Apache is to pull it from the yum repository:

yum install httpd 

After the installation is done, the system should be configured to automatically run Apache on system boot:

chkconfig httpd on 

Without this setting, the httpd service needs to be started manually each time the droplet is rebooted.

The next step is to configure Apache to expect incoming requests by editing its configuration file:

nano /etc/httpd/conf/httpd.conf 

In the editor, near the bottom, locate and uncomment the line containing: NameVirtualHost *:80

Save and exit the editor. Apache is ready to be started now:

service httpd start 

Voilà! Accessing droplet’s IP address in a web browser will show Apache’s welcome page.

Step Two – Ruby 2.0 and Rails 4.0 Setup


Setting up Apache was an easy stroll. It’s even simpler to setup Ruby, followed by Rails.

The quickest way is to use Ruby Version Manager (RVM) to maintain multiple Ruby environments on the
machine. The latest stable version of RVM is downloaded and installed like this:

curl -L get.rvm.io | bash -s stable 

If RVM is supposed to be used by all users, there is a shell script available for the job:

source /etc/profile.d/rvm.sh 

Additionally, installing RVM’s requirements is necessary and this command will install various development packages and dependencies:

rvm requirements 

At this point, RVM is fully initialized and ready for use.

Currently, the latest Ruby version is 2.0.0 and the corresponding RVM command that installs it is:

rvm install 2.0.0 

It will download and install the Ruby environment. After the installation and even though it is the only version installed at this point, it should be configured as the default environment:

rvm use 2.0.0 --default 

Rails is distributed as a Ruby gem and adding it to the local system is extremely simple:

gem install rails 

A quick version check will yield output similar to this one:

[user@server ~]$ ruby -v ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux] [user@server ~]$ rails -v Rails 4.0.1 

Nice job!

Step Three – Phusion Passenger Setup


Phusion Passenger (commonly shortened to Passenger or referred to as mod_passenger) is an application server and it is often used to power Ruby sites. Its code is distributed in form of a Ruby gem, which is then compiled on the target machine and installed into Apache as a module.

First, the gem needs to be installed on the system:

gem install passenger 

Before the Apache module is compiled, two dependency packages need to be installed as well:

yum install curl-devel httpd-devel 

The environment is now ready for the compilation. The process takes a few minutes and it’s started by the following command:

passenger-install-apache2-module  

Note that this script will not install the module really. It will compile module’s binary and place it under
gem’s path. The path will be printed on screen and it needs to be copy-pasted into Apache’s config file
(/etc/httpd/conf/httpd.conf) manually.

The output will be similar to this one:

LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.26/buildout/apache2/mod_passenger.so PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.26 PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p353/ruby 

Placing those lines at the bottom of the file will do just fine. Save the change and restart Apache:

service httpd restart 

Two green OK messages mark completion of the environment setup. Congrats!

Finally – A Rails App Example


It’s always good to do a smoke test and using Rails’ app skeleton generator is an ideal tool for that task. It requires sqlite’s development package to be installed:

yum install sqlite-devel 

The simplest location to place the test application code is Apache’s web root folder:

cd /var/www/html 

In this folder, test application code is generated under the “helloapp” folder:

rails new helloapp cd helloapp 

Since CentOS doesn’t come with a JavaScript execution environment, one must be installed manually. It can be installed as a gem, hence it simply needs to be listed in Gemfile as follows:

gem 'therubyracer' 

Gems required by the Ruby application are installed by positioning in application’s root and running the bundle installer:

bundle install 

Also, the development database needs to be initialized by the migration tool:

rake db:migrate 

One final visit to Apache’s config file (/etc/httpd/conf/httpd.conf) is needed. A virtual host section is missing and it must be added at the bottom:

RackEnv development

RackEnv development<VirtualHost *:80>  ServerName www.yourhost.com  # !!! Be sure to point DocumentRoot to 'public'!  DocumentRoot /var/www/html/helloapp/public  <Directory /var/www/html/helloapp/public>  # This relaxes Apache security settings.  AllowOverride all  # MultiViews must be turned off.  Options -MultiViews  </Directory> </VirtualHost> 

Save the change and restart Apache once again:

service httpd restart 

Go to the virtual server’s IP address in your browser and you should see the “Welcome aboard – You’re riding Ruby on Rails!” welcome message.

Submitted by Tonci Damjanic
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Wang Zhe's Blog | CentOS下部署Redmine項目管理系統(tǒng)
Redmine Apache SVN SMTP的安裝配置
Redmine+Apache+SVN+Postfix完整配置指南 - 手機綜合交流 - 烈...
安裝Gitorious
rvm,gems,rubygems,bundle,gemfile,git,rake,怎么這么多概念,都是干什么用的?
Ruby China | RVM 實用指南
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服