ggppc

107 经验值

nginx 配置文件如下

    server {
    server_name laravel.mengniang.tv ;
    listen 80;
    index index.php index.html index.htm;
    root /usr/share/nginx/laravel/web;

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


    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9001;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PHP_VALUE         open_basedir=$document_root:/tmp/:/proc/;
        include        fastcgi_params;
    }

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

    location ~ .*\.(js|css)$
    {
        expires      12h;
    }


    access_log  /usr/share/nginx/laravel/log/static_access.log access;
    error_log  /usr/share/nginx/laravel/log/static_error.log error;
}

如果root 去掉public的话public同级目录的php文件又不能访问了,郁闷,求解答,谢谢

如果root 是..../public 的话 public同级目录的php文件又不能生效,郁闷

NGINX配置文件如下
server {

server_name laravel.mengniang.tv ;
listen 80;
index index.php index.html index.htm;
root /usr/share/nginx/laravel/web;

location / {
try_files $uri $uri/ /index.php?$query_string;
}       #rewrite end
location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9001;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  PHP_VALUE         open_basedir=$document_root:/tmp/:/proc/;
    include        fastcgi_params;
}

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

location ~ .*\.(js|css)$
{
    expires      12h;
}
access_log  /usr/share/nginx/laravel/log/static_access.log access;
error_log  /usr/share/nginx/laravel/log/static_error.log error;

}

这样就造成url是localhost/public 才能访问laravel项目
怎么配置才能使网址变成localhost