CI 묻고 답하기

제목 시작도 못하고 막혀있네요.. centOS7 + Nginx + codeIgniter3
카테고리 CI 2, 3
글쓴이 개락 작성시각 2017/03/31 08:53:28
댓글 : 10 추천 : 0 스크랩 : 0 조회수 : 19670   RSS

안녕하세요.

ASP만 하다가 PHP입문하게되어 바로 코드이그나이터로 익혀보려고 서버세팅부터 하나하나 해오고있습니다.

NGINX세팅까지는 마무리했고 코드이그나이터 파일 업로드 후 테스트하는 단계인데..

기본 INDEX.PHP파일은 잘 열립니다.

테스트 URL은 http://youngcom.co.kr/todo/ 입니다.

책을 따라 예제를 진행하려고 하는데 문제는 컨트롤러 호출이 안되는건지 파일을 찾아가질 못합니다.

http://youngcom.co.kr/todo/index.php?/main/lists 

http://youngcom.co.kr/todo/index.php/main/lists 

http://youngcom.co.kr/todo/main/lists 

세 URL 다 연결이 안됩니다.

main.php 파일에 

<물음표 php 

phpinfo();

end;

위와같이 적고 main을 호출하면 No input file specified. 요 메세지가 나옵니다.

이걸 어디서부터 풀어나가야할지 막막해서 이렇게 글을 올려봅니다..ㅠㅠ

제목에 적은대로 centOS7 + NginX + php7 + mariaDB10 조합입니다.

서버부터 소스까지 다 제가 만질수 있는 상황이긴한데 어디서부터 체크를 해야하는지를 모르겠는게 문제입니다.

아래는 서버쪽 에러로그입니다.

 

2017/03/31 08:19:22 [error] 5924#0: *76 FastCGI sent in stderr: "Unable to open primary script: /home/www/youngcom.co.kr/index.php (No such file or directory)" while reading response header from upstream, client: ***.***.***.***, server: *.youngcom.co.kr, request: "GET /todo/main/lists HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "youngcom.co.kr"

2017/03/31 08:19:23 [error] 5924#0: *76 FastCGI sent in stderr: "Unable to open primary script: /home/www/youngcom.co.kr/index.php (No such file or directory)" while reading response header from upstream, client: ***.***.***.***, server: *.youngcom.co.kr, request: "GET /todo/main/lists HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "youngcom.co.kr"

2017/03/31 08:43:55 [error] 5924#0: *80 directory index of "/home/www/youngcom.co.kr/" is forbidden, client: ***.***.***.***, server: *.youngcom.co.kr, request: "GET / HTTP/1.1", host: "youngcom.co.kr"

2017/03/31 08:59:42 [error] 5924#0: *85 directory index of "/home/www/youngcom.co.kr/" is forbidden, client: 211.196.223.90, server: *.youngcom.co.kr, request: "GET / HTTP/1.1", host: "youngcom.co.kr"

2017/03/31 09:10:20 [error] 5924#0: *89 FastCGI sent in stderr: "Unable to open primary script: /home/www/youngcom.co.kr/index.php (No such file or directory)" while reading response header from upstream, client: ***.***.***.***, server: *.youngcom.co.kr, request: "GET /todo/index.php/main HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "youngcom.co.kr"

2017/03/31 09:10:28 [error] 5924#0: *89 FastCGI sent in stderr: "Unable to open primary script: /home/www/youngcom.co.kr/index.php (No such file or directory)" while reading response header from upstream, client: ***.***.***.***, server: *.youngcom.co.kr, request: "GET /todo/main HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "youngcom.co.kr"

2017/03/31 09:17:32 [error] 5924#0: *108 FastCGI sent in stderr: "Unable to open primary script: /home/www/youngcom.co.kr/index.php (No such file or directory)" while reading response header from upstream, client: ***.***.***.***, server: *.youngcom.co.kr, request: "GET /todo/index.php/main HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "youngcom.co.kr"

 다음글 Hook을 이용한 사이트점검때문에 질문드립니다. (3)
 이전글 코어 와 컨트롤러의 경계에 대해서 개념좀 잡아주세요.. (6)

댓글

전상민 / 2017/03/31 09:56:54 / 추천 0
Nginx의 "fastcgi_param" 설정이 잘못돼있는 것 같습니다.
도라에몽 / 2017/03/31 10:14:53 / 추천 0
CentOS7 이면 SELinux를 꺼보세요. 아마 끄고 재부팅 하고나면 될겁니다. ㅎㅎ
개락 / 2017/03/31 13:04:56 / 추천 0

댓글 감사합니다.

nginx 설정부분은 아래처럼 되어있어요

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param  PATH_INFO $fastcgi_path_info;
    include        fastcgi_params;
}

selinux는 세팅하면서 꺼놨었습니다..ㅎㅎ

SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

전상민 / 2017/03/31 14:41:54 / 추천 0

php-fpm pool 설정의 listen 항목도 아래처럼 설정해주셨나요?

listen='/var/run/php-fpm/php-fpm.sock'

nginx 설정중 document root 디렉토리 경로도 한 번 확인해보세요.

개락 / 2017/03/31 15:01:15 / 추천 0

www.conf 파일 설정은 

 38 ;listen = 127.0.0.1:9000
 39 listen = '/var/run/php-fpm/php-fpm.sock'

와 같이 되어있습니다.

아래 적어주신 nginx 설정중에 document root 디렉토리 경로를 확인 하라는 말씀이 어느부분인지 잘 모르겟습니다..^^;;

아래는 nginx.conf 파일 부분인데 저부분에 location / {} 이부분을 말씀하시는건가요?..^^;

 include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {

        }
        location ~ \.php$ {
            fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO $fastcgi_path_info;
            include        fastcgi_params;
        }
    }

전상민 / 2017/03/31 15:43:26 / 추천 0

http://youngcom.co.kr 도메인 관련 설정파일도 보여주세요.

/etc/nginx/default.d 디렉토리 하위에 있을 것 같네요.

개락 / 2017/03/31 16:11:24 / 추천 0

정말 감사합니다.. ㅎㅎ;; 일하면서 익힐려니 시간도 없고 맘만 쫓기네요...ㅠㅠ

[admin@centos php-fpm.d]$ sudo vi /etc/nginx/conf.d/aaa.conf
[sudo] password for admin:
server {
    listen       80;
    server_name  *.youngcom.co.kr youngcom.co.kr;

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

    index index.php index.html index.htm;
    root    /home/www/youngcom.co.kr;

    location / {
        try_files $uri $uri/ /index.php?/$request_uri;
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    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;
    }

    location ~ \.php$ {
                #root                                           /home/www/youngcom.co.kr;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
                fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param  PATH_INFO $fastcgi_path_info;
    include        fastcgi_params;

    }
                location = /\.ht{
                        deny all;
                }
}

전상민 / 2017/03/31 16:45:07 / 추천 0

CodeIgniter 설치 경로가 /home/www/youngcom.co.kr/todo 여긴가요?

그럼 root 설정을 아래처럼 변경해보세요.

root    /home/www/youngcom.co.kr/todo;

 

접근시엔 아래처럼 하시구요.

http://youngcom.co.kr/index.php/main/lists

개락 / 2017/03/31 17:44:09 / 추천 0

root경로는 todo까지 넣었고.. 위 경로로 접근했으나 404에러가 나옵니다..ㅠㅠ

nginx access.log 부분입니다..ㅠㅠ

 - - [31/Mar/2017:18:04:20 +0900] "GET /index.php?/main.php HTTP/1.1" 404 1217 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" "-"
 - - [31/Mar/2017:18:05:51 +0900] "GET /index.php?/main/lists HTTP/1.1" 404 1217 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" "-"
 - - [31/Mar/2017:18:05:57 +0900] "GET /index.php/main/lists HTTP/1.1" 404 1217 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" "-"
 - - [31/Mar/2017:18:06:23 +0900] "GET /index.php/main/lists HTTP/1.1" 404 1217 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" "-"
 - - [31/Mar/2017:18:06:31 +0900] "GET /index.php/main/lists HTTP/1.1" 404 1217 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0" "-"
 - - [31/Mar/2017:18:06:31 +0900] "GET /favicon.ico HTTP/1.1" 404 1217 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0" "-"

 

혹시나해서 config.php 파일의 uri_protocol  부분을 PATH_INFO 로 변경하니

main/lists로 연결하면 연결은 되는데 welcome으로 연결되네요...ㅠㅠ

 

개락 / 2017/04/06 17:53:20 / 추천 0

일단 http://youngcom.co.kr/todo/index.php?/main

이 URL로 띄우는데 까지는 성공했습니다. 첫번째문제는 nginx/conf.d에 설정파일을 뒤죽박죽 해놨더니 도메인 연결이 들쑥 날쑥해져서 제대로 테스트가 안되었던거고

또하나는 ci가 3점대 버전인데 이버전에서는 파일명을 무조건 대문자로 시작해야한다는걸 이제야 알게됐습니다.;;;;

rewriteurl은 더 해봐야겠지만 일단 연결된다는 자체가 기쁘네요....ㅠㅠ

만세!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!