在nginx配置文件中删除了index.php就报错

本文介绍了一个关于Nginx配置文件中index设置的问题及解决方案,通过调整index配置解决了Nginx重启失败的问题,并提供了正确的配置示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[root@izkbs00av8xzccz conf.d]# systemctl restart nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

[root@izkbs00av8xzccz conf.d]# vim default.conf

###################### Default ################################
server
{
    listen 80 default_server;
    server_name www.mydomain.com mydomain.com;
    index index.html index.htm index.php; #此行我去掉了index.php 和前面的index就出现报错
    root  /data/wwwroot/default;
    error_log /var/log/nginx/default-error.log crit;

    location ~ .*\.php$
    {
        fastcgi_pass  unix:/dev/shm/php-fpm-default.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
        try_files $uri = 404;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma|mp4|ico)$
    {
        expires      30d;
        access_log off;
    }

    location ~ .*\.(js|css)$
    {
        expires      7d;
        access_log off;
    }

    location ~* \.(ftpquota|htaccess|htpasswd|asp|aspx|jsp|asa|mdb)?$ {
        deny all;
    }

################################ SSL #########################################
#listen 443 ssl;
#ssl on;
#ssl_certificate /data/cert/xxx.crt;
#ssl_certificate_key /data/cert/xxx.key
#ssl_session_timeout 5m;
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
#ssl_prefer_server_ciphers
## 301 重定向 http => https
#if ( != "https") {
#return 301 https://;
#}
############################### extra ########################################
     include /etc/nginx/conf.d/extra/*.conf;
}

[root@izkbs00av8xzccz conf.d]# systemctl restart nginx #正确

转载于:https://my.oschina.net/botkenni/blog/1603193

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值