LoginSignup
1
3

More than 5 years have passed since last update.

オフライン環境へのnginx導入手順

Last updated at Posted at 2017-12-24

構築手順

1.インターネット環境がある端末で、nginx公式HPより最新版のtar.gzファイルをダウンロードする。(http://nginx.org/en/download.html)
2.インストール時にPCREとzlibのライブラリがないと怒られるはずなので、あらかじめダウンロードしておく

yum install --downloadonly --downloaddir=~/hogehoge pcre-devel
yum install --downloadonly --downloaddir=~/hogehoge zlib-devel

3.オフライン環境に上記資材を持ってくる
4.下記コマンドでnginxを導入する

yum localinstall pcre-devel.rpm
yum localinstall zlib-devel.rpm
tar zxvf nginx-1.13.7.tar.gz
cd nginx-1.13.7
./configure
make
make install

bash_profileにnginxのパスを通す。

bash_profile
vi ~/.bash_profile
export PATH=$PATH:/usr/local/nginx/sbin
source ~/.bash_profile

5.nginx -Vでバージョン確認
6.下記URLよりRedHat用のinitスクリプトを取得し、/ete/init.d/nginxファイルとして保存する(実行権限を付与すること)
https://www.nginx.com/resources/wiki/start/topics/examples/initscripts/
7.起動・終了

# 起動
nginx
ps -ef | grep [n]ginx # プロセスの確認

# 終了
nginx -s stop

# 再起動
nginx -s reload

webブラウザでlocalhostにアクセスし、Welcome to nginx! の確認用ページが表示されれば成功。

備忘

デフォルトのルートディレクトリは下記
/usr/local/nginx/html

デフォルトルート配下のファイルインデックスを表示させる設定

/usr/local/nginx/conf/nginx.conf

# conf内の下記記述部分のautoindex on; を追記すればよい

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
            autoindex on; # この記述を追加する
        }
1
3
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
1
3