티스토리 뷰

어렵지 않은걸 어렵게 돌아갔다..


우선 nginx + php7 설치 후 연동까지는 많은 블로그들에 정보가 있다.


중요한점은 


/etc/nginx/conf.d/*.conf 파일의 아래부분에 unix:/var/run/php-fpm/php-fpm.sock;와

/etc/php-fpm.d/www.conf 설정에 listen = /var/run/php-fpm/php-fpm.sock

이 동일해야한다는것정도



 location ~ \.php$ {

 72     fastcgi_split_path_info ^(.+\.php)(/.+)$;

 73     fastcgi_index   index.php;

 74     fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;

 75     fastcgi_param PATH_INFO       $fastcgi_path_info;

 76     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

 77     include        fastcgi_params;

 78     }


연동을 하고 나면 특정 폴더를 지정해서 ci(codeIgniter)파일들을 업로드 한다.


ci책중에 제일 볼만한 책이 만들면서 배우는 codeIgniter 프레임워크라 하여 이책으로 시작했는데


책버전과 실제 서버에 설치한 버전에서 오는 차이의 문제때문에 고생 했다 그문제는 바로..


파일명을 생성할때 첫번째 글자가 대문자여야한다는것...


ci 2점대 버전에서는 이부분이 없었는데 3점대 올라오면서 추가된거라 한다..


파일이 있는데 계속 404에러를 뿌려대길래 호스팅쪽 문제인줄 알고 몇일을 고생해서 찾았는데..;;


일단 그렇게 설정을 하고 다음문제는 index.php없애기..


기본 *.conf 파일에서


아래처럼 하면 된다고 했다 여러 블로그 및 글에 따르면


#
server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;

    server_name localhost;

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

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
    }

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

가상호스팅 설정 파일 부분인데 난 이렇게 해도 안됐었다..


그러다가 해외글 하나를 접했는데


http://www.farinspace.com/codeigniter-nginx-rewrite-rules/


이글이다..


뭐 해석하긴 어렵고 중간에 설정부분만 가져와서 넣었더니 index.php가 없어도 연결이 된다..


  1 server {

  2     listen       80;

  3     server_name  youngcom.co.kr www.youngcom.co.kr *.youngcom.co.kr;

  4

  5     #charset koi8-r;

  6     #access_log  /var/log/nginx/log/host.access.log  main;

  7

  8     index index.php index.html index.htm;

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

 10

 11     location / {

 12       try_files $uri $uri/ /index.php/$request_uri;

 13     }

 14

 15

 16     if ($host ~* ^www\.(.*))

 17     {

 18     set $host_without_www $1;

 19     rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;

 20     }

 21     # canonicalize codeigniter url end points

 22     # if your default controller is something other than "welcome" you should change the following

 23     if ($request_uri ~* ^(/welcome(/index)?|/index(.php)?)/?$)

 24     {

 25     rewrite ^(.*)$ / permanent;

 26     }

 27     # removes trailing "index" from all controllers

 28     if ($request_uri ~* index/?$)

 29     {

 30     rewrite ^/(.*)/index/?$ /$1 permanent;

 31     }

 32     # removes trailing slashes (prevents SEO duplicate content issues)

 33     if (!-d $request_filename)

 34     {

 35     rewrite ^/(.+)/$ /$1 permanent;

 36     }

 37     # removes access to "system" folder, also allows a "System.php" controller

 38     if ($request_uri ~* ^/system)

 39     {

 40     rewrite ^/(.*)$ /index.php?/$1 last;

 41     break;

 42     }

 43     # unless the request is for a valid file (image, js, css, etc.), send to bootstrap

 44     if (!-e $request_filename)

 45     {

 46     rewrite ^/(.*)$ /index.php?/$1 last;

 47     break;

 48     }

 49     # catch all

 50     error_page 404 /index.php;

 51

 52     location = /favicon.ico {

 53         log_not_found off;

 54         access_log off;

 55     }

 56     location = /robots.txt {

 57         allow all;

 58         log_not_found off;

 59         access_log off;

 60     }

 61

 62     error_page  404 /404.html;

 63

 64     # redirect server error pages to the static page /50x.html

 65     #

 66     error_page   500 502 503 504  /50x.html;

 67     location = /50x.html {

 68         root   /usr/share/nginx/html;

 69     }

 70

 71     location ~ \.php$ {

 72     fastcgi_split_path_info ^(.+\.php)(/.+)$;

 73     fastcgi_index   index.php;

 74     fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;

 75     fastcgi_param PATH_INFO       $fastcgi_path_info;

 76     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

 77     include        fastcgi_params;

 78     }


이렇게 ci 세팅은 끝맺었다..


몇일을 쓴건지 이거때문에..;;                                                                  

댓글