我想在后端和angularjs在前端使用codeigniter网站。 对于后端,我使用nginx作为服务器。 目前我遇到了正确配置nginx的问题。我想要实现的是将codeigniter和angularjs应用程序放在单独的文件夹中。而我要的是访问如下从my_website.com/apiNginx的子文件夹中的角和codeigniter应用程序
- 笨
- 从my_website.com
,并在文件夹的角度而言我希望让他们在:
- 笨:/无功/网络/ HTML/API
- 角:/无功/网络/ HTML /角
到目前为止,我已经设法使它在同一个文件夹中工作。所以现在我在/ var/www/html中添加了codeigniter,并且angular文件夹位于相同的目录中。这样我就可以从my_website.com/访问codeigniter,并从my_website.com/app获取角度,这不是我想要的。
我正在尝试nginx/etc/nginx/sites-available/default文件的多个不同设置,但每次都遇到一些问题。我得到的最远是将它们放在单独的文件夹中,但codeigniter只能用于default_controller,我无法访问任何其他文件。 这是当前的工作配置。
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
root /var/www/html;
server_name localhost;
index index.php index.htm index.html;
location /app/ {
root /var/www/html/angular;
try_files $uri/ $uri index.html =404;
}
location/{
try_files $uri $uri/ /index.php;
#index index.html;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
include fastcgi_params;
}
}
这里是简单的配置,我只是尝试从演示子文件夹笨运行,
server {
listen 80;
server_name localhost;
root /var/www/html;
autoindex on;
index index.php;
location/{
#try_files $uri $uri/ /index.php;
try_files $uri $uri/ /index.php$request_uri;
location = /demo/index.php {
try_files $uri $uri/ /index.php$request_uri;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME /var/www/html/demo$fastcgi_script_name;
include fastcgi_params;
}
}
location ~ \.php$ {
return 444;
}
}
这里my_website.com/demo/index.php工作正常,但my_website.com/ demo/index.php/welcome shows 500内部服务器错误
我希望自己清楚。 我尝试了很多不同的在线配置,但我总是遇到一些麻烦。你们能为你们提出一些简单的解决方案吗?
感谢, Mateusz
你的日志里有什么错误? –
我在哪里可以查看该日志? – Mateusz
默认情况下它应该位于'/ var/log/nginx/* .log'下,您还可以设置[error_log](http://nginx.org/en/docs/ngx_core_module.html?&_ga=1.179635491.686758843.1471931560# error_log)指令重定向到特定文件 –