AWS / PHP / Python ちょいメモ

amazon web service , PHP, Python を使ったときのメモ。日本語でググってもわからなかった事を中心に。

Jenkins 動作ポート, Listen IP変更方法

Jenkins を 開発サーバにあげたときのメモ。

公開してる開発サーバにJenkinsをいれたのだけど、別に外からアクセス出来なくてもいいよなぁと思い、SSHトンネル経由で Port Forward して利用することに。その際やりたかったことをメモ。

環境:

インストール内容確認

次のコマンドで、apt-getでインストールされたファイルを確認:

$ dpkg -L jenkins
...
/etc/default/jenkins
...
/etc/init.d/jenkins
...

続きを読む

VirtualBox の 共有フォルダ に シンボリックリンク利用はさける

今回は、これだけ。

Windowsホスト上のシンボリックリンクを、VirtualBoxの共有フォルダー として設定しないでおこう。」

vagrant 1.9.2 + VairutalBox 5.1.18 on Win10Pro(x64) の環境で遭遇。


指定してしまった時のエラー

==> host1: Mounting shared folders...
host1: /vagrant => C:/work/_ansible_sym
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant

The error output from the command was:

/sbin/mount.vboxsf: mounting failed with the error: Invalid argument


Win上でシンボリックリンク(正確には、今回はジャンクション)を使った理由は、まとめてGitで管理を始めたので作業フォルダと分けようと思ったから。Invalid argument だと対応に時間がかかるので、Symbolic Link does not support とかがいいかも。

参考

vagrant オフィシャル

Symbolic Links
Support for symbolic links across synced folder implementations and host/guest combinations is not consistent

WinのVM環境 : Hyper-V or VirtualBox

Win上の開発環境を検討していて、VirtualBoxHyper-Vって同居できないという事に気づいたのでメモ。

環境:

最終的に僕の場合は、Hyper-Vはインストール済みだが、BCDの編集で起動時にHyperVisorをOffにする事で通常はVirtualBoxを使うという状態を選択しました。

理由は vagrant 利用する場合 Hyper-V 対応のboxがほぼなかったという点につきます。本番想定では別ですが、開発環境という視点だと vagrant で box が利用できるのは大変助かるので。

続きを読む

Django での static files の扱い方まとめ (追加)

以前書いたPOST の中で避けてたw点、よい解決方法が見つかったのでメモ。

400.html, 500html などの動作確認を行いたいなーって思って。Django1.8.17で確認しました。


元POST : Django での static files の扱い方まとめ - AWS / PHP / Python ちょいメモ

ちなみに、開発サーバーでも、次の条件が揃うと、 {{ STATIC_URL }} が自動公開されなくなります。

settings.py : DEBUG="False" & ALLOWED_HOSTS = ['something'] のケース
settings.py : DEBUG="Ture" & runserver —nostaticオプション付 で起動
DEBUG="False"の時にも urls.py の設定で、static files を公開する方法もあり(ググってください)

DEBUG="False" の時に Static files を公開する簡単な方法:

$ python manage.py runserver --insecure

runserver に insecure オプションがあるんですね。

--insecure Allows serving static files even if DEBUG is False.

続きを読む

mod_wsgi は pip でも提供ありなのかぁ

今回 Ubuntu 14.04 に PPA を使って Python 3.5.x を導入したところ、PPAには mod_wsgi がないことに気づき対応策を調べた。

結果 pip で mod_wsgi が提供されてるといううれしい事実を発見し、無事に環境構築完了。

Ubuntu 14.04 だと オフィシャルのリポジトリでは Python3.4 が提供されてます

手順

インストール by pip
  1. 次のパッケージが apt でインストールされてることを確認
    • apache2
    • apache2-dev (apxs : APache eXtenSion tool が インストール時に必要)
  2. pip3 でインストール
    • pip3 install mod_wsgi
続きを読む