【发布时间】:2014-06-12 15:01:53
【问题描述】:
我有一个安装了 CentOS 6.5 Plesk 11.5 的专用服务器,并且我已经打开了 Nginx 来处理 PHP 文件。
我已在 Plesk 中开启服务工具/服务管理:
- 反向代理服务器 (nginx)
- 对 nginx 的 PHP-FPM 支持
在 Domains/example.com/Web 服务器设置中
- 智能静态文件处理
- 直接由 nginx 提供静态文件
- 通过 nginx 处理 PHP
我使用 CodeIgniter 框架,默认配置下一切正常。但是当我尝试删除 CodeIgniter 配置文件 (config.php) 中的 index.php 时
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
以前的 URL example.com/project/index.php/text 变成 example.com/project/text 虽然我无法访问链接并出现以下错误:
没有指定输入文件。
我已经搜索了很多解决方案,但对我没有任何帮助。 Plesk 自动为每个域生成 Nginx 配置。根据指南,我尝试在 Domains/example.com/Web Server Settings 的 Additional nginx 指令中添加此代码。
location ~ /project {
try_files $uri $uri/ /index.php?$args;
}
我得到一个不同的错误:
找不到文件。
我应该改变什么以及在哪里改变?我浪费了 2 天没有成功。
我在 example.com.conf 中有以下代码,但它是由 Plesk 自动生成的。
server {
listen IP_IS_HIDDEN:80;
server_name domain.com;
server_name www.example.com;
server_name ipv4.example.com;
client_max_body_size 128m;
root "/var/www/vhosts/example.com/httpdocs";
access_log /var/www/vhosts/system/example.com/logs/proxy_access_log;
if ($host ~* ^www.example.com$) {
rewrite ^(.*)$ http://example.com$1 permanent;
}
location / {
proxy_pass http://IP_IS_HIDDEN:7080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location @fallback {
proxy_pass http://IP_IS_HIDDEN:7080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location ~ ^/plesk-stat/ {
proxy_pass http://IP_IS_HIDDEN:7080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location ~ ^/(.*\.(ac3|avi|bmp|bz2|css|cue|dat|doc|docx|dts|exe|flv|gif|gz|htm|html|ico|img|iso|jpeg|jpg|js|mkv|mp3|mp4|mpeg|mpg|ogg|pdf|png|ppt|pptx|qt|rar|rm|swf|tar|tgz|txt|wav|xls|xlsx|zip))$ {
try_files $uri @fallback;
}
location ~ ^/~(.+?)(/.*?\.php)(/.*)?$ {
alias /var/www/vhosts/example.com/web_users/$1/$2;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass "unix:/var/www/vhosts/system/example.com/php-fpm.sock";
include /etc/nginx/fastcgi.conf; }
location ~ ^/~(.+?)(/.*)?$ {
proxy_pass http://IP_IS_HIDDEN:7080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location ~ \.php(/.*)?$ {
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass "unix:/var/www/vhosts/system/example.com/php-fpm.sock";
include /etc/nginx/fastcgi.conf; }
location ~ /$ {
index index.html index.cgi index.pl index.php index.xhtml index.htm index.shtml;
}
include "/var/www/vhosts/system/example.com/conf/vhost_nginx.conf";
}
【问题讨论】:
标签: codeigniter nginx plesk