Skip to content

Instantly share code, notes, and snippets.

@saitodev
Last active December 21, 2015 00:29
Show Gist options
  • Save saitodev/6221124 to your computer and use it in GitHub Desktop.
Save saitodev/6221124 to your computer and use it in GitHub Desktop.
[ -e /tmp/work/nginx ] || mkdir -p /tmp/work/nginx
cd /tmp/work/nginx
# ユーザーの作成
sudo /usr/sbin/useradd -s /sbin/nologin -d /var/lib/nginx -c "Nginx web server" -M nginx
# nginxのダウンロードとビルド
wget http://nginx.org/download/nginx-1.4.3.tar.gz
tar zxf nginx-1.4.3.tar.gz
cd nginx-1.4.3
./configure \
--prefix=/usr/local \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi/ \
--http-scgi-temp-path=/var/tmp/nginx/scgi/
make
sudo make install
# 作業ディレクトリの作成
sudo mkdir /var/tmp/nginx
sudo mkdir /var/tmp/nginx/{proxy,client,fcgi,uwsgi,scgi}
# 設定ファイル用のディレクトリを作成
sudo mkdir /etc/nginx/{conf.d,sites-available,sites-enabled}
# 起動スクリプトのインストール
wget -O nginx https://gist.github.com/saitodev/6208944/raw/nginx
sudo cp nginx /etc/rc.d/init.d/nginx
sudo chmod 755 /etc/rc.d/init.d/nginx
sudo /sbin/chkconfig --add nginx
sudo /sbin/chkconfig nginx on
# logrotateの設定ファイルの作成
sudo tee /etc/logrotate.d/nginx > /dev/null <<'EOM'
/var/log/nginx/*log {
weekly
rotate 52
compress
delaycompress
missingok
notifempty
sharedscripts
postrotate
[ ! -f /var/run/nginx/nginx.pid ] || kill -USR1 `cat /var/run/nginx/nginx.pid`
endscript
}
EOM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment