2014年12月15日月曜日

phpenv on Debian

installation of PHP 5.6.3

curl https://raw.githubusercontent.com/CHH/phpenv/master/bin/phpenv-install.sh | bash
git clone git://github.com/CHH/php-build.git ~/.phpenv/plugins/php-build
echo 'export PATH="$HOME/.phpenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(phpenv init -)"' >> ~/.bashrc
exec $SHELL -l
sudo aptitude install bison re2c libcurl4-openssl-dev libjpeg8-dev libpng-dev libmcrypt-dev libreadline-dev libtidy-dev libxslt1-dev libltdl-dev autoconf
phpenv install -l
phpenv install 5.6.3
phpenv versions
phpenv global 5.6.3

2014年12月1日月曜日

Supervisor+Starman on Debian


installation of supervisor


aptitude install supervisor


setting of supervisor


vim /etc/supervisor/conf.d/programname.conf

[program:programname]
user=username
directory=/home/username/programname
command=/home/username/programname/script/run.sh
autostart=true
autorestart=true
stopsignal=QUIT
stdout_logfile=/var/log/supervisor/programname.log
stderr_logfile=/var/log/supervisor/programname_error.log


creating a run script


vim /home/username/programname/script/run.sh

#!/bin/bash

cd /home/username/programname/
export HOME=/home/username
exec /home/username/perl5/perlbrew/perls/perl-5.20.1/bin/start_server \
    --port 3000 \
    --interval 2 \
    -- /home/username/perl5/perlbrew/perls/perl-5.20.1/bin/plackup \
    -Ilib -s Starman \
    -E production \
    /home/username/programname/webapp.pl \
    --workers 6


restart of supervisor


/etc/init.d/supervisor restart


Check Status


supervisorctl status


supervisorctl start, stop, reload


supervisorctl start programname
supervisorctl stop programname
supervisorctl reread


Confirmation


pkill starman
ps aux | grep starman


reference materials:


 

2014年11月22日土曜日

Nginx + Git on Debian

[server]
cat /etc/debian_version 
7.7
sudo aptitude install nginx git-core git-doc fcgiwrap
sudo adduser git
sudo su - git
mkdir -p /home/git/repositories/test.git
cd /home/git/repositories/test.git
git --bare init --shared=group
mkdir ~/test
cd ~/test
git init
echo "Hello git project" > README
git add .
git commit -m "first push"
git push /home/git/repositories/test.git master
cd /home/git/repositories/test.git
cp -pi hooks/post-update.sample hooks/post-update
git update-server-info
git config http.receivepack true


[Nginx]
sudo vim /etc/nginx/conf.d/git.conf

server {
    listen       80;
    server_name  git.example.com;

    access_log /var/log/nginx/git_access_log;
    error_log /var/log/nginx/git_error_log;

    location /repositories {

        root /home/git/;

        fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
        fastcgi_param GIT_PROJECT_ROOT /home/git;
        fastcgi_param GIT_HTTP_EXPORT_ALL "";
        fastcgi_param PATH_INFO $uri;
        fastcgi_param REMOTE_USER $remote_user;

        fastcgi_pass unix:/var/run/fcgiwrap.socket;

        include /etc/nginx/fastcgi_params;
    }
}

[server]
sudo /etc/init.d/fcgiwrap restart
sudo /etc/init.d/nginx restart

[local]
git clone http://git.choiq.com/repositories/test.git

reference materials: