webtop
@webtop
Web developer

Как настроить nginx для правильной работы приложения на zend freamework 2?

Текущие настройки такие:
#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 my@mail.com";
		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;
}


при переходе по адресу test.com страница открывается корректно.
Но когда запрашиваю страницу test.com/module/index выдает 404.
  • Вопрос задан
  • 735 просмотров
Пригласить эксперта
Ответы на вопрос 2
sumanai
@sumanai
Веб- программист- самоучка
Строчка
try_files $uri =404;
мешает
Ответ написан
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";
       }
}
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы