nginx ¼³Ä¡¿À·ù

   Á¶È¸ 16509   Ãßõ 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 2438/5687
2014-05   4991126   Á¤ÀºÁØ1
2015-12   1527111   ¹é¸Þ°¡
2014-02   4650   judeivan
2020-10   4650   itsss
2007-10   4650   ¹Úº´Èñ
2012-07   4650   ¹ÚÁØ¿ë
2016-12   4650   ±Í¾ÈÀǶÇÁß
2023-06   4650   ´Þ±¤ÀÌ
2015-03   4650   °æÀ̾ƺü
2021-01   4650   ¹Ú¹®Çü
2014-11   4650   Win31
2017-02   4650   ȲÁø¿ì
2007-03   4650   °­µ¿¿À
2015-05   4650   À嵿°Ç2014
2016-02   4650   Sunrise
2006-11   4651   ³ëÇϼ®
2022-09   4651   È­¶õ
2006-12   4651   ÀÌÀç¼®
2022-11   4651   ¹Ú¹®Çü
2017-06   4651   AplPEC
2015-05   4651   isaiah
2006-12   4651   ¹èÁ¤ÇÑ