Last active
December 23, 2017 14:50
Revisions
-
David Soichi Nakahashi revised this gist
Dec 23, 2017 . 4 changed files with 29 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ alias brew="env PATH=${PATH/\/home\/vagrant\/\.pyenv\/shims:/} brew" This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ [vagrant@localhost vagrant]$ vim ~/.bash_profile This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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. -
David Soichi Nakahashi revised this gist
Dec 9, 2017 . 21 changed files with 195 additions and 192 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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" ・・・ This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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; } } This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,53 +1,6 @@ [vagrant@localhost ~]$ echo "export PATH="/usr/local/Cellar/git/{version}/bin:$PATH"" >> ~/.bash_profile # バージョン確認 [vagrant@localhost ~]$ git version 2.15.1 ↑インストールしたバージョンになればok This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,33 +1,2 @@ [vagrant@localhost ~]$ sudo systemctl stop firewalld [vagrant@localhost ~]$ sudo systemctl disable firewalld This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,38 +1 @@ [vagrant@localhost ~]$ sudo vi /etc/yum.repos.d/nginx.repo This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,2 @@ [vagrant@localhost ~]$ cd /etc/nginx/conf.d [vagrant@localhost conf.d]$ sudo vi default.conf This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ # 再起動をかける場合は $ sudo systemctl restart nginx # または $ sudo systemctl reload nginx This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1 @@ $ vim Vagrantfile This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,10 @@ # vagrant立ち上げる $ vagrant up # 立ち上がったらsshで入る $ vagrant ssh Welcome to your Vagrant-built virtual machine. [vagrant@localhost ~]$ # yum update [vagrant@localhost ~]$ sudo yum update This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,22 +1 @@ [vagrant@localhost ~]$ sudo yum groupinstall 'Development Tools' && sudo yum install ruby curl file git python-setuptools openssl-devel This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1 @@ [vagrant@localhost ~]$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)" This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,6 @@ [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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,2 @@ [vagrant@localhost ~]$ brew install gcc [vagrant@localhost ~]$ brew install git This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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; } This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 -
David Soichi Nakahashi revised this gist
Dec 9, 2017 . 15 changed files with 0 additions and 29 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,3 @@ $ mkdir -p Vagrant/Centos7 $ cd ~/Vagrant/Centos7 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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) This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,6 @@ # 使用したいボックス名を指定してinit $ vagrant init centos7.1 # するとVagrantfileが生成される $ ls Vagrantfile This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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" ・・・ This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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; } } -
David Soichi Nakahashi created this gist
Dec 9, 2017 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ $ mkdir -p Vagrant/Centos7 $ cd ~/Vagrant/Centos7 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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) This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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; } This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ # 使用したいボックス名を指定してinit $ vagrant init centos7.1 # するとVagrantfileが生成される $ ls Vagrantfile This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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" ・・・ This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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; } } This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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...')