Php 如何使用Nginx设置文档根以加载Laravel应用程序?

Php 如何使用Nginx设置文档根以加载Laravel应用程序?,php,linux,laravel,nginx,laravel-5,Php,Linux,Laravel,Nginx,Laravel 5,我的网站一直显示phpinfo();当我着陆的时候 我的根目录应该是:/home/forge/aveniros/public 我不知道该把它放在哪里 我决定在以下位置配置我的设置:~/etc/nginx/sites available/default 然后,在保存后运行sudo服务nginx restart。 似乎什么也没起作用 有人能告诉我我做错了什么吗 您需要将服务器名称设置为u,目前您只监听默认名称的请求 server_name _; 使用此虚拟主机 server { list

我的网站一直显示phpinfo();当我着陆的时候

  • 我的根目录应该是:
    /home/forge/aveniros/public
  • 我不知道该把它放在哪里
  • 我决定在以下位置配置我的设置:~/etc/nginx/sites available/default


然后,在保存后运行
sudo服务nginx restart
。 似乎什么也没起作用


有人能告诉我我做错了什么吗

您需要将服务器名称设置为u,目前您只监听默认名称的请求

server_name  _;
使用此虚拟主机

server {
listen       80;
server_name  project.dev;
root /var/www/directory/project/public;

access_log /var/log/nginx/access.log;
error_log  /var/log/nginx/error.log;

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

location ~ \.php/?(.*)$ {

    fastcgi_connect_timeout 3s;     # default of 60s is just too long
    fastcgi_read_timeout 10s;       # default of 60s is just too long

    fastcgi_pass unix:/var/run/php5-fpm.sock; 
    fastcgi_index  index.php;

    include fastcgi_params;

    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
}
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
fastcgi_pass   unix:/var/run/php5-fpm.sock;
include fastcgi_params;
}
} 
}
我的网站正在运行。以下是我的设置: 文件路径:~/etc/nginx/sites available/default

server {
    listen 80 default_server;
    server_name default;
    root /home/forge/aveniros/public;

    #HTTP Authentication Configuartion
    auth_basic "Restricted";
    auth_basic_user_file /home/forge/aveniros/.htpasswd;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;

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

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/default-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

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

所以我不能把它作为默认值,对吗?另外,如何找到我的服务器名?它是linode中的名称吗?只留下一个
index.php现在我没有指定输入文件。
!!!!
server {
    listen 80 default_server;
    server_name default;
    root /home/forge/aveniros/public;

    #HTTP Authentication Configuartion
    auth_basic "Restricted";
    auth_basic_user_file /home/forge/aveniros/.htpasswd;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;

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

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/default-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

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