I have setup nginx 0.7.67 on Ubuntu10.10 along with php-cli . I'm trying to get my front-controller based PHP framework to run, but all pages except index.php give a 403 error.
我在Ubuntu10.10上安装了nginx 0.7.67和php-cli。我试图让基于前端控制器的PHP框架运行,但是除了索引之外的所有页面。php会出现403错误。
Ex :
例:
- http://mysite.com/styles/style.css - 403 Forbidden
- http://mysite.com/styles/style.css - 403禁止
- http://mysite.com/scripts/script.css - 403 Forbidden
- http://mysite.com/scripts/script.css - 403禁止
- http://mysite.com/index.php - Works
- http://mysite.com/index.php的作品
My /etc/nginx/sites-enabled/default is as follows
我的/etc/ nginx/sitenabled /默认值如下。
server {
listen 80;
server_name mysite.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
index index.php index.html;
root /full/path/to/public_html;
location ~* \.(js|css|png|jpg|jpeg|gif|ico|html)$ {
expires max;
}
location ~ index.php {
include /etc/nginx/fastcgi_params;
keepalive_timeout 0;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
Any suggestions on how to fix the above?
对于如何解决上述问题有什么建议吗?
PS: This is the entry from the error log
这是错误日志中的条目
2010/10/14 19:56:15 [error] 3284#0: *1 open() "/full/path/to/public_html/styles/style.css"
failed (13: Permission denied), client: 127.0.0.2, server: quickstart.local,
request: "GET /styles/style.css HTTP/1.1", host: "mysite"
6 个解决方案
#1
16
Had the same problem. Fixed it by simply setting the right permissions on my CSS and JS files and folders. Be careful about setting permissions! But for a file to be readable on the web, it has to be readable by the user running the server process.
有同样的问题。通过在我的CSS和JS文件和文件夹中设置正确的权限来修复它。设置权限时要小心!但是要使文件在web上可读,它必须由运行服务器进程的用户可读。
chmod -R +rx css
chmod -R +rx js
Gives read and execute permissions. The -R
is for recursive. Only do this for files you want readable by the world!
授予读取和执行权限。r是递归的。只对你想要被世界读的文件这样做!
#2
1
Alt solution: change the run user by editing the nginx.conf (e.g., /usr/local/nginx/conf/nginx.conf) to the owner of those files:
Alt解决方案:通过编辑nginx来更改运行用户。conf(例如,/usr/local/nginx/conf/nginx.conf)给这些文件的所有者:
user myuser mygroup;
#3
0
Try this in your location line:
在你的位置上试试这个:
location ~* ^.+\.(js|css|png|jpg|jpeg|gif|ico|html)$ {
or
或
location ~* ^.+.(js|css|png|jpg|jpeg|gif|ico|html)$ {
#4
0
i need to write alterative solution to this problem. I migrate wordpress into plesk server and I get this error with css and js scripts. Nginx configuration produce a bug getting js and css files. If a wordpress error loading CSS and JS scripts (forbidden), it may be due to the configuration of nginx and apache.
我需要写出这个问题的交替解。我将wordpress迁移到plesk服务器,我在css和js脚本中得到了这个错误。Nginx配置产生了一个获取js和css文件的bug。如果wordpress加载CSS和JS脚本时出现错误(被禁止),这可能是由于nginx和apache的配置造成的。
UNLOCK the box of configuration nginx and apache:
打开配置nginx和apache的盒子:
Intelligent processing of static files -> DONT CHECKED
智能处理静态文件->不检查
This solves my problem. I hope others too pymessoft.com
这解决了我的问题。我希望其他人也能浏览pymessoft.com
#5
-1
Make sure that every top level directory has permission levels AND the index.html. Most of the times you will just copy the file you want to see in /www and rename it index.html make sure the new index.html has the right permissions (to be sure 777 just for testing ofcourse).
确保每个*目录都有权限级别和index.html。大多数情况下,您只需复制希望在/www中看到的文件并将其重命名为index。html确保新的索引。html有正确的权限(当然,为了测试当然是777)。
#6
-3
server {
listen 80;
server_name mysite.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
index index.php index.html;
root /full/path/to/public_html;
} <--- you forgot this one
location ~* \.(js|css|png|jpg|jpeg|gif|ico|html)$ {
expires max;
}
location ~ index.php {
include /etc/nginx/fastcgi_params;
keepalive_timeout 0;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
you have to close server{} before defining the location.
在定义位置之前,必须先关闭服务器{}。
or change the owner of the files to www-data or apache if you don't have access to the files.
或者将文件的所有者更改为www-data或apache(如果您没有访问这些文件的权限)。
#1
16
Had the same problem. Fixed it by simply setting the right permissions on my CSS and JS files and folders. Be careful about setting permissions! But for a file to be readable on the web, it has to be readable by the user running the server process.
有同样的问题。通过在我的CSS和JS文件和文件夹中设置正确的权限来修复它。设置权限时要小心!但是要使文件在web上可读,它必须由运行服务器进程的用户可读。
chmod -R +rx css
chmod -R +rx js
Gives read and execute permissions. The -R
is for recursive. Only do this for files you want readable by the world!
授予读取和执行权限。r是递归的。只对你想要被世界读的文件这样做!
#2
1
Alt solution: change the run user by editing the nginx.conf (e.g., /usr/local/nginx/conf/nginx.conf) to the owner of those files:
Alt解决方案:通过编辑nginx来更改运行用户。conf(例如,/usr/local/nginx/conf/nginx.conf)给这些文件的所有者:
user myuser mygroup;
#3
0
Try this in your location line:
在你的位置上试试这个:
location ~* ^.+\.(js|css|png|jpg|jpeg|gif|ico|html)$ {
or
或
location ~* ^.+.(js|css|png|jpg|jpeg|gif|ico|html)$ {
#4
0
i need to write alterative solution to this problem. I migrate wordpress into plesk server and I get this error with css and js scripts. Nginx configuration produce a bug getting js and css files. If a wordpress error loading CSS and JS scripts (forbidden), it may be due to the configuration of nginx and apache.
我需要写出这个问题的交替解。我将wordpress迁移到plesk服务器,我在css和js脚本中得到了这个错误。Nginx配置产生了一个获取js和css文件的bug。如果wordpress加载CSS和JS脚本时出现错误(被禁止),这可能是由于nginx和apache的配置造成的。
UNLOCK the box of configuration nginx and apache:
打开配置nginx和apache的盒子:
Intelligent processing of static files -> DONT CHECKED
智能处理静态文件->不检查
This solves my problem. I hope others too pymessoft.com
这解决了我的问题。我希望其他人也能浏览pymessoft.com
#5
-1
Make sure that every top level directory has permission levels AND the index.html. Most of the times you will just copy the file you want to see in /www and rename it index.html make sure the new index.html has the right permissions (to be sure 777 just for testing ofcourse).
确保每个*目录都有权限级别和index.html。大多数情况下,您只需复制希望在/www中看到的文件并将其重命名为index。html确保新的索引。html有正确的权限(当然,为了测试当然是777)。
#6
-3
server {
listen 80;
server_name mysite.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
index index.php index.html;
root /full/path/to/public_html;
} <--- you forgot this one
location ~* \.(js|css|png|jpg|jpeg|gif|ico|html)$ {
expires max;
}
location ~ index.php {
include /etc/nginx/fastcgi_params;
keepalive_timeout 0;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
you have to close server{} before defining the location.
在定义位置之前,必须先关闭服务器{}。
or change the owner of the files to www-data or apache if you don't have access to the files.
或者将文件的所有者更改为www-data或apache(如果您没有访问这些文件的权限)。