43
43

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vagrantで作ったローカル環境(centOS)にnginxを導入してみた

Last updated at Posted at 2014-08-14

前提条件
 vagrantをインストール済み
 自分の作業ディレクトリへ移動済み

vagrant環境構築

・Vagrantfileファイル作成

vagrant init

・Vagrantfile編集

vi Vagrantfile
config.vm.box = "base"
↓上記を下記の様に変更(vagrant box listで表示される中にあるもの)
config.vm.box = "centos6.5-64"

# config.vm.network :private_network, ip: "192.168.33.10"
↓上記を下記の様に変更
config.vm.network :private_network, ip: "192.168.33.15

vagrant up

vagrant ssh

・ipアドレスの確認


ifconfig

inet addr:192.168.33.15

exit;

nginxの導入

・nginxインストール

vagrant ssh
sudo su - 
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
yum install nginx
/etc/init.d/nginx start

・webブラウザで確認

http://192.168.33.15/
※「Welcome to nginx」 が表示されるはず

おまけ

・DocumentRootの変更

# /etc/nginx/conf.d/default.confを編集。
vi /etc/nginx/conf.d/default.conf
"/usr/share/nginx/html"
↓上記を下記の様に変更
"/var/www/html"
var配下が存在しないので、自分で作る
cd /var
mkdir www
cd www
mkdir html
cd html
vi index.html

/etc/init.d/nginx restart

・webブラウザで確認

http://192.168.33.15/
index.htmlの内容が表示される。

さらにおまけってか、メモ

・自動起動の設定の参考サイト

http://qiita.com/kkyouhei/items/c313953c6a027bab5855

・ログ情報

/var/log/nginx
access.log
error.log

・起動と停止

/etc/init.d/nginx start
/etc/init.d/nginx stop

参考サイト
・vagrant
http://www.absolute-keitarou.net/blog/?p=579#IP

・nginx
http://tejunsho.com/nginx/20140207000183.html

43
43
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
43
43

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?