码迷,mamicode.com
首页 > 其他好文 > 详细

百度云BCH虚拟服务器的laravel框架配置

时间:2020-07-21 13:59:06      阅读:93      评论:0      收藏:0      [点我收藏+]

标签:框架   request   uri   min   string   rem   sql   cloud   写入   

  百度云虚拟机BCH的配置要灵活一些,百度云默认目录为/webroot(FTP打开时的目录,其实映射的真实目录是/home/bae/app),但是我们的需求是将项目存放到/webroot/websit下面。在/webroot主目录下新建文件bcloud_nginx_user.conf写入以下配置:

location / {
    root /home/bae/app/website/public;
 
    if (-e $document_root/index.php) {
        ## 获取正则匹配中的数据,wwwxxx.com/test/ 实际访问路径问 www.xxx.com/index.php/test
          rewrite ^/(.*)$ /index.php/$1?$query_string last; 
    }
 
    return 404;
}
 
## php配置
location ~ [^/]\.php(/|$){
    root /home/bae/app/website/public;
    fastcgi_index               index.php;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_intercept_errors    on;
    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;
    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param  QUERY_STRING       $query_string;
    fastcgi_param  REQUEST_METHOD     $request_method;
    fastcgi_param  CONTENT_TYPE       $content_type;
    fastcgi_param  CONTENT_LENGTH     $content_length;
 
    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param  REQUEST_URI        $request_uri;
    fastcgi_param  DOCUMENT_URI       $document_uri;
    fastcgi_param  DOCUMENT_ROOT      $document_root;
    fastcgi_param  SERVER_PROTOCOL    $server_protocol;
    fastcgi_param  REQUEST_SCHEME     $scheme;
    fastcgi_param  HTTPS              $https if_not_empty;
 
    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
 
    fastcgi_param  REMOTE_ADDR        $remote_addr;
    fastcgi_param  REMOTE_PORT        $remote_port;
    fastcgi_param  SERVER_ADDR        $server_addr;
    fastcgi_param  SERVER_PORT        $server_port;
    fastcgi_param  SERVER_NAME        $server_name;
 
    # PHP only, required if PHP was built with --enable-force-cgi-redirect
    fastcgi_param  REDIRECT_STATUS    200;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
   root /home/bae/app/website/public;
   expires 30d;
   access_log off;
}
location ~ .*\.(js|css)?$ {
   root /home/bae/app/website/public;
   expires 7d;
   access_log off;
}
location ~ /\.ht {
   root /home/bae/app/website/public;
   deny all;
}
 
## 禁止敏感文件的直接访问
location ~* \.(inc|bak|sql|lua|so|ini|conf)$ {
    deny all;
}

  注意:当出现重复配置时,bcloud_nginx_user.conf优先级高于bcloud_nginx_gen.conf。由于百度云/webroot映射到系统中的目录为/home/bae/app,所以我们在配置nginx文件的时候需要设置root这个属性。百度云BCH引用的配置文件其实是bcloud_nginx_user*.conf,配置文件名是bcloud_nginx_user_01.conf也可以。百度云在系统中/home/admin/runtime/nginx/conf.d/user-site.conf的默认配置内容如下,可以参考一下:

include /home/bae/app/bcloud_nginx_custom_http*.conf;

server {
    listen       8080 default_server;
    server_name  localhost;

    root /home/bae/app;

    index  index.php index.html index.htm;
    
    include /home/bae/app/bcloud_nginx_user*.conf;
    include /home/bae/app/bcloud_nginx_gen*.conf;

    location ~ \.php($|/) {
        set $path_info "";
        set $real_script_name $fastcgi_script_name;
        
        if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
            set $real_script_name $1;
            set $path_info $2;
        }
        
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
        fastcgi_param SCRIPT_NAME $real_script_name;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param  SERVER_PORT        80;
        include fastcgi_params;
    }
    
    location ~* \.(inc|bak|sql|lua|so|ini|conf)$ {
        deny  all;
    }

}

 

百度云BCH虚拟服务器的laravel框架配置

标签:框架   request   uri   min   string   rem   sql   cloud   写入   

原文地址:https://www.cnblogs.com/qingsong/p/13354365.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!