nginx + codeigniter 구성이 CentOS 7에서 작동하지 않습니까?

nginx + codeigniter 구성이 CentOS 7에서 작동하지 않습니까?

저는 nginx를 처음 접했고 StackOverflow에서 문제를 찾으려고 노력했지만 포럼에서 정확한 문제를 찾지 못했습니다. nginx, MySQL 및 php-fpm을 성공적으로 설치한 후 제대로 작동하는 php.info를 테스트했습니다.

CodeIgniter 프로젝트를 Apache 서버에서 nginx로 옮기고 있습니다. nginx.conf코드가 있는 파일을 편집합니다.

server {
    listen       80;
    server_name  173.249.40.xxx;

    # note that these lines are originally from the "location /" block
    root   /usr/share/nginx/html/ci;
    index index.html index.htm index.php;

    location /ci {
        try_files $uri $uri/ /index.php;
    }        

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

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

php.info내 경로처럼 잘 작동했지만 호출했을 때 처럼 http://173.249.40.xxx/ci/info.phpCodeIgniter에서는 작동하지 않습니다 .controller namehttp://173.249.40.xxx/ci/index.php/Welcome

CodeIgniter 애플리케이션 경로는 다음과 같습니다.'/usr/share/nginx/html/ci/;'

제게 뭔가를 제안해주세요. 어떻게 고칠 수 있나요?

답변1

오류는 다음과 같습니다.

    location /ci {

이로 인해 로 시작하는 URL 경로만 /ci포함된 try_files. 이것은 당신이 원하는 것이 아닙니다.

대신 다음을 사용하여 모든 URL을 처리해야 합니다.

    location / {

답변2

파일 을 편집하지 않는 것이 좋습니다 nginx.conf. gzip와 같은 새 포함 폴더를 편집 하고 include /etc/nginx/sites/enabled/*.conf;원래 포함 행을 주석 처리한 다음 앞서 언급한 폴더에 com.mywebsite.conf라는 이름으로 구성 파일을 만듭니다.

과거에 제가 했던 방법은 다음과 같습니다.

제가 언급한 새 구성 파일에서 공식적으로 권장되는 구성의 내용을 복사하세요. 이는 시스템에 대한 변수를 수정하면 작동합니다.

https://www.nginx.com/resources/wiki/start/topics/recipes/codeigniter/

또한 웹사이트를 다음 위치에 저장하세요./var/www/html/mywebsite

관련 정보