我创建了一个yii2休息Angular应用程序,它在apache服务器上工作得很好, 我需要将服务器更改为nginx。 这是我的nginx配置
server {
charset utf-8;
client_max_body_size 128M;
listen 8888;
server_name careers;
root "/Applications/MAMP/htdocs/careers";
access_log /Applications/MAMP/logs/nginx_access.log;
error_log /Applications/MAMP/logs/nginx_error.log;
location / {
root "/Applications/MAMP/htdocs/careers";
try_files $uri $uri/ /index.html =404;
}
location ~* \.php$ {
include fastcgi_params;
fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
try_files $uri =404;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location /careers-api {
client_max_body_size 2000M;
alias /Applications/MAMP/htdocs/careers/careers-backend/api/web;
try_files $uri /careers-backend/api/web/index.php?$args;
location ~* ^/careers-api/(.+\.php)$ {
try_files $uri /careers-backend/api/web/$1?$args;
}
}
location ~ /\. {
deny all;
}
}
它适用于我的角度应用,但是我的yii2 api无效,只有我只能访问我给出的每个网址的默认网址site/index
。 Ps:在我的yii2应用程序中启用了漂亮的URL。
文件夹结构
-- root Folder(Angular App Index)
--- root/careers-backend/api/web (Yii2 App index)
任何想法?我是nginx服务器的新手。