У меня есть конфигурация nginx для реагирующего приложения. Однако я также хотел бы включить sitemap.php, который я создаю динамически с помощью php.
Итак, вот мой конфиг nginx:
server {
listen 80;
listen [::]:80;
server_name mysite.com;
index index.html index.htm;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
location /sitemap.xml {
alias /var/www/web-app/public/sitemap.php;
}
location / {
root /var/www/web-app/public;
try_files $uri $uri/ /index.html;
default_type "text/html";
}
}
Файл фрагментов состоит из этого:
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
Кроме того, это размещено на Ubuntu 16.04 digitalocean VPS.
Мое приложение для реагирования по-прежнему загружается нормально. Он основан на index.html в корне моего сайта (/var/www/web-app/public). Если я помещаю test.php в общую папку, я получаю ошибку 404. Для моего псевдонима sitemap.xml он правильно перенаправляется на sitemap.php (также общедоступный), но php не отображается.
Итак, у меня две самые большие проблемы: 1. Почему я получаю 404 на /mysite.com/test.php? 2. И почему мой php не отображается, когда он работает? (например, sitemap.php)