Nginx+git
gitインストール
# sudo apt-get install git
リポジトリ作成
# mkdir -p /var/git/repository/test.git # cd /var/git/repository/test.git # git --bare init --shared=group
コミット
# mkdir ~/test # cd ~/test # git init # echo "Hello git project" > README # git add . # git commit -m "test" # git push /var/git/repository/test.git master
nginx fcgiwrapインストール
# sudo apt-get install nginx fcgiwrap
Nginx設定
location /repository { # IP制限など allow XXX.XXX.XXX.XXX; deny all; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; fastcgi_param GIT_PROJECT_ROOT /var/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; }
hooks設定
# cd /var/git/repository/test.git # cp hooks/post-update.sample hooks/post-update # git update-server-info # git config http.receivepack true
fcgiwrapのソケットユーザをnginxにしておく
# vi /etc/init.d/fcgiwrap FCGI_SOCKET="/var/run/$NAME.socket"FCGI_USER="nginx" FCGI_GROUP="nginx" # Socket owner/group (will default to FCGI_USER/FCGI_GROUP if not defined) FCGI_SOCKET_OWNER="nginx" FCGI_SOCKET_GROUP="nginx"
再起動
# sudo /etc/init.d/fcgiwrap restart # sudo /etc/init.d/nginx restart
ローカルからgit clone
# git clone http://my_domain/repository/test.git
参考 http://serverfault.com/questions/334127/howto-nginx-git-http-backend-fcgiwrap-debian-squeeze http://zuqqhi2.com/?p=735
Nginxでオレオレ証明書
秘密鍵の作成
# openssl genrsa -out server.key -aes128 1024 Generating RSA private key, 1024 bit long modulus ..............++++++ ...........................................................................++++++ e is 65537 (0x10001) Enter pass phrase for server.key: Verifying - Enter pass phrase for server.key:
証明書署名要求ファイルの作成
# openssl req -new -key server.key -out my_domain.csr Enter pass phrase for server.key: You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:JP State or Province Name (full name) [Some-State]:Tokyo Locality Name (eg, city) :Shibuya Organization Name (eg, company) [Internet Widgits Pty Ltd]:my_domain Organizational Unit Name (eg, section) : Common Name (e.g. server FQDN or YOUR name) :my_domain Email Address :info@my_domain Please enter the following 'extra' attributes to be sent with your certificate request A challenge password : An optional company name :
証明書署名要求ファイルからサーバ証明書を作成
# openssl x509 -req -in my_domain.csr -signkey server.key -out my_domain.crt Signature ok subject=/C=JP/ST=Tokyo/L=Shibuya-ku/O=my_domain/CN=my_domain Getting Private key Enter pass phrase for server.key:
パスフレーズの入力回避
# cp -ip server.key server.key.bak # openssl rsa -in server.key.bak -out server.key Enter pass phrase for server.key.bak: writing RSA key
Nginx設定
server { listen 443 ssl; server_name my_domain; access_log /var/log/ssl.access.log main; ssl_certificate /etc/nginx/my_domain.crt; ssl_certificate_key /etc/nginx/server.key; ・・・
Nginx再起動、パスフレーズを求められなければよい。
# /etc/init.d/nginx restart
権限はrootのみにする。
# chmod 600 server.key
Ubuntu 12.04.4 にSubversion1.8をインストール
ソースリストを新規追加
# vi /etc/apt/sources.list.d/svn.list deb http://opensource.wandisco.com/ubuntu precise svn18
GPG keyの追加
# wget http://opensource.wandisco.com/wandisco-debian.gpg # sudo apt-key add wandisco-debian.gpg OK
パッケージリスト更新
# sudo apt-get update
Subversionインストール
# sudo apt-get install subversion
バージョン確認
# svn --version svn, version 1.8.8 (r1568071)
Nginxとphp-fpmの権限確認
WordPressのページからテーマをアップロードしようとしたときに表示された画面。
アップロードしたファイル xxxx.zip からテーマをインストールしています 接続情報 要求されたアクションを実行するには、WordPress が Web サーバーにアクセスする必要があります。 次に進むには FTP の接続情報を入力してください。 接続情報が思い出せない場合は、ホスティング担当者に問い合わせてください。
権限足りないだけかな?と思ったけど、 Nginxのユーザとphp-fpmのlisten.ownerがずれているかも。 DocumentRootの所有者はnginxでpfmはwww-dataになっている気がする。
vi /etc/nginx/nginx.conf user nginx nginx;
下記に修正する。
vi /etc/php5/fpm/pool.d/www.conf listen = /var/run/php-fpm/php-fpm.sock listen.owner = nginx listen.group = nginx listen.mode = 0666 user = nginx group = nginx
Nokogiriでスクレイピング
C:\>ruby -v ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
タイトルをスクレイピングして取得する。
#! ruby -Ku p "文字化けしないか確認しておく" require "open-uri" require "nokogiri" url = "http://snit.hatenadiary.jp/" charset = nil html = open(url) do |f| charset = f.charset f.read end doc = Nokogiri::HTML.parse(html, nil, charset) p doc.title
実行
C:\>ruby sample3.rb "文字化けしないか確認しておく" "snit21の日記"
最初の定義がないとそもそも日本語が文字化けする。
#! ruby -Ku
参考
http://ginzanomama.hatenablog.com/entry/2013/02/27/162828
http://morizyun.github.io/blog/ruby-nokogiri-scraping-tutorial