[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 {
¸ÕÀú php-fpmÀ» Àç½ÃÀÛÀ» Çغ¸½Ã°í 9000¹ø Æ÷Æ®°¡ Á¤»óÀûÀ¸·Î ¿¬°áµÇ´ÂÁö È®ÀÎÇغ¸½Ã±â ¹Ù¶ø´Ï´Ù.
Âü°í·Î php-fpmÀ» µ¿Àϼ¹ö ·ÎÄÿ¡¼¸¸ »ç¿ëÇϽŴٸé upstream À» tcp·Î ¿Áö ¸¶½Ã°í ¼ÒÄÏÀ» ÀÌ¿ëÇϽô°ÍÀÌ ¼º´É¸é¿¡¼ ÁÁ½À´Ï´Ù.
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µµ µ¿ÀÛÇÏ°í ÀÖ´Â °Í °°±¸¿ä
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)
worker_rlimit_nofile 30000;
...
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
...
sysctl fs.file-max
fs.file-max = 70000
¿ä·¸°Ô Çغ¸½Ã¸é µÉ½Çµí.
--> /etc/nginx/nginx.conf ¿¡ ³Ö¾îÁ® ÀÖ½À´Ï´Ù.
/run/ ¹Ø¿¡ php µð·ºÅ丮°¡ ¾ø½À´Ï´Ù. -..-...
fileÀº os ·¹º§¿¡¼ ¸¹ÀÌ ´Ã·Áµ×±¸¿ä.
Á¢¼ÓÀÌ ¸¹Àº ¼¹öÀΰ¡¿ä?
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;
}
# 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
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
/var/log/nginx/error.log¿¡¼ ³ª¿À´Â ÀÌ°ÍÀÌ ¿øÀÎÀÎ °Í °°Àºµ¥ ¹æ¹ýÀÌ ¾Èº¸À̳׿ä.
fastcgi_param SCRIPT_FILENAME ºÎºÐÀ» ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤Çغ¸½Ç¼ö ÀÖ´ÂÁö¿ä?
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
vmÀ» ¸¸µé¾î¼ óÀ½ºÎÅÍ ´Ù½ÃÇØ¾ß ÇÒ °Í °°¾Æ¿ä.
¼³Ä¡°úÁ¤Àº ¿Ã·ÁµÎ°Ú½À´Ï´Ù.
Çѹø ¸®ºäÇغÁ ÁÖ¼¼¿ä.
¾ÈµÇ½Ã¸é..
php ¾ÈÂÊÀÇ
root /usr/share/nginx/html;
À̰Ÿ¦ ³Ö¾îÁֽðí .. nginx ¹× php-fpm Àç½ÃÀÛ ÇÏ½Ã¸é ¾ÈµÉ ÀÌÀ¯°¡ ¾ø¾îº¸À̳׿ä.
³»¿ë ¿Ã·ÁÁÖ¼¼¿ä. php-fpmÀº apacheÀ¯Àú·Î ±¸µ¿ÀÌ µÇ°í nginx´Â nginx·Î ±¸µ¿ÀÌ µÇ¸é¼
¹º°¡ ±ÇÇÑ ¹®Á¦°¡ »ý±äµí º¸ÀÔ´Ï´Ù.
¼¹ö¿¡¼´Â »èÁ¦ÇÏ°í À缳ġ ½ÃÀÛÇß½À´Ï´Ù.
selinux °ü·Ã ¿À·ùÀΰ¡ºÁ¿ä.
http://2cpu.co.kr/PDS/11338
mariadb ¼³Ä¡
http://www.2cpu.co.kr/PDS/11339
php 7 ¼³Ä¡