nginx ¼³Ä¡¿À·ù

   Á¶È¸ 16454   Ãßõ 0    

[error] 14479#14479: *120 connect() failed (111: Connection refused) while connecting to upstream, client: ip주소, server: localhost, request: "GET /bbs/board.php?bo_table=g4_100 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "서버ip주소"


nginx 최근 버젼을 yum으로 설치하고

접속을 하려고 하니 다음과 같이 오류가 나옵니다.


php 7은 remi의 repo에서 yum으로 설치했구요.


어떻게 해야 할까요?

stackoverflow.com 의 답변들도 도움이 안되네요.


/etc/nginx/conf.d/default.conf


server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    location ~ \.php$ {
        proxy_pass   http://127.0.0.1;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        #root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {

- to be continue -
ªÀº±Û Àϼö·Ï ½ÅÁßÇÏ°Ô.
¿¡·¯ ·Î±×·Î¸¸ º¸ÀÚ¸é  php-fpm¿¡ ¿¬°áÀ» ¸øÇÑ´Ù´Â À̾߱â ÀÔ´Ï´Ù.
¸ÕÀú  php-fpmÀ» Àç½ÃÀÛÀ» Çغ¸½Ã°í 9000¹ø Æ÷Æ®°¡ Á¤»óÀûÀ¸·Î ¿¬°áµÇ´ÂÁö È®ÀÎÇغ¸½Ã±â ¹Ù¶ø´Ï´Ù.
Âü°í·Î php-fpmÀ» µ¿Àϼ­¹ö ·ÎÄÿ¡¼­¸¸ »ç¿ëÇϽŴٸé upstream À» tcp·Î ¿­Áö ¸¶½Ã°í ¼ÒÄÏÀ» ÀÌ¿ëÇϽô°ÍÀÌ ¼º´É¸é¿¡¼­ ÁÁ½À´Ï´Ù.
     
ȸ¿øK 2016-03
telnet> open localhost 9000
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

9000¹øÀº ¿¬°áµÇ°í ÀÖ´Â °Í °°½À´Ï´Ù.

# systemctl | grep php
php70-php-fpm.service                                                                              loaded active running  The PHP FastCGI Process Manager

php70-php-fpmµµ µ¿ÀÛÇÏ°í ÀÖ´Â °Í °°±¸¿ä
ȸ¿øK 2016-03
2016/03/20 22:56:44 [alert] 15458#15458: setrlimit(RLIMIT_NOFILE, 30000) failed (1: Operation not permitted)
2016/03/20 22:56:56 [alert] 15458#15458: *13176 socket() failed (24: Too many open files) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.0", upstream: "http://127.0.0.1:80/index.php", host: "127.0.0.1"
2016/03/20 22:56:56 [crit] 15458#15458: *13176 open() "/usr/share/nginx/html/50x.html" failed (24: Too many open files), client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.0", upstream: "http://127.0.0.1:80/index.php", host: "127.0.0.1"
2016/03/21 08:26:42 [alert] 1894#1894: setrlimit(RLIMIT_NOFILE, 30000) failed (1: Operation not permitted)
/etc/nginx/conf.d/default.conf
worker_rlimit_nofile 30000;
...
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
...


sysctl fs.file-max
fs.file-max = 70000

¿ä·¸°Ô Çغ¸½Ã¸é µÉ½Çµí.
     
ȸ¿øK 2016-03
worker_rlimit_nofile 30000;
--> /etc/nginx/nginx.conf ¿¡ ³Ö¾îÁ® ÀÖ½À´Ï´Ù.

/run/ ¹Ø¿¡ php µð·ºÅ丮°¡ ¾ø½À´Ï´Ù. -..-...

fileÀº os ·¹º§¿¡¼­ ¸¹ÀÌ ´Ã·Áµ×±¸¿ä.
À½..¿¡·¯·Î¸¸ º¸ÀÚ¸é file open limit¿¡ °É¸°µí ÇÕ´Ï´Ù ¾Æ´Ï¸é ÆÛ¹Ì¼Ç ¹®Á¦Àεí Çѵ¥¿ä?
Á¢¼ÓÀÌ ¸¹Àº ¼­¹öÀΰ¡¿ä?

1. ½Ã½ºÅÛ open file-max°ª È®ÀÎ
cat /proc/sys/fs/file-max
2. selinuxÈ®ÀÎ
3. nginx µ¥¸ó ±¸µ¿ À¯Àú¿Í php-fpm À¯Àú È®ÀÎ
4. ulimit °ª È®ÀÎ ÈÄ °ª ¼öÁ¤
ulimit -n
vi /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535




 

±Ùµ¥  fastcgi·Î  php  ½ºÅ©¸³Æ® ³Ñ°ÜÁÖ´Â ¼³Á¤ÀÌ ¾Æ·¡¿¡ Àִµ¥ ¾Æ·¡ÀÇ ¼³Á¤Àº ¿Ö ÀÖ´Â °ÍÀÌÁÒ?
¾Æ·¡ »©°í ´Ù½Ã nginx ±¸µ¿ÇØ º¸¼¼¿ä.

 location ~ \.php$ {
        proxy_pass  http://127.0.0.1;
    }
     
ȸ¿øK 2016-03
Á¢¼ÓÀº ÀüÇô ¾ø½À´Ï´Ù. Áö³­ÁÖ¿¡ ÀÔ°íÇؼ­ ¼ÂÆÃÁßÀ̰ŵç¿ä.

# cat /proc/sys/fs/file-max
8586507

/etc/security/limits.conf
nginx      soft    nofile  10000
nginx      hard    nofile  30000

# location ~ \.php$ {
#        proxy_pass  http://127.0.0.1;
#    }

# ps -ef | grep nginx
root    13276    1  0 22:28 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx    13277 13276  0 22:28 ?        00:00:00 nginx: worker process
nginx    13278 13276  0 22:28 ?        00:00:00 nginx: worker process
nginx    13279 13276  0 22:28 ?        00:00:00 nginx: worker process
nginx    13280 13276  0 22:28 ?        00:00:00 nginx: worker process

[root@kcolo122-198 conf.d]# ps -ef | grep fpm
root      1701    1  0 08:26 ?        00:00:02 php-fpm: master process (/etc/opt/remi/php70/php-fpm.conf)
apache  13093  1701  0 21:30 ?        00:00:00 php-fpm: pool www
apache  13094  1701  0 21:30 ?        00:00:00 php-fpm: pool www
apache  13095  1701  0 21:30 ?        00:00:00 php-fpm: pool www
apache  13096  1701  0 21:30 ?        00:00:00 php-fpm: pool www
apache  13097  1701  0 21:30 ?        00:00:00 php-fpm: pool www
ȸ¿øK 2016-03
sestatus -v
SELinux status:                enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:        /etc/selinux
Loaded policy name:            targeted
Current mode:                  enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:    allowed
Max kernel policy version:      28

Process contexts:
Current context:                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
Init context:                  system_u:system_r:init_t:s0
/usr/sbin/sshd                  system_u:system_r:sshd_t:s0-s0:c0.c1023

File contexts:
Controlling terminal:          unconfined_u:object_r:user_devpts_t:s0
/etc/passwd                    system_u:object_r:passwd_file_t:s0
/etc/shadow                    system_u:object_r:shadow_t:s0
/bin/bash                      system_u:object_r:shell_exec_t:s0
/bin/login                      system_u:object_r:login_exec_t:s0
/bin/sh                        system_u:object_r:bin_t:s0 -> system_u:object_r:shell_exec_t:s0
/sbin/agetty                    system_u:object_r:getty_exec_t:s0
/sbin/init                      system_u:object_r:bin_t:s0 -> system_u:object_r:init_exec_t:s0
/usr/sbin/sshd                  system_u:object_r:sshd_exec_t:s0
ȸ¿øK 2016-03
2016/03/21 22:28:26 [alert] 13280#13280: setrlimit(RLIMIT_NOFILE, 30000) failed (1: Operation not permitted)
/var/log/nginx/error.log¿¡¼­ ³ª¿À´Â ÀÌ°ÍÀÌ ¿øÀÎÀÎ °Í °°Àºµ¥ ¹æ¹ýÀÌ ¾Èº¸À̳׿ä.
redhat °è¿­ OS°¡ ¾ø´Ùº¸´Ï Å×½ºÆ®¸¦ ÇÒ¼ö°¡ ¾ø³×¿ä....

fastcgi_param SCRIPT_FILENAME ºÎºÐÀ» ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤Çغ¸½Ç¼ö ÀÖ´ÂÁö¿ä?

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     
ȸ¿øK 2016-03
´õ ÇÏ´Ù°¡ os¸¦ À缳ġÇÏ´Â »óȲÀÌ »ý±æ °Í °°¾Æ¼­
vmÀ» ¸¸µé¾î¼­ óÀ½ºÎÅÍ ´Ù½ÃÇØ¾ß ÇÒ °Í °°¾Æ¿ä.
¼³Ä¡°úÁ¤Àº ¿Ã·ÁµÎ°Ú½À´Ï´Ù.
Çѹø ¸®ºäÇغÁ ÁÖ¼¼¿ä.
±èÁ¦¿¬ 2016-03
ÀÛÀº ¾Ç¸¶ ´Ô²²¼­ ¸®Çà ´Ù½Åµ¥·Î ÇÏ¸é µÉ°Í °°±¸¿ä ..
¾ÈµÇ½Ã¸é..
php ¾ÈÂÊÀÇ

 root  /usr/share/nginx/html;
À̰Ÿ¦ ³Ö¾îÁֽðí .. nginx ¹× php-fpm Àç½ÃÀÛ ÇÏ½Ã¸é ¾ÈµÉ ÀÌÀ¯°¡ ¾ø¾îº¸À̳׿ä.
     
ȸ¿øK 2016-03
¾ÈµÉ ÀÌÀ¯°¡ ¾ø´Âµ¥ ¾ÈµÇ³×¿ä. ¤Ð¤Ð...
php-fpm.conf
³»¿ë ¿Ã·ÁÁÖ¼¼¿ä. php-fpmÀº apacheÀ¯Àú·Î ±¸µ¿ÀÌ µÇ°í nginx´Â nginx·Î ±¸µ¿ÀÌ µÇ¸é¼­
¹º°¡ ±ÇÇÑ ¹®Á¦°¡ »ý±äµí º¸ÀÔ´Ï´Ù.
     
ȸ¿øK 2016-03
php70-php-fpmÀÇ À§Ä¡¸¦ ¸ø ã°í ÀÖ½À´Ï´Ù.
¼­¹ö¿¡¼­´Â »èÁ¦ÇÏ°í À缳ġ ½ÃÀÛÇß½À´Ï´Ù.
±èÁ¦¿¬ 2016-03
ȸ¿øK 2016-03
nginx ¼³Ä¡
http://2cpu.co.kr/PDS/11338

mariadb ¼³Ä¡
http://www.2cpu.co.kr/PDS/11339

php 7 ¼³Ä¡


QnA
Á¦¸ñPage 2429/5678
2014-05   4940810   Á¤ÀºÁØ1
2015-12   1477658   ¹é¸Þ°¡
2013-12   5107   Nikon
2015-04   3700   ºû³¯±¤
2022-08   1597   palpitez
03-20   1143   ¹Ì´ã
2015-04   5288   ´ëÀü»ç¶÷
2019-10   2085   Æä¼±»ý
2017-05   2998   NAS°íÀå³µ´Ù¡¦
2022-08   1317   Çã¿ì´ë
2018-08   3551   ¾Ë¼±¾÷ü
2013-12   4203   Å©¸®¹Ì
2018-08   4478   Á¦Ç๫»ó
2013-12   3700   ¹Ú¼º¸¸
2016-06   6988   ´ÃÆĶõ
2017-05   6648   ¼Û»óº´
2015-04   4806   Win31
04-09   1454   ¹«¸íÀÎ12
2011-07   6132   Larry
2013-12   4777   ¹Ú¼º¸¸
2018-09   5806   ¿¥ºê¸®¿À
04-15   1603   lvlnx