N
N
Narek2015-10-04 05:21:47
Nginx
Narek, 2015-10-04 05:21:47

How to configure nginx for application to work properly on zend freamework 2?

The current settings are:

#user 'test' virtual host 'test.com' configuration file
server {
  server_name test.com www.test.com;
  charset UTF-8;
  disable_symlinks if_not_owner from=$root_path;
  gzip on;
  gzip_comp_level 5;
  index index.php index.html;
  root $root_path;
  set $root_path /var/www/test/data/www/test.com/public;
  access_log /var/www/httpd-logs/test.com..access.log ;
  error_log /var/www/httpd-logs/test.com.error.log notice;
  listen MY_IP:80 default_server;
  include /etc/nginx/vhosts-includes/*.conf;
  location / {
    location ~ [^/]\.ph(p\d*|tml)$ {
      try_files /does_not_exists @php;
    }
  }
  location @php {
    fastcgi_index index.php;
    fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
    fastcgi_pass unix:/var/www/php-fpm/test.sock;
    fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
    try_files $uri =404;
    include fastcgi_params;
  }
  ssi on;
}

when you go to test.com, the page opens correctly.
But when I request the page test.com/module/index it gives 404.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sumanai, 2015-10-04
@sumanai

The line
gets in the way

S
Sergey Tevs, 2015-11-04
@Berserk22

server {
        listen 80;
        server_name www.test.com test.com;

        ##LOGS
        access_log off;
        error_log /srv/www/test/logs/www.test.com.error_log;

        ##Document Root
        root /srv/www/test/html/test.com/public;

        ##Default Index
        index index.php index.html index.htm;

        ##Security
        if ( $request_method !~ ^(GET|HEAD|POST)$ ){
               return 444;
        }

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

        # Block access to .htaccess
        location ~ \.htaccess {
           deny all;
        }

        location ~\.php$ {
                   try_files $uri = 404;
           fastcgi_pass   unix:/var/run/php5-fpm/test.sock;
           fastcgi_index  index.php;
           fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
           fastcgi_param TMP /srv/www/test/tmp;
           fastcgi_param TMPDIR  /srv/www/test/tmp;
           fastcgi_param TEMP  /srv/www/test/tmp;
           include fastcgi_params;
       }
    location = /favicon.ico {
         log_not_found off;
         access_log off;
         }

        location = /robots.txt {
         allow all;
         log_not_found off;
         access_log off;
         }
    location ~* ^.+.(jpe?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|mi​di|wav|bmp|rtf|js|swf|avi|mp3)$ {
           expires 31d;
           add_header Pragma "public";
           add_header Cache-Control "public, must-revalidate, proxy-revalidate";
       }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question