LoginSignup
5
5

More than 5 years have passed since last update.

Docker使って環境構築してみた

Posted at

本投降は個人的なメモな為、必ず上手くいくとは限りませんのでご注意ください

ホスト

  • mac OS X El Capitan (2016/9/20時点 10.11.6)
  • docker for mac(2016/9/20時点 1.12.1で多分最新)

ゲスト

使い方

  • 基本的にdocker pullしてrunするだけ。docker使ったことない人はググってください(;゚∀゚)
  • docker execして中に入り、/var/www/html/内にあるindex.php/var/www/に移動
  • docker runした時に指定したポートでloclahost:8081のようにwebブラウザで開く
  • phpinfoが出ればok

カスタマイズ

  • まず、データが残らないので、docker runオプションの-vで任意のディレクトリをマウントします。

    • 因みに、~/hoge/hogeのようにフルパスじゃないと何故かマウントされませんので注意
  • nginxの設定を変更する やったことだけ記載

    • nginxのuserを作成
groupadd nginx
useradd -g nginx nginx
usermod -s /bin/false nginx
  • 出来上がったnginx.conf(/etc/nginx/nginx.confを直接書き換え)
# user www-data;
user nginx;
worker_processes auto;
pid /run/nginx.pid;
worker_rlimit_nofile 196605;

events {
        # worker_connections 768;
        worker_connections 65535;
        multi_accept on;
        use epoll;
        accept_mutex_delay 100ms;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        # keepalive_timeout 65;
        keepalive_timeout 120;
        keepalive_requests 20;
        types_hash_max_size 2048;
        server_tokens off;
        charset UTF-8;
        client_header_timeout 120;
        client_body_timeout 120;
        limit_conn_zone $binary_remote_addr zone=addr:10m;
        limit_conn  addr  100;
        open_file_cache max=100 inactive=20s;
"/etc/nginx/nginx.conf" 113L, 2190C                                                                                        2,1           Top
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}
daemon off;
  • /etc/nginx/site-enabled/defaultもphalcon用に書き換えておく
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/store/public;

    index index.php index.html;

    server_name _;

    access_log /var/log/nginx/default.access.log;
    error_log /var/log/nginx/default.error.log;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}
  • php-fpmのconfigも書き換え
    • /etc/php/7.0/fpm/pool.d/www.confの中身を書き換え
    • userとgroupをwww-dataからnginxに書き換え
    • listen.ownerとlisten.groupもnginxに書き換え

上記まで行えばとりあえず、phalconの本家チュートリアルのCongratulations!までは出るはず

とりあえずはここまで。以降チュートリアルやりつつ、更新していきます。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5