logo

nginxでabした時にtoo many open filesになってしまった場合の対処

cd /etc/nginx/

cp -p nginx.conf nginx.conf.date +%Y%m%d

vi nginx.conf

— 追記 worker_rlimit_nofile 8192; <–ここ

events { worker_connections 1024; }

service nginx configtest

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful

service nginx resrart

ps aux | grep nginx

root 13282 0.0 0.0 44752 1172 ? Ss 18:58 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf nginx 13283 0.0 0.0 45204 1876 ? S 18:58 0:00 nginx: worker process nginx 13284 0.0 0.0 45204 1812 ? S 18:58 0:00 nginx: worker process nginx 13285 0.0 0.0 45204 1876 ? S 18:58 0:00 nginx: worker process nginx 13287 0.0 0.0 45204 1860 ? S 18:58 0:00 nginx: worker process

cat /proc/13287/limits

Max open files 8192 8192 files <– worker_rlimit_nofileで記述した値が上書きされていることがわかる。 参考URL:http://www.1x1.jp/blog/2013/02/nginx_too_many_open_files_error.html

2 minutes to read

nginxでIP制限をする

location / { if ( $acl = false ){ return 503; } } CIDR単位で指定する場合 [#bf4d4e29]

location /admin { if ( $acl = false ){ return 503; }

One minute to read

nginxでPHPを動かす

 ↓
 location   

.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /ドキュメントルート$fastcgi_script_name; include fastcgi_params; }

/etc/init.d/nginx configtest

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful

service nginx restart

4.テスト [#pd08ab79]

One minute to read

nginxでWordPressをサブディレクトリに設定する

    alias   /var/www/html/hogejp/test2;
    index  index.php;

     if (!-e $request_filename) {
        rewrite ^/test2(.+)$  /test2/index.php?q=$1 last;
        break;
    }

    location   

^/test2/.+.php$ { fastcgi_pass 127.0.0.1:9002; fastcgi_index index.php; fastcgi_split_path_info ^/jc8xzj(.+.php)(.*)$; fastcgi_param SCRIPT_FILENAME /var/www/html/hoge.jp/test2$fastcgi_script_name; fastcgi_intercept_errors on; include fastcgi_params; } }

One minute to read

nginxのインストール:redhat系

下記URLからリポジトリをダウンロードする。 [#x86ae1cd]

rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm

cd /etc/yum.repos.d/

ls -l

-rw-r–r– 1 root root 113 10月 14 19:04 2011 nginx.repo

yum install nginx

chkconfig –list nginx

nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off もしくは、下記を追加してnginxをインストールすればOK.

One minute to read