2014-11-25 2 views
1

OpenCart에서 nginx를 사용할 수 있습니까? 나는 다음의 nginx 영역을 사용하고 있습니다 :opencart 1.5.5를 사용하여 nginx를 설치하는 방법은 무엇입니까?

server { 
     listen 80; 
     listen [::]:80; 

     root /home/username/Development/shop.local; 
     index index.php; 

     server_name shop.local; 

     location /image/data { 
       autoindex on; 
     } 

     location /admin { 
       index index.php; 
     } 

     location/{ 
       try_files $uri @opencart; 
     } 

     location @opencart { 
       rewrite ^/(.+)$ /index.php?_route_=$1 last; 
     } 

     location = /favicon.ico { 
       log_not_found off; 
       access_log off; 
     } 

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


     # Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS! 
     location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ { 
       deny all; 
     } 

     # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). 
     location ~ /\. { 
       deny all; 
       access_log off; 
       log_not_found off; 
     } 

     location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ { 
       expires max; 
       log_not_found off; 
     } 

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

을하지만 shop.local를 방문 할 때 내가 shop.local/install/index.php에 redirecto을 얻고있다 및 nginx를 나에게 내 설정 잘못 어떤 오류 404가 발생합니다?

답변

1

보십시오이 하나

# FORCE WWW 
server { 
    server_name site.com; 
    rewrite ^(.*) http://www.domain.com$1 permanent; 
} 
# MAIN SERVER 
server { 
    server_name www.domain.com; 
    listen 80; 
    root /var/www/www.domain.com/public; 
    index index.php index.html; 
    location /image/data { 
     autoindex on; 
    } 
    location /admin { 
     index index.php; 
    } 
    location/{ 
     try_files $uri @opencart; 
    } 
    location @opencart { 
     rewrite ^/(.+)$ /index.php?_route_=$1 last; 
    } 
    location = /favicon.ico { 
     log_not_found off; 
     access_log off; 
    } 
    location = /robots.txt { 
     allow all; 
     log_not_found off; 
     access_log off; 
    } 
    # Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS! 
    location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ { 
     deny all; 
    } 
    # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). 
    location ~ /\. { 
     deny all; 
     access_log off; 
     log_not_found off; 
    } 
    location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ { 
     expires max; 
     log_not_found off; 
    } 
    location ~ \.php$ { 
     try_files $uri =404; 
     include /etc/nginx/fastcgi_params; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    } 
} 
관련 문제