Skip to content

Instantly share code, notes, and snippets.

@sdn0303
Last active December 23, 2017 14:50

Revisions

  1. David Soichi Nakahashi revised this gist Dec 23, 2017. 4 changed files with 29 additions and 0 deletions.
    1 change: 1 addition & 0 deletions [.bash_profile]
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    alias brew="env PATH=${PATH/\/home\/vagrant\/\.pyenv\/shims:/} brew"
    24 changes: 24 additions & 0 deletions file25.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    [vagrant@localhost vagrant]$ brew doctor
    Please note that these warnings are just used to help the Homebrew maintainers
    with debugging if you file an issue. If everything you use Homebrew for is
    working fine: please don't worry and just ignore them. Thanks!

    Warning: python is symlinked to python3
    This will confuse build scripts and in general lead to subtle breakage.

    Warning: "config" scripts exist outside your system or Homebrew directories.
    `./configure` scripts often look for *-config scripts to determine if
    software packages are installed, and what additional flags to use when
    compiling and linking.

    Having additional scripts in your path can confuse software installed via
    Homebrew if the config script overrides a system or Homebrew provided
    script of the same name. We found the following "config" scripts:
    /home/vagrant/.pyenv/shims/icu-config
    /home/vagrant/.pyenv/shims/libpng16-config
    /home/vagrant/.pyenv/shims/ncursesw6-config
    /home/vagrant/.pyenv/shims/pcre-config
    /home/vagrant/.pyenv/shims/python-config
    /home/vagrant/.pyenv/shims/python3-config
    /home/vagrant/.pyenv/shims/python3.6-config
    /home/vagrant/.pyenv/shims/python3.6m-config
    1 change: 1 addition & 0 deletions file26.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    [vagrant@localhost vagrant]$ vim ~/.bash_profile
    3 changes: 3 additions & 0 deletions file28.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    [vagrant@localhost vagrant]$ source ~/.bash_profile
    [vagrant@localhost vagrant]$ brew doctor
    Your system is ready to brew.
  2. David Soichi Nakahashi revised this gist Dec 9, 2017. 21 changed files with 195 additions and 192 deletions.
    5 changes: 5 additions & 0 deletions Vagrantfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    ・・・
    - 35 # config.vm.network "private_network", ip: "192.168.33.10"

    + 35 config.vm.network "private_network", ip: "192.168.33.10"
    ・・・
    15 changes: 15 additions & 0 deletions default.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    # default.confの中身を↓に修正
    server {
    listen 80;
    server_name 192.168.33.10;
    charset utf-8;
    location / {
    proxy_pass http://0.0.0.0:8000;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/html;
    }
    }
    57 changes: 5 additions & 52 deletions file10.txt
    Original file line number Diff line number Diff line change
    @@ -1,53 +1,6 @@
    [vagrant@localhost conf.d]$ cd ../

    [vagrant@localhost nginx]$ sudo vi nginx.conf

    # nginx.confを↓に修正(*実際には動かすサービスに合った設定にする)

    user nginx;
    worker_processes auto;

    error_log /var/log/nginx/error.log warn;
    pid /var/run/nginx.pid;


    events {
    worker_connections 1024;
    }


    http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    '$status $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';
    server_tokens off;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    access_log off;
    error_log /var/log/nginx/error.log crit;
    keepalive_timeout 10;
    client_header_timeout 10;
    client_body_timeout 10;
    reset_timedout_connection on;
    send_timeout 10;
    limit_conn_zone $binary_remote_addr zone=addr:5m;
    limit_conn addr 100;
    charset UTF-8;
    gzip on;
    gzip_http_version 1.0;
    gzip_disable "msie6";
    gzip_proxied any;
    gzip_min_length 1024;
    gzip_comp_level 6;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/json;
    open_file_cache max=100000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;
    include /etc/nginx/conf.d/*.conf;
    }
    [vagrant@localhost ~]$ echo "export PATH="/usr/local/Cellar/git/{version}/bin:$PATH"" >> ~/.bash_profile

    # バージョン確認
    [vagrant@localhost ~]$ git version
    2.15.1
    ↑インストールしたバージョンになればok
    35 changes: 2 additions & 33 deletions file11.txt
    Original file line number Diff line number Diff line change
    @@ -1,33 +1,2 @@
    # 起動
    [vagrant@localhost nginx]$ sudo systemctl start nginx

    # 自動起動
    [vagrant@localhost nginx]$ sudo systemctl enable nginx

    # ステータス確認
    [vagrant@localhost nginx]$ sudo systemctl status nginx
    nginx.service - nginx - high performance web server
    Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled)
    Active: active (running) since 土 2017-12-09 14:47:15 UTC; 7s ago
    Docs: http://nginx.org/en/docs/
    Process: 1767 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
    Main PID: 1769 (nginx)
    CGroup: /system.slice/nginx.service
    ├─1769 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
    └─1770 nginx: worker process

    12月 09 14:47:15 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
    12月 09 14:47:15 localhost.localdomain nginx[1767]: nginx: [warn] duplicate MIME type "application/json" in /etc/nginx/nginx.conf:41
    12月 09 14:47:15 localhost.localdomain systemd[1]: PID file /var/run/nginx.pid not readable (yet?) after start.
    12月 09 14:47:15 localhost.localdomain systemd[1]: Started nginx - high performance web server.

    # ホームディレクトリに戻る
    [vagrant@localhost nginx]$ cd

    ----------------------------------------------------

    # 再起動をかける場合は
    $ sudo systemctl restart nginx

    # または
    $ sudo systemctl reload nginx
    [vagrant@localhost ~]$ sudo systemctl stop firewalld
    [vagrant@localhost ~]$ sudo systemctl disable firewalld
    39 changes: 1 addition & 38 deletions file12.txt
    Original file line number Diff line number Diff line change
    @@ -1,38 +1 @@
    [vagrant@localhost ~]$ brew install pyenv
    [vagrant@localhost ~]$ pyenv -v
    pyenv 1.1.5

    # pathを通す
    [vagrant@localhost ~]$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
    [vagrant@localhost ~]$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
    [vagrant@localhost ~]$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile

    # .bash_profile再読み込み
    [vagrant@localhost ~]$ source ~/.bash_profile

    # インストール可能なバージョン一覧を確認
    [vagrant@localhost ~]$ pyenv install --list

    # 使いたいバージョンをインストール
    [vagrant@localhost ~]$ pyenv install anaconda3-5.0.0

    # グローバル環境を3系に変更してバージョンを確認
    [vagrant@localhost ~]$ pyenv global anaconda3-5.0.0
    [vagrant@localhost ~]$ pyenv versions
    system
    * anaconda3-5.0.0 (set by /home/vagrant/.pyenv/version)

    # 特定のディレクトリのみ3系にする場合
    $ cd hoge
    $ pyenv local anaconda3-5.0.0

    # ターミナル再起動
    [vagrant@localhost ~]$ exec $SHELL -l

    # Pythonバージョン確認
    [vagrant@localhost ~]$ python -V

    # もしバージョンが変わらない場合は一旦exitしてvagrantを再起動する
    [vagrant@localhost ~]$ exit
    $ vagrant reload
    $ vagrant ssh
    [vagrant@localhost ~]$ sudo vi /etc/yum.repos.d/nginx.repo
    6 changes: 6 additions & 0 deletions file14.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    # nginxインストール
    [vagrant@localhost ~]$ sudo yum install -y nginx

    # 確認
    [vagrant@localhost ~]$ nginx -v
    nginx version: nginx/1.13.7
    7 changes: 2 additions & 5 deletions file15.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,2 @@
    # gunicorn経由でapiをバックグラウンド起動させる
    [vagrant@localhost vagrant]$ gunicorn -b 0.0.0.0:8000 sample_api:app &

    # プロセス確認
    [vagrant@localhost vagrant]$ ps aux | grep gunicorn
    [vagrant@localhost ~]$ cd /etc/nginx/conf.d
    [vagrant@localhost conf.d]$ sudo vi default.conf
    2 changes: 2 additions & 0 deletions file17.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    [vagrant@localhost conf.d]$ cd ../
    [vagrant@localhost nginx]$ sudo vi nginx.conf
    25 changes: 25 additions & 0 deletions file19.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    # 起動
    [vagrant@localhost nginx]$ sudo systemctl start nginx

    # 自動起動
    [vagrant@localhost nginx]$ sudo systemctl enable nginx

    # ステータス確認
    [vagrant@localhost nginx]$ sudo systemctl status nginx
    nginx.service - nginx - high performance web server
    Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled)
    Active: active (running) since 土 2017-12-09 14:47:15 UTC; 7s ago
    Docs: http://nginx.org/en/docs/
    Process: 1767 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
    Main PID: 1769 (nginx)
    CGroup: /system.slice/nginx.service
    ├─1769 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
    └─1770 nginx: worker process

    12月 09 14:47:15 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
    12月 09 14:47:15 localhost.localdomain nginx[1767]: nginx: [warn] duplicate MIME type "application/json" in /etc/nginx/nginx.conf:41
    12月 09 14:47:15 localhost.localdomain systemd[1]: PID file /var/run/nginx.pid not readable (yet?) after start.
    12月 09 14:47:15 localhost.localdomain systemd[1]: Started nginx - high performance web server.

    # ホームディレクトリに戻る
    [vagrant@localhost nginx]$ cd
    5 changes: 5 additions & 0 deletions file20.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # 再起動をかける場合は
    $ sudo systemctl restart nginx

    # または
    $ sudo systemctl reload nginx
    38 changes: 38 additions & 0 deletions file21.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    [vagrant@localhost ~]$ brew install pyenv
    [vagrant@localhost ~]$ pyenv -v
    pyenv 1.1.5

    # pathを通す
    [vagrant@localhost ~]$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
    [vagrant@localhost ~]$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
    [vagrant@localhost ~]$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile

    # .bash_profile再読み込み
    [vagrant@localhost ~]$ source ~/.bash_profile

    # インストール可能なバージョン一覧を確認
    [vagrant@localhost ~]$ pyenv install --list

    # 使いたいバージョンをインストール
    [vagrant@localhost ~]$ pyenv install anaconda3-5.0.0

    # グローバル環境を3系に変更してバージョンを確認
    [vagrant@localhost ~]$ pyenv global anaconda3-5.0.0
    [vagrant@localhost ~]$ pyenv versions
    system
    * anaconda3-5.0.0 (set by /home/vagrant/.pyenv/version)

    # 特定のディレクトリのみ3系にする場合
    $ cd hoge
    $ pyenv local anaconda3-5.0.0

    # ターミナル再起動
    [vagrant@localhost ~]$ exec $SHELL -l

    # Pythonバージョン確認
    [vagrant@localhost ~]$ python -V

    # もしバージョンが変わらない場合は一旦exitしてvagrantを再起動する
    [vagrant@localhost ~]$ exit
    $ vagrant reload
    $ vagrant ssh
    11 changes: 11 additions & 0 deletions file22.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # /vagrant は共有ディレクトリで最初にローカルで作ったCentos7ディレクトリと同期している
    [vagrant@localhost ~]$ cd /vagrant

    # gunicornインストール
    [vagrant@localhost vagrant]$ pip install gunicorn

    # pyramidインストール
    [vagrant@localhost vagrant]$ pip install pyramid

    # サンプルapi作成
    [vagrant@localhost vagrant]$ sudo vi sample_api.py
    5 changes: 5 additions & 0 deletions file24.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # gunicorn経由でapiをバックグラウンド起動させる
    [vagrant@localhost vagrant]$ gunicorn -b 0.0.0.0:8000 sample_api:app &

    # プロセス確認
    [vagrant@localhost vagrant]$ ps aux | grep gunicorn
    6 changes: 0 additions & 6 deletions file3.txt
    Original file line number Diff line number Diff line change
    @@ -1,7 +1 @@
    $ vim Vagrantfile

    ・・・
    - 35 # config.vm.network "private_network", ip: "192.168.33.10"

    + 35 config.vm.network "private_network", ip: "192.168.33.10"
    ・・・
    11 changes: 10 additions & 1 deletion file5.txt
    Original file line number Diff line number Diff line change
    @@ -1 +1,10 @@
    [vagrant@localhost ~]$ sudo yum groupinstall 'Development Tools' && sudo yum install ruby curl file git python-setuptools openssl-devel
    # vagrant立ち上げる
    $ vagrant up

    # 立ち上がったらsshで入る
    $ vagrant ssh
    Welcome to your Vagrant-built virtual machine.
    [vagrant@localhost ~]$

    # yum update
    [vagrant@localhost ~]$ sudo yum update
    23 changes: 1 addition & 22 deletions file6.txt
    Original file line number Diff line number Diff line change
    @@ -1,22 +1 @@
    [vagrant@localhost ~]$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

    # PATHを通す(linubrewインストール完了時のターミナルに出るPathセットアップのガイドに沿って追加)
    [vagrant@localhost ~]$ echo "export PATH="$HOME/.linuxbrew/bin:$PATH"" >> ~/.bash_profile
    [vagrant@localhost ~]$ echo "export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"" >> ~/.bash_profile
    [vagrant@localhost ~]$ echo "export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"" >> ~/.bash_profile


    # .bash_profile再読み込み
    [vagrant@localhost ~]$ source ~/.bash_profile

    # brewでgitをインストール
    [vagrant@localhost ~]$ brew install gcc
    [vagrant@localhost ~]$ brew install git

    # gitのpathを通す({version}にbrewでインストールしたgitのバージョンを置き換えてください)
    [vagrant@localhost ~]$ echo "export PATH="/usr/local/Cellar/git/{version}/bin:$PATH"" >> ~/.bash_profile

    # バージョン確認
    [vagrant@localhost ~]$ git version
    2.15.1
    ↑インストールしたバージョンになればok
    [vagrant@localhost ~]$ sudo yum groupinstall 'Development Tools' && sudo yum install ruby curl file git python-setuptools openssl-devel
    3 changes: 1 addition & 2 deletions file7.txt
    Original file line number Diff line number Diff line change
    @@ -1,2 +1 @@
    [vagrant@localhost ~]$ sudo systemctl stop firewalld
    [vagrant@localhost ~]$ sudo systemctl disable firewalld
    [vagrant@localhost ~]$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
    19 changes: 5 additions & 14 deletions file8.txt
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,6 @@
    [vagrant@localhost ~]$ sudo vi /etc/yum.repos.d/nginx.repo
    [vagrant@localhost ~]$ echo "export PATH="$HOME/.linuxbrew/bin:$PATH"" >> ~/.bash_profile
    [vagrant@localhost ~]$ echo "export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"" >> ~/.bash_profile
    [vagrant@localhost ~]$ echo "export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"" >> ~/.bash_profile

    # ↓をコピペして保存
    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
    gpgcheck=0
    enabled=1

    # nginxインストール
    [vagrant@localhost ~]$ sudo yum install -y nginx

    # 確認
    [vagrant@localhost ~]$ nginx -v
    nginx version: nginx/1.13.7
    # .bash_profile再読み込み
    [vagrant@localhost ~]$ source ~/.bash_profile
    21 changes: 2 additions & 19 deletions file9.txt
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,2 @@
    [vagrant@localhost ~]$ cd /etc/nginx/conf.d

    [vagrant@localhost conf.d]$ sudo vi default.conf

    # default.confの中身を↓に修正
    server {
    listen 80;
    server_name 192.168.33.10;
    charset utf-8;
    location / {
    proxy_pass http://0.0.0.0:8000;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/html;
    }
    }
    [vagrant@localhost ~]$ brew install gcc
    [vagrant@localhost ~]$ brew install git
    48 changes: 48 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    # nginx.confを↓に修正(*実際には動かすサービスに合った設定にする)

    user nginx;
    worker_processes auto;

    error_log /var/log/nginx/error.log warn;
    pid /var/run/nginx.pid;


    events {
    worker_connections 1024;
    }


    http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    '$status $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';
    server_tokens off;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    access_log off;
    error_log /var/log/nginx/error.log crit;
    keepalive_timeout 10;
    client_header_timeout 10;
    client_body_timeout 10;
    reset_timedout_connection on;
    send_timeout 10;
    limit_conn_zone $binary_remote_addr zone=addr:5m;
    limit_conn addr 100;
    charset UTF-8;
    gzip on;
    gzip_http_version 1.0;
    gzip_disable "msie6";
    gzip_proxied any;
    gzip_min_length 1024;
    gzip_comp_level 6;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/json;
    open_file_cache max=100000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;
    include /etc/nginx/conf.d/*.conf;
    }
    6 changes: 6 additions & 0 deletions nginx.repo
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    # ↓をコピペして保存
    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
    gpgcheck=0
    enabled=1
  3. David Soichi Nakahashi revised this gist Dec 9, 2017. 15 changed files with 0 additions and 29 deletions.
    2 changes: 0 additions & 2 deletions file0.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,3 @@

    $ mkdir -p Vagrant/Centos7

    $ cd ~/Vagrant/Centos7

    2 changes: 0 additions & 2 deletions file1.txt
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,6 @@

    # vagrant box add {vagrantのbox名} {boxのURL}を指定してDL
    $ vagrant box add centos7.1 https://github.com/CommanderK5/packer-centos-template/releases/download/0.7.1/vagrant-centos-7.1.box

    # 確認
    $ vagrant box list
    centos7.1 (virtualbox, 0)

    1 change: 0 additions & 1 deletion file10.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    [vagrant@localhost conf.d]$ cd ../

    [vagrant@localhost nginx]$ sudo vi nginx.conf
    2 changes: 0 additions & 2 deletions file11.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    # 起動
    [vagrant@localhost nginx]$ sudo systemctl start nginx

    @@ -32,4 +31,3 @@ $ sudo systemctl restart nginx

    # または
    $ sudo systemctl reload nginx

    2 changes: 0 additions & 2 deletions file12.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    [vagrant@localhost ~]$ brew install pyenv
    [vagrant@localhost ~]$ pyenv -v
    pyenv 1.1.5
    @@ -37,4 +36,3 @@ $ pyenv local anaconda3-5.0.0
    [vagrant@localhost ~]$ exit
    $ vagrant reload
    $ vagrant ssh

    2 changes: 0 additions & 2 deletions file13.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    # /vagrant は共有ディレクトリで最初にローカルで作ったCentos7ディレクトリと同期している
    [vagrant@localhost ~]$ cd /vagrant

    @@ -10,4 +9,3 @@

    # サンプルapi作成
    [vagrant@localhost vagrant]$ sudo vi sample_api.py

    2 changes: 0 additions & 2 deletions file15.txt
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,5 @@

    # gunicorn経由でapiをバックグラウンド起動させる
    [vagrant@localhost vagrant]$ gunicorn -b 0.0.0.0:8000 sample_api:app &

    # プロセス確認
    [vagrant@localhost vagrant]$ ps aux | grep gunicorn

    2 changes: 0 additions & 2 deletions file2.txt
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,6 @@

    # 使用したいボックス名を指定してinit
    $ vagrant init centos7.1

    # するとVagrantfileが生成される
    $ ls
    Vagrantfile

    2 changes: 0 additions & 2 deletions file3.txt
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,7 @@

    $ vim Vagrantfile

    ・・・
    - 35 # config.vm.network "private_network", ip: "192.168.33.10"

    + 35 config.vm.network "private_network", ip: "192.168.33.10"
    ・・・

    2 changes: 0 additions & 2 deletions file4.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    # vagrant立ち上げる
    $ vagrant up

    @@ -9,4 +8,3 @@ Welcome to your Vagrant-built virtual machine.

    # yum update
    [vagrant@localhost ~]$ sudo yum update

    2 changes: 0 additions & 2 deletions file5.txt
    Original file line number Diff line number Diff line change
    @@ -1,3 +1 @@

    [vagrant@localhost ~]$ sudo yum groupinstall 'Development Tools' && sudo yum install ruby curl file git python-setuptools openssl-devel

    2 changes: 0 additions & 2 deletions file6.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    [vagrant@localhost ~]$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

    # PATHを通す(linubrewインストール完了時のターミナルに出るPathセットアップのガイドに沿って追加)
    @@ -21,4 +20,3 @@
    [vagrant@localhost ~]$ git version
    2.15.1
    ↑インストールしたバージョンになればok

    2 changes: 0 additions & 2 deletions file7.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,2 @@

    [vagrant@localhost ~]$ sudo systemctl stop firewalld
    [vagrant@localhost ~]$ sudo systemctl disable firewalld

    2 changes: 0 additions & 2 deletions file8.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    [vagrant@localhost ~]$ sudo vi /etc/yum.repos.d/nginx.repo

    # ↓をコピペして保存
    @@ -14,4 +13,3 @@ enabled=1
    # 確認
    [vagrant@localhost ~]$ nginx -v
    nginx version: nginx/1.13.7

    2 changes: 0 additions & 2 deletions file9.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    [vagrant@localhost ~]$ cd /etc/nginx/conf.d

    [vagrant@localhost conf.d]$ sudo vi default.conf
    @@ -18,4 +17,3 @@ server {
    root /usr/share/nginx/html;
    }
    }

  4. David Soichi Nakahashi created this gist Dec 9, 2017.
    5 changes: 5 additions & 0 deletions file0.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@

    $ mkdir -p Vagrant/Centos7

    $ cd ~/Vagrant/Centos7

    8 changes: 8 additions & 0 deletions file1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@

    # vagrant box add {vagrantのbox名} {boxのURL}を指定してDL
    $ vagrant box add centos7.1 https://github.com/CommanderK5/packer-centos-template/releases/download/0.7.1/vagrant-centos-7.1.box

    # 確認
    $ vagrant box list
    centos7.1 (virtualbox, 0)

    54 changes: 54 additions & 0 deletions file10.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@

    [vagrant@localhost conf.d]$ cd ../

    [vagrant@localhost nginx]$ sudo vi nginx.conf

    # nginx.confを↓に修正(*実際には動かすサービスに合った設定にする)

    user nginx;
    worker_processes auto;

    error_log /var/log/nginx/error.log warn;
    pid /var/run/nginx.pid;


    events {
    worker_connections 1024;
    }


    http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    '$status $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';
    server_tokens off;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    access_log off;
    error_log /var/log/nginx/error.log crit;
    keepalive_timeout 10;
    client_header_timeout 10;
    client_body_timeout 10;
    reset_timedout_connection on;
    send_timeout 10;
    limit_conn_zone $binary_remote_addr zone=addr:5m;
    limit_conn addr 100;
    charset UTF-8;
    gzip on;
    gzip_http_version 1.0;
    gzip_disable "msie6";
    gzip_proxied any;
    gzip_min_length 1024;
    gzip_comp_level 6;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/json;
    open_file_cache max=100000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;
    include /etc/nginx/conf.d/*.conf;
    }

    35 changes: 35 additions & 0 deletions file11.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@

    # 起動
    [vagrant@localhost nginx]$ sudo systemctl start nginx

    # 自動起動
    [vagrant@localhost nginx]$ sudo systemctl enable nginx

    # ステータス確認
    [vagrant@localhost nginx]$ sudo systemctl status nginx
    nginx.service - nginx - high performance web server
    Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled)
    Active: active (running) since 土 2017-12-09 14:47:15 UTC; 7s ago
    Docs: http://nginx.org/en/docs/
    Process: 1767 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
    Main PID: 1769 (nginx)
    CGroup: /system.slice/nginx.service
    ├─1769 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
    └─1770 nginx: worker process

    12月 09 14:47:15 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
    12月 09 14:47:15 localhost.localdomain nginx[1767]: nginx: [warn] duplicate MIME type "application/json" in /etc/nginx/nginx.conf:41
    12月 09 14:47:15 localhost.localdomain systemd[1]: PID file /var/run/nginx.pid not readable (yet?) after start.
    12月 09 14:47:15 localhost.localdomain systemd[1]: Started nginx - high performance web server.

    # ホームディレクトリに戻る
    [vagrant@localhost nginx]$ cd

    ----------------------------------------------------

    # 再起動をかける場合は
    $ sudo systemctl restart nginx

    # または
    $ sudo systemctl reload nginx

    40 changes: 40 additions & 0 deletions file12.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@

    [vagrant@localhost ~]$ brew install pyenv
    [vagrant@localhost ~]$ pyenv -v
    pyenv 1.1.5

    # pathを通す
    [vagrant@localhost ~]$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
    [vagrant@localhost ~]$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
    [vagrant@localhost ~]$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile

    # .bash_profile再読み込み
    [vagrant@localhost ~]$ source ~/.bash_profile

    # インストール可能なバージョン一覧を確認
    [vagrant@localhost ~]$ pyenv install --list

    # 使いたいバージョンをインストール
    [vagrant@localhost ~]$ pyenv install anaconda3-5.0.0

    # グローバル環境を3系に変更してバージョンを確認
    [vagrant@localhost ~]$ pyenv global anaconda3-5.0.0
    [vagrant@localhost ~]$ pyenv versions
    system
    * anaconda3-5.0.0 (set by /home/vagrant/.pyenv/version)

    # 特定のディレクトリのみ3系にする場合
    $ cd hoge
    $ pyenv local anaconda3-5.0.0

    # ターミナル再起動
    [vagrant@localhost ~]$ exec $SHELL -l

    # Pythonバージョン確認
    [vagrant@localhost ~]$ python -V

    # もしバージョンが変わらない場合は一旦exitしてvagrantを再起動する
    [vagrant@localhost ~]$ exit
    $ vagrant reload
    $ vagrant ssh

    13 changes: 13 additions & 0 deletions file13.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@

    # /vagrant は共有ディレクトリで最初にローカルで作ったCentos7ディレクトリと同期している
    [vagrant@localhost ~]$ cd /vagrant

    # gunicornインストール
    [vagrant@localhost vagrant]$ pip install gunicorn

    # pyramidインストール
    [vagrant@localhost vagrant]$ pip install pyramid

    # サンプルapi作成
    [vagrant@localhost vagrant]$ sudo vi sample_api.py

    7 changes: 7 additions & 0 deletions file15.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@

    # gunicorn経由でapiをバックグラウンド起動させる
    [vagrant@localhost vagrant]$ gunicorn -b 0.0.0.0:8000 sample_api:app &

    # プロセス確認
    [vagrant@localhost vagrant]$ ps aux | grep gunicorn

    8 changes: 8 additions & 0 deletions file2.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@

    # 使用したいボックス名を指定してinit
    $ vagrant init centos7.1

    # するとVagrantfileが生成される
    $ ls
    Vagrantfile

    9 changes: 9 additions & 0 deletions file3.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@

    $ vim Vagrantfile

    ・・・
    - 35 # config.vm.network "private_network", ip: "192.168.33.10"

    + 35 config.vm.network "private_network", ip: "192.168.33.10"
    ・・・

    12 changes: 12 additions & 0 deletions file4.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@

    # vagrant立ち上げる
    $ vagrant up

    # 立ち上がったらsshで入る
    $ vagrant ssh
    Welcome to your Vagrant-built virtual machine.
    [vagrant@localhost ~]$

    # yum update
    [vagrant@localhost ~]$ sudo yum update

    3 changes: 3 additions & 0 deletions file5.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@

    [vagrant@localhost ~]$ sudo yum groupinstall 'Development Tools' && sudo yum install ruby curl file git python-setuptools openssl-devel

    24 changes: 24 additions & 0 deletions file6.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@

    [vagrant@localhost ~]$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

    # PATHを通す(linubrewインストール完了時のターミナルに出るPathセットアップのガイドに沿って追加)
    [vagrant@localhost ~]$ echo "export PATH="$HOME/.linuxbrew/bin:$PATH"" >> ~/.bash_profile
    [vagrant@localhost ~]$ echo "export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"" >> ~/.bash_profile
    [vagrant@localhost ~]$ echo "export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"" >> ~/.bash_profile


    # .bash_profile再読み込み
    [vagrant@localhost ~]$ source ~/.bash_profile

    # brewでgitをインストール
    [vagrant@localhost ~]$ brew install gcc
    [vagrant@localhost ~]$ brew install git

    # gitのpathを通す({version}にbrewでインストールしたgitのバージョンを置き換えてください)
    [vagrant@localhost ~]$ echo "export PATH="/usr/local/Cellar/git/{version}/bin:$PATH"" >> ~/.bash_profile

    # バージョン確認
    [vagrant@localhost ~]$ git version
    2.15.1
    ↑インストールしたバージョンになればok

    4 changes: 4 additions & 0 deletions file7.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@

    [vagrant@localhost ~]$ sudo systemctl stop firewalld
    [vagrant@localhost ~]$ sudo systemctl disable firewalld

    17 changes: 17 additions & 0 deletions file8.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@

    [vagrant@localhost ~]$ sudo vi /etc/yum.repos.d/nginx.repo

    # ↓をコピペして保存
    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
    gpgcheck=0
    enabled=1

    # nginxインストール
    [vagrant@localhost ~]$ sudo yum install -y nginx

    # 確認
    [vagrant@localhost ~]$ nginx -v
    nginx version: nginx/1.13.7

    21 changes: 21 additions & 0 deletions file9.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@

    [vagrant@localhost ~]$ cd /etc/nginx/conf.d

    [vagrant@localhost conf.d]$ sudo vi default.conf

    # default.confの中身を↓に修正
    server {
    listen 80;
    server_name 192.168.33.10;
    charset utf-8;
    location / {
    proxy_pass http://0.0.0.0:8000;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/html;
    }
    }

    20 changes: 20 additions & 0 deletions sample_api.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    # -*- Coding: UTF-8 -*-
    from pyramid.config import Configurator
    from pyramid.response import Response


    def hello_world(request):
    return Response('Hello %(name)s!' % request.matchdict)


    with Configurator() as config:
    config.add_route('hello', '/hello/{name}')
    config.add_view(hello_world, route_name='hello')
    app = config.make_wsgi_app()

    if __name__ == '__main__':
    from wsgiref.simple_server import make_server
    httpd = make_server('', 8000, app)
    httpd.server_forever()
    print('Serving on port 8000...')