Laravel 5.2在使用Nginx服务器的PHP 5.6中无法运行

时间:2017-08-29 10:50:07

标签: php .htaccess nginx laravel-5 laravel-5.2

我目前正在将我的网站从Apache迁移到nginx,但我的.htaccess文件无效。如何在我的nginx服务器中使用.htaccess?

我的nginx配置文件:

server {
#listen 8000;
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
#listen [::]:80 default_server;

root /var/www/html;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

server_name localhost;

location /phpmyadmin {
           root /usr/share/;
           index index.php index.html index.htm;
           location ~ ^/phpmyadmin/(.+\.php)$ {
                   try_files $uri =404;
                   root /usr/share/;
                   fastcgi_pass unix:/var/run/php5-fpm.sock; # or 127.0.0.1:9000
                   fastcgi_index index.php;
                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                   include /etc/nginx/fastcgi_params;
           }
           location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                   root /usr/share/;
           }
    }
    location /phpMyAdmin {
           rewrite ^/* /phpmyadmin last;
    }

location / {
        try_files $uri $uri/ /index.php?$query_string;
}

# Remove trailing slash to please routing system.
    if (!-d $request_filename) {
        rewrite     ^/(.+)/$ /$1 permanent;
    }

location ~ \.php$ {
    #try_files $uri =404;
    try_files $uri /index.php =404;
    #fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
}

location ~ /\.ht {
    deny all;
}
}

我尝试了什么:

sudo chown -R www-data:www-data *

sudo chown -R root:root *

我也试图改变

try_files $uri $uri/ /index.php?$query_string;
try_files $uri $uri/ /index.php$is_args$args;
try_files $uri $uri/ /index.php;

php artisan cache:clear

google中的大部分问题我都读过,但没有任何帮助。

0 个答案:

没有答案