我正在使用nginx,需要有关配置的帮助。如果我将位置更改为
root /var/www/html
到
root /spectrum/public
在index.html文件所在的位置,出现500错误。
看看nginx默认文件
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root spectrum/public;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name pretected.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/index.html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
使用默认位置/var/www/html
,我从nginx
进入了欢迎页面,但是当我更改位置时,我得到的只是500错误。
我在/
行尝试了/
,而没有root /spectrum/public
请帮助我修复它。预先感谢。
答案 0 :(得分:1)
执行此操作:
chown -R www-data /spectrum
然后将文档根目录改回
重新启动nGinx,看看效果是否更好。
文件不可全局写入。它们仅限于写入文件的所有者。
Web服务器必须在特定用户下运行。该用户必须存在。
如果您决定在其他用户ID下运行它,则该用户必须是文件的有效所有者才能获得适当的特权。
创建特定用户可以更轻松地识别文件,并且可以一致地识别要添加到站点的新文件和文件夹的ID。
默认情况下,所有者的配置为www-data