鍍金池/ 問答/PHP  Linux/ CentOS Laravel 配置了nginx root running時報錯

CentOS Laravel 配置了nginx root running時報錯

Warning: include(/home/www/station/vendor/composer/../symfony/http-kernel/HttpKernelInterface.php): failed to open stream: No such file or directory in /home/www/station/vendor/composer/ClassLoader.php on line 444

Warning: include(): Failed opening '/home/www/station/vendor/composer/../symfony/http-kernel/HttpKernelInterface.php' for inclusion (include_path='.:/usr/local/php/lib/php') in /home/www/station/vendor/composer/ClassLoader.php on line 444

Fatal error: Interface 'Symfony\Component\HttpKernel\HttpKernelInterface' not found in /home/www/station/vendor/laravel/framework/src/Illuminate/Foundation/Application.php on line 25

nginx配置如下:

server {
        listen       80;
        server_name  localhost;

        charset UTF-8;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /home/www/station/public/;
            index  index.html index.htm index.php;
        try_files $uri $uri/ /index.php?$query_string;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /home/www;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
                root            /home/www/station/public/;
                fastcgi_pass    127.0.0.1:9000;
                fastcgi_index   index.php;
                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include         fastcgi_params;
        }
回答
編輯回答
萌吟
server {  
        listen  80;    
        server_name localhost;    
        set $root_path '/data/appname/public';    
        root $root_path;    
        
        index index.php index.html index.htm;    
        
        try_files $uri $uri/ @rewrite;    
        
        location @rewrite {    
            rewrite ^/(.*)$ /index.php?_url=/$1;    
        }    
        
        location ~ \.php {    
        
            fastcgi_pass 127.0.0.1:9000;    
            fastcgi_index /index.php;    
        
            fastcgi_split_path_info       ^(.+\.php)(/.+)$;    
            fastcgi_param PATH_INFO       $fastcgi_path_info;    
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;    
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;    
            include                       fastcgi_params;  
        }    
        
        location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {    
            root $root_path;    
        }    
        
        location ~ /\.ht {    
            deny all;    
        }    
    }

使用這個配置,保證PHP-FPM 已經(jīng)啟動

2017年9月15日 09:47