我正在寻找一个初始化脚本,以在运行Nginx的Web服务器上使用Perlbrew作为Perl催化剂应用程序的代理.我目前正在尝试通过启动应用
source $PERLBREW
execute "perlbrew use perl-5.14.4@devel"
execute "mkdir -p $PID_PATH && $START_ICOS_APP > /dev/null 2>&1 &"
echo "$DESC started"
但它无法找到本地perl安装. $PERLBREW设置为我的perlbrew文件夹.
最佳答案
这是一个很好的逐步指南,指导您执行此操作,但是它是法语(但仍然可以理解).
http://www.catapulse.org/articles/view/124
我在这里复制:
设置要运行催化剂应用程序的用户(此示例中为www-data)
su - www-data
curl -kL http://install.perlbrew.pl | bash
echo 'source ~/perl5/perlbrew/etc/bashrc' >> .profile
. .profile
perlbrew install perl-5.16.3 -Dusethreads --as perl-5.16.3_WITH_THREADS
perlbrew switch perl-5.16.3_WITH_THREADS
#perlbrew install-cpanm
#cpanm Catalyst Catalyst::Devel
#catalyst.pl myapp
(我假设您的应用程序名称为myapp,将其替换为您的名称.)
创建/ etc / nginx / sites-enabled / myapp
server {
listen 80;
server_name exemple.com *.exemple.com;
client_max_body_size 50m;
location / {
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_NAME '';
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass unix:/var/www/myapp/myapp.socket;
}
location /static {
root /var/www/myapp/root;
expires 30d;
}
}
创建/var/www/myapp/myapp.fastcgi.initd
#!/usr/bin/env perl
use warnings;
use strict;
use Daemon::Control;
# 1) create initd file
# ./myapp.fastcgi.initd get_init_file > /etc/init.d/cat-myapp
#
# 3) install to runlevels
# update-rc.d cat-myapp defaults
my $app_home = '/var/www/myapp';
my $perl = 'perl';
my $program = $app_home . '/script/myapp_fastcgi.pl';
my $name = 'myapp';
my $workers = 1;
my $pid_file = $app_home . '/myapp.pid';
my $socket = $app_home . '/myapp.socket';
Daemon::Control->new({
name => $name,lsb_start => '$nginx',lsb_stop => '$nginx',lsb_sdesc => $name,lsb_desc => $name,path => $app_home . '/myapp.fastcgi.initd',user => 'www-data',group => 'www-data',directory => $app_home,program => "$perl $program --nproc $workers --listen $socket",pid_file => $pid_file,stderr_file => $app_home . '/myapp.out',stdout_file => $app_home . '/myapp.out',fork => 2,})->run;
设置文件权限并创建正确的初始化文件:
$chmod +x myapp.fastcgi.initd
$./myapp.fastcgi.initd get_init_file > /etc/init.d/cat-myapp
启动您的应用程序并启动Web服务器:
$/etc/init.d/cat-myapp start
$/etc/init.d/nginx restart