下面我们执行“./bin/passenger-install-nginx-module”开始安装,安装过程较长,为了更清楚的说明过程,我们使用了截图:
在这个过程中由于没有安装rack而被迫终止,因此,我们需要安装这个工具。
|
[root@nas passenger-3.0.9]# /usr/local/bin/gem install rack Successfully installed rack-1.3.3 1 gem installed Installing ri documentation for rack-1.3.3... Installing RDoc documentation for rack-1.3.3... |
安装到这一步,需要我们做一个选择,是否自动下载和安装Nginx?安装过程说的很明确,Nginx服务器不像Apache等服务器一样支持模块载入,因此,为了安装支持Passenger的Nginx那么必须重新编译Nginx。这里有两个选择:
选择1:这也是被推荐的一种选择,这个方法很容易开始,但是这种方式不会支持第三方的模块;
选择2:自定义Nginx的安装,推荐为高级用户使用,选择这种方式可以同时编译多个第三方模块,如果需要传递给“configure”脚本额外的选项,该安装器会有三个询问选择项,我们看一下:
1):询问Nginx的源代码位置,这个需要我们手动填入;
2):询问安装Nginx的位置,也需要我们手动添加:
3):看下面“Extra arguments to pass to configure script.:”,在一行下面,我们可以添加额外的编译选项:
|
If you specify nothing then the 'configure' script. will be run as follows:
sh ./configure --prefix='/usr/local/nginx-1.0.6' --with-http_ssl_module --with-cc-opt='-Wno-error' --add-module='/root/passenger-3.0.9/ext/nginx'
Extra arguments to pass to configure script.
--------------------------------------------
Confirm configure flags
The Nginx configure script. will be run as follows:
sh ./configure --prefix='/usr/local/nginx-1.0.6' --with-http_ssl_module --with-cc-opt='-Wno-error' --add-module='/root/passenger-3.0.9/ext/nginx'
Is this what you want? (yes/no) [default=yes]:
--------------------------------------------
Compiling Passenger support files... # /usr/local/bin/ruby /usr/local/bin/rake nginx:clean nginx RELEASE=yes (in /root/passenger-3.0.9) |
在“Is this what you want? (yes/no) [default=yes]:”确定是否是我们需要的编译选项,如果确定那么就选择“yes”,这也是默认在选择。在我们敲响回车后安装将会继续进行。看下面的截图,这说明开始Passenger程序的安装,安装过程较长,我们只截图了开始的一小部分:
接着安装Nginx:
过程较长,我们看到其中的一小部分。接着往下看:
到这里,具有Passenger支持的Nginx安装已经完成,并且告诉了我们在配置文件中添加了相应的配置。
下面是部署Ruby应用程序的例子:
看一下安装后的Nginx目录结构:
|
[root@nas ~]# tree /usr/local/nginx-1.0.6/ -L 2 /usr/local/nginx-1.0.6/ |-- conf | |-- fastcgi.conf | |-- fastcgi.conf.default | |-- fastcgi_params | |-- fastcgi_params.default | |-- koi-utf | |-- koi-win | |-- mime.types | |-- mime.types.default | |-- nginx.conf | |-- nginx.conf.default | |-- scgi_params | |-- scgi_params.default | |-- uwsgi_params | |-- uwsgi_params.default | `-- win-utf |-- html | |-- 50x.html | `-- index.html |-- logs `-- sbin `-- nginx
4 directories, 18 file |
我们看一下安装时的选项:
|
[root@nas ~]# /usr/local/nginx-1.0.6/sbin/nginx -V nginx: nginx version: nginx/1.0.6 nginx: TLS SNI support disabled nginx: configure arguments: --prefix=/usr/local/nginx-1.0.6 --with-http_ssl_module --with-cc-opt=-Wno-error --add-module=/root/passenger-3.0.9/ext/nginx |
注意黑体字部分,这说明Passenger是以模块的形式安装在Nginx服务器。
我们看一下安装后的Nginx配置文件:
|
[root@nas conf]# grep -v "#" nginx.conf
worker_processes 1;
events { worker_connections 1024; }
http { passenger_root /root/passenger-3.0.9; passenger_ruby /usr/local/bin/ruby;
include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65;
server { listen 80; server_name localhost;
location / { root html; index index.html index.htm; }
error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }
} }
|
注意黑体字标出的部分。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27043155/viewspace-734733/ ,如需转载,请注明出处,否则将追究法律责任。