我有一个静态站点 Angular 站点,我想让路径 /deploy 运行 php 脚本 /var/www/app/deploy/deploy.php。我尝试了重写规则,但没有成功。
正确的做法是什么?
php.conf
index index.php index.html index.htm;
location ~ \.php$ {
try_files $uri =404;
fastcgi_intercept_errors on;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php-fpm;
}
虚拟主机配置文件
server {
listen 80;
server_name app.com;
root /var/www/app/;
include /etc/nginx/default.d/php.conf;
location / {
root /var/www/app/frontend/dist;
try_files $uri $uri/ /index.html =404;
rewrite ^/deploy /var/www/app/deploy/deploy.php;
}
}