Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在nginx 1.13.3中为laravel 5.x配置default.conf_Php_Laravel_Nginx_Laravel 5 - Fatal编程技术网

Php 如何在nginx 1.13.3中为laravel 5.x配置default.conf

Php 如何在nginx 1.13.3中为laravel 5.x配置default.conf,php,laravel,nginx,laravel-5,Php,Laravel,Nginx,Laravel 5,在我们将/etc/nginx/sites available/default更改为 server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /var/www/laravel/public; index index.php index.html index.htm; # Make site accessible from http://local

在我们将/etc/nginx/sites available/default更改为

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

    root /var/www/laravel/public;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    server_name <Your Domain name / Public IP Address>;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.php?$query_string;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }
    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }
}

但在nginx 1.13.3中,我们如何放置这些更改?

似乎您以前使用过ubuntu,这就是为什么您发现这些站点可用且启用了站点的目录,因为nginx本身的设置中没有这些。因此,您可以将默认配置文件直接放入

/etc/nginx/conf.d/default  #default is your configuration file
或者创建/etc/nginx/sites available和/etc/nginx/sites enabled,然后在/etc/nginx/nginx.conf内编辑http块并添加此行

include /etc/nginx/sites-enabled/*;
所有文件都应该在站点内部可用,然后在启用的站点内部为它们创建符号链接

默认文件路径:/etc/nginx/sites available

您也可以在那里创建新文件

您可以签出laravel的ngnix示例默认文件:


您正在查找default.conf吗?如果是这样,您可以在/etc/nginx/conf.d或/etc/nginx/sites中找到它。这取决于您的/etc/nginx/nginx.conf文件.Sagar中包含了哪一个,虽然这个链接可能会回答这个问题,但最好在这里包含答案的基本部分,并提供链接供参考。
server {
    #if single domain then uncomment following line
   # listen 80 default_server;

    server_name example.com www.example.com;  #add your domain name here

    access_log /var/www/laravel-example.com/logs/access.log; # change path as per your application
    error_log /var/www/laravel-example/logs/error.log;

    root /var/www/example.com/public;  #laravel application full path
    index index.php index.html;

    # serve static files directly
    location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
        access_log off;
        expires max;
        log_not_found off;
    }

    # removes trailing slashes (prevents SEO duplicate content issues)
    if (!-d $request_filename)
    {
        rewrite ^/(.+)/$ /$1 permanent;
    }

    # enforce NO www
    if ($host ~* ^www\.(.*))
    {
        set $host_without_www $1;
        rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
    }

    # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
    if (!-e $request_filename)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }

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

    location ~* \.php$ {
        try_files $uri = 404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock; # may also be: 127.0.0.1:9000;  this path is as your php version
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

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