Nginx+Passenger配置
1.安装passenger相关软件包
[root@master ~]yum install -y rubygems
[root@master ~]gem rack
[root@master ~]gem rake
[root@master ~]gem passenger -v 3.0.12
2.使用passenger-install-nginx-module安装之前先安装相关软件包
注:以下两个包解压即可
[root@master package]#wget http://downloads.sourceforge.net/pcre/pcre-8.32.tar.bz2
[root@master package]#tar xf pcre-8.32.tar.bz2
[root@master package]#http://www.openssl.org/source/openssl-1.0.1.tar.gz
[root@master package]#tar xf openssl-1.0.1.tar.gz
[root@master ~]# passenger-install-nginx-module
选择1
1.This installer will compile and install Nginx with Passenger support.
选择2使用已有的nginx包安装
Where is your Nginx source code located?
Please specify the directory: /root/package/nginx-1.2.8
Where do you want to install Nginx to?
Please specify a prefix directory [/opt/nginx]: /usr/local/nginx
Extra arguments to pass to configure script: --with-pcre=/root/package/pcre-8.32 --with-openssl=/root/package/openssl-1.0.1
3.配置Nginx
[root@master ~]vim /usr/local/nginx/conf/nginx.conf
server {
listen 8140 ssl;
server_name master.csdn.net;
passenger_enabled on;
passenger_set_cgi_param HTTP_X_CLIENT_DN $ssl_client_s_dn;
passenger_set_cgi_param HTTP_X_CLIENT_VERIFY $ssl_client_verify;
access_log /usr/local/nginx/logs/puppet_access.log;
error_log /usr/local/nginx/logs/puppet_error.log;
root /etc/puppet/rack/puppetmaster/public/;
ssl_certificate /var/lib/puppet/ssl/certs/master.csdn.net.pem;
ssl_certificate_key /var/lib/puppet/ssl/private_keys/master.csdn.net.pem;
ssl_crl /var/lib/puppet/ssl/ca/ca_crl.pem;
ssl_client_certificate /var/lib/puppet/ssl/certs/ca.pem;
ssl_ciphers SSLv2:-LOW:-EXPORT:RC4+RSA;
ssl_prefer_server_ciphers on;
ssl_verify_client optional;
ssl_verify_depth 1;
ssl_session_cache shared:SSL:128m;
ssl_session_timeout 5m;
}
4.创建相应的目录.
mkdir -p /etc/puppet/rack/puppetmaster/{public,tmp}
复制config.ru到/etc/puppet/rack/puppetmaster/
cp /usr/share/puppet/ext/rack/files/config.ru /etc/puppet/rack/puppetmaster/
更改config.ru
vim /etc/puppet/rack/puppetmaster/config.ru
# a config.ru, for use with every rack-compatible webserver.
$0 = "master"
# if you want debugging:
# ARGV << "�Cdebug"
ARGV << "�Crack"
require 'puppet/application/master'
run Puppet::Application[:master].run
# EOF /etc/puppet/rack/puppetmaster/config.ru
复制pulic目录到/etc/puppet/rack/puppetmaster/,里面有dispatch.cgi,dispatch.fcgi,以及dispatch.rb等文件
cp -rf /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/test/stub/rails_apps/1.2/empty/public/* /etc/puppet/rack/puppetmaster/public/
[root@master package]# ll /etc/puppet/rack/puppetmaster/public/ ,
total 28
-rw-r--r--. 1 root root 947 May 28 19:18 404.html
-rw-r--r--. 1 root root 941 May 28 19:18 500.html
-rwxr-xr-x. 1 root root 473 May 28 19:18 dispatch.cgi
-rwxr-xr-x. 1 root root 855 May 28 19:18 dispatch.fcgi
-rwxr-xr-x. 1 root root 474 May 28 19:18 dispatch.rb
-rw-r--r--. 1 root root 0 May 28 19:18 favicon.ico
drwxr-xr-x. 2 root root 4096 May 28 19:18 images
-rw-r--r--. 1 root root 99 May 28 19:18 robots.txt
5.改变/etc/puppet/rack的权限为puppet
[root@master package]# chown puppet.puppet /etc/puppet/rack/ -R
6.关闭puppetmaster服务
[root@master package]#service puppetmaster stop
[root@master package]#chkconfig puppetmaster off
7.启动Nginx服务
[root@master package]#/usr/local/nginx/sbin/nginx
常用参加:
-s reload 重新加载配置文件
-s stop 关闭服务
注:启动nginx不能加-s
8.客户端验证