기본 콘텐츠로 건너뛰기

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 framework 종류

PHP framework 종류 분류 전체보기 (1461) API (0) Android (19) Common (11) Component (0) adb (2) DDMS (1) GCM (4) HTTP (0) sqlite (1) View (0) build (0) Bigdata (4) Common (1) Hadoop (2) Spark (0) SQL on Hadoop (1) Cloud (12) Common (8) Multitenancy (2) OpenStack (0) UCloud (2) Computer Science (24) Common (4) Asynchronous IO (1) Cache (6) Distributed (0) Message Queue (1) Parallel Computing (5) Software Engineering (7) DB (172) Common (32) HSQLDB (1) In-memory DB (0) MariaDB (2) MongoDB (30) MySQL (69) NoSQL (8) Oracle (17) ORM (6) Redis (1) SQL Server (6) Design Pattern (7) Common (7) Programming paradigms (0) Reactor (0) Development (459) Common (37) AngularJS (3) Bootstrap (3) C (22) C++ (0) CSS (32) HTML (31) HTML5 (2) Java (118) JavaEssential (25) JSP & Servlet (33) JavaScript (69) jQuery (26) jQuery Mobile (4) Linux Programming (3) python (3) PHP (21) Reactive Streams (0) ShellScript (5) UML (6) Windows Programming (2) XML (14) Framework & Platform (161) Common (8) EFL (1) mybati

MariaDB 에서 access denied for user 'root' 문제

MariaDB 에서 access denied for user 'root' 문제 heidisql 등의 원격 접속 툴을 이용해도 접속이 안 됐다. 포트, 방화벽 설정 등등 모두 확인해 봤고 로컬에서 잘 돌아가는 데도 원격 접속이 안됐다. 사실 원격 접속만 안 되면 상관 없는데, codeigniter에서도 똑같이 로그인을 못해서 자꾸 에러가 났었다. 일단, MariaDB는 10.4부터 root 권한 소유자에게 따로 비밀번호를 물어보지 않는다. 즉, 루트 계정으로 로그인했으면 그냥 콘솔에 mysql 치면 접속이 된다. 물론 다른 유저는 전처럼 비밀번호를 물어본다. 나는 이 root 계정으로 로그인을 며칠째 계속 시도해 봤는데 계속 안됐다.... 포트 문제도 아니었고 딱히 통신 문제도 아니었다. 심지어 SSH 접속 계정도 root 였다. 해답은 새로운 계정을 파서, 그 계정으로 접속을 하니까 잘 됐다. 계정 만드는 SQL 문이야 검색하면 바로 나올 거니까 따로 적진 않겠다.사실 별 내용 없는 건 아는데 새 계정을 파서 시도하란 말을 며칠 내내 구글을 뒤진 다음에야 본 것 같아서, 혹시 같은 어려움을 겪는 사람들이 있다면 빨리 해결할 수 있었으면 좋겠다. from http://skyseven73.tistory.com/5 by ccl(A) rewrite - 2020-03-11 02:54:31

[공학] 목차

[공학] 목차 자동차공학 컴퓨터공학 컴퓨터공학 | 개발환경 컴퓨터공학 | 웹개발 컴퓨터공학 | 모바일개발 ✓ 컴퓨터공학 | 운영체제 컴퓨터공학 | 프로그래밍 컴퓨터공학 | 네트워크 컴퓨터공학 | 데이터베이스 from http://sanctacrux.tistory.com/679 by ccl(A) rewrite - 2020-03-12 16:54:22