기본 콘텐츠로 건너뛰기

CentOS7 + nginx + PHP7 + codeIgniter 세팅기

CentOS7 + nginx + PHP7 + codeIgniter 세팅기

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

우선 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 세팅은 끝맺었다..

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

from http://rootjs.tistory.com/24 by ccl(A) rewrite - 2020-03-06 07:20:39

댓글

이 블로그의 인기 게시물

[PHP] 코드이그니터 - 파일업로드 구현

[PHP] 코드이그니터 - 파일업로드 구현 파일 업로드 이번에 PHP 프레임워크인 코드 이그니터(Codeigniter)를 사용하여 홈페이지를 만드는데 사용한 이미지 업로드용 코드 입니다. upload 라이브러리를 사용하고 app~ 와 같은 위치에 upload 폴더를 만드고 다음 코드를 사용한다음 ajax 로 호출하여 파일을 업로드 합니다. function index() { // Upload 설정 $config['upload_path'] = './upload/'; $config[\'allowed_types\'] = 'gif|jpg|png'; $config['max_size'] = 100; // 100k $config['max_width'] = 1024; $config['max_height'] = 768; $this->load->library('upload', $config); $data = array(); if (! $this->upload->do_upload("service_image")) { $error = array('error' => $this->upload->display_errors()); } else { //$data = array('upload_data' => $this->upload->data()); $this->output->set_output("./upload/".$this->upload->data('file_name')); } } jquery 를 이용한 파일 업로드 호출 코드 function upload() { var datas, xhr; datas = new FormData(); datas.append( 'service_image', $( ...

2017년 1월 스타트업에서 구인할때 주로 원하는 개발 기술

2017년 1월 스타트업에서 구인할때 주로 원하는 개발 기술 php mysql linux android git kotlin gcm/fcm python mssql mongodb amazon aws ios objective-c swift github python c++ django python postgresql amazon aws html5/css3/javascript android java mysql python c++ c# java aws cloud-server dbms node.js postgresql redis nginx react.js hapi.js amazon aws restful-api angularJS jQuery html5/css3/javascript android firebase custom ui component restful-api asp.net c# html css javascript bootstrap angularjs node.js php mongodb redis 프론트엔드 주요 기술 javascript jquery ajax angularjs wbesocket html5/css3/javascript android ios java xcode node.js coffeescript mysql amazon ec2 amazon es3 android ios node.js php python java ios php mysql apache python android redis node.js jquery msa node.js java restful-api linux nosql golang redis nginx ...

이클립스 코드이그나이터 연동 ( eclipse codeigniter )

이클립스 코드이그나이터 연동 ( eclipse codeigniter ) https://ellislab.com/codeigniter/user-guide/installation/downloads.html 위의 사이트에서 코드이그나이터를 다운 받는다. 다운받은 압축 파일을 풀어 준다. 이클립스에서 php 프로젝트를 생성한 공간에 코드이그나이터 압축파일을 복사 붙여넣기 해준다. 위와 같은 화면이 나오면 정상적으로 연동이 된 것 입니다. from http://nahosung.tistory.com/22 by ccl(A) rewrite - 2020-03-06 16:20:55