A simple guide on how to install nginx from source with passenger and ruby enterprise edition.
Hopefully you've been hearing some
comments over the last while about how good the package management
story is with Linux and Ruby. Basically, Ubuntu/Debian makes use of
Aptitude, while Ruby makes use of RubyGems. Aptitude in particular has
made installing things on Linux quicker and easier than Windows.
In most cases the package you get from aptitude is exactly what you
want. However, you'll sometimes want a build with a non default
configuration. In such cases you'll have to grab the source, configure
your makefile, build and install. I admit that it can be a little
intimidating at first, but it really is easy, and it'll cover that last
5% that Aptitude can't. (there's actually a much easier way to get
passenger/nginx up and running, but its good to know and understand the
linux build process)
What we are going to look at in specific is configuring nginx
to use Phusion Passenger
- the combination is quickly becoming the preferred way to host Ruby on
Rails. Even if you aren't interested in Rails development, nginx is
very popular and super-fast reverse proxy/load balancer/http server
used in front of many IIS boxes, so its good to be familiar with it.
Depending on what's already on your box, some of these steps might
be unnecessary. Also, I'm not an expert at this - if it doesn't work,
try and figure it out (it didn't work at first for me either, but
google is great
Step 1 - Get The Source
The first step is to download the nginx source. You can do this however you like, but wget http://sysoev.ru/nginx/nginx-0.8.43.tar.gz
is probably the quickest way (you should check the nginx download page
to see if there's a newer version than 0.8.43).
Step 2 - Untar It
Next we have to unarchive and decompress the source using the tar
command: tar -xvf nginx-0.8.43.tar.gz
. This creates a folder named nginx-0.8.43
.
Step 3 - Setup
You'll probably need to install the core build tools, which you can do by executing apt-get install build-essential
. You'll also want to install Ruby. I use REE (Ruby Enterprise Edition). Download the latest source (using wget) from here
,
untar it, and run the installer. It'll walk you through the
installation processing - telling which and how to install missing
dependencies. Once done, we can add ruby's bin folder to our path: export PATH=$PATH:/opt/ruby-enterprise-1.8.7-2010.02/bin/
(your path may be different)
Next we install the passenger phusion gem: gem install passenger
.
Step 4 - Configure
In following steps we'll make (which builds the code) and then make
install (which installs the built code). Before we do that we need to
generate a MakeFile (which those two steps use). This is where we
change our package from what we could otherwise get from Aptitude
(that's essentially what Aptitude does, it gives us a pre-configured
and pre-built package). The nginx install page
gives us the possible compile-time options as well as samples. We can
run one of the samples from the nginx page (all it does is create a
Makefile, so go ahead and play with it). Change to the nginx directory
and run (./XYZ is how you execute XYZ in Linux, the \ lets us break the
command across multiple lines):
02
|
--conf-path=/etc/nginx/nginx.conf \
|
03
|
--error-log-path=/var/log/nginx/error.log \
|
04
|
--pid-path=/var/run/nginx.pid \
|
05
|
--lock-path=/var/lock/nginx.lock \
|
06
|
--http-log-path=/var/log/nginx/access.log \
|
07
|
--with-http_dav_module \
|
08
|
--http-client-body-temp-path=/var/lib/nginx/body \
|
09
|
--http-proxy-temp-path=/var/lib/nginx/proxy \
|
10
|
--with-http_stub_status_module \
|
11
|
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
|
13
|
--with-http_flv_module
|
You'll probably get some errors - for example, I'm told that the
HTTP rewrite module requires the PCRE library. I'm also given some
options. We can install PCRE, tell nginx to skip loading the HTTP
rewrite module, or point nginx to the PCRE source. You can install PCRE
by running apt-get install libpcre3 libpcre3-dev
. You'll
probably get more errors which you can resolve however you want (by
installing the necessary library (it isn't always easy to know what
library you need), or skipping the module).
Step 5 - More Headers Module
The above is just a sample, we're going to build nginx exactly how
we want it. First though, I need to download any extra module I want to
build with. I'm particularly interested in More Headers Module
,
which gives us more control over headers than what can be done with the
core. Its pretty easy, download the latest version form github page
, untar it, and we can now configure nginx to use this module via the add-module directive: --add-module=/root/headers-more-nginx-module
.
Step 6 - Our Configure
Here's the actual configuration options I'll be using:
02
|
--conf-path=/etc/nginx/nginx.conf \
|
03
|
--error-log-path=/var/log/nginx/error.log \
|
04
|
--pid-path=/var/run/nginx.pid \
|
05
|
--lock-path=/var/lock/nginx.lock \
|
06
|
--http-log-path=/var/log/nginx/access.log \
|
07
|
--http-client-body-temp-path=/var/lib/nginx/body \
|
08
|
--http-proxy-temp-path=/var/lib/nginx/proxy \
|
09
|
--without-http_fastcgi_module \
|
10
|
--without-http_uwsgi_module \
|
11
|
--with-http_stub_status_module \
|
12
|
--with-http_gzip_static_module \
|
13
|
--add-module=/root/headers-more-nginx-module \
|
14
|
--add-module=/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/nginx
|
As you can see I've disabled a couple built-in modules, added a
couple ones, and added our more-header and passenger module. The path
of your passenger module might be different, but it should be similar
except for the possibility of different version numbers.
Step 7 - Make
Now that we have everything configured, we can build it. To do so, simply run make
. Once completed, you can install it by running make install
.
Step 8 - Configuring nginx
You'll want to configure nginx to fit your specific needs, but to
get passenger working you'll need to specify these two directives (in
the http section of the configuration):
1
|
passenger_root /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/passenger-2.2.15;
|
2
|
passenger_ruby /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby;
|
also, you specify passenger_enabled on
within the appropriate nginx locations
Step 9 - Final touches
You'll want a start/stop script for nginx, you can grab mine
, place it in /etc/init.d
, give it execute permission chmod +x /etc/init.d/nginx
and use /etc/init.d/nginx start|stop|restart|reload
(if it fails because of missing directories, go ahead and create them
and try again). Finally, we can make nginx auto start by executing /usr/sbin/update-rc.d -f nginx defaults
.
Conclusion
Hopefully you have everything up and running. All you need to do is
read up on nginx configuration to set up your sites. A long time ago I
remember configuring/making and not really getting it. Now it all seems
pretty trivial. Hopefully you think so too, and remember, if you screw
anything up or want to change something (like include another module),
you can just start the process over (remember to stop relevant running
processes (like nginx) and to make/make install after configuring.)
相关推荐
在本文中,我们将深入探讨如何在Linux环境下安装Oracle 10G数据库系统。Oracle 10G是一款功能强大的关系型数据库管理系统,广泛应用于企业级的数据存储和管理。Linux作为开源且稳定的操作系统,是部署Oracle数据库的...
标题 "Installing Nginx With PHP5 And MySQL Support On Debian Squeeze" 涉及到的是在Debian Squeeze操作系统上安装Nginx web服务器、PHP5脚本语言支持以及MySQL数据库的过程。这是一个基础的LEMP(Linux、Nginx、...
在本文中,我们将深入探讨如何在Linux环境下安装Oracle Database 11g,这是一个重要的数据库管理系统,广泛用于企业级数据存储和处理。Oracle 11g提供了高性能、高可用性和安全性,使其成为许多组织的核心数据库解决...
从压缩包文件`Installing Oracle9i on RedHat Linux 7_2, 7_3, 8_0, 9, AS 2_1, 3_0 (Red Hat Enterprise Advanced Server 3 - RHEL AS 3) (Oracle database installation, install Oracle software).htm`中,我们...
本教程将详述如何在Red Hat Linux操作系统上安装Oracle 9i,这对于那些需要在Linux环境下搭建Oracle数据库的IT专业人士来说是极具价值的。 首先,了解Oracle 9i的基本信息是必要的。Oracle 9i是Oracle公司推出的第9...
### 安装STLinux在Ubuntu上的关键步骤与挑战 #### 概览 本文将深入探讨在Ubuntu上安装STLinux的全过程,重点解析由于包管理系统的差异而带来的挑战及其解决方案。对于那些希望在Ubuntu环境中利用STLinux强大功能的...
2.2. Installing MySQL from Generic Binaries on Unix/Linux 2.3. Installing MySQL on Microsoft Windows 2.3.1. MySQL Installation Layout on Microsoft Windows 2.3.2. Choosing An Installation Package 2.3.3...
【安装Asterisk从源代码】 在进行VoIP通信时,Asterisk是一个非常重要的开源PBX(Private Branch eXchange)系统,它支持多种协议,如SIP、PJSIP和WebRTC。本文主要讲解如何从源代码编译并安装Asterisk。...
### 安装Oracle RAC 10g Release 2于Linux x86(中)的知识点解析 #### 概览与背景 Oracle Database 10g Release 2 RAC(Real Application Clusters)的安装流程旨在指导新手及有经验的用户在Linux环境下部署RAC...
Installing Kali Linux Understanding File Systems and Storage Media Incident Response and Data Acquisition Evidence Acquisition and Preservation with DC3DD and Guymager File Recovery and Data Carving ...
This article describes the installation of Oracle Database 11g release 2 (11.2.0.3 64-bit) RAC on Linux (Oracle Linux 6.3 64-bit) using VirtualBox (4.2.6) with no additional shared disk devices. ...
在深入探讨如何逐步安装Oracle RAC 11gR2于Linux系统上的过程中,我们首先应当理解该版本中引入的一些新概念与特性,这将有助于更有效地进行部署和管理。 ### 1. 新概念概览 #### 1.1 SCAN(Single Client Access ...
Compilation - Compiling and Running C Programs, Installing Codeblocks IDE on Raspberry Pi / Linux, Variables and Data Types in C, Operators, Input and output - printf and scanf, Strings, Arrays, ...
《安装Koha图书馆软件在Windows/Mac/Linux上的指南》 Koha是一款开源的图书馆自动化系统,它涵盖了图书馆管理的所有核心功能,包括目录编目、读者服务、馆际互借、库存管理和报告等。本篇文章将详细讲解如何在不同...
this new edition gives you the basics of building embedded Linux systems, along with the configuration, setup, and use of more than 40 different open source and free software packages in common use....