欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

lnmp环境下 配置laravel项目指向public目录

程序员文章站 2022-03-04 12:47:45
...
  1. lnmp环境已装好
  2. laravel 项目也装好

    首先,我声明下我的项目路径:
    laravel 项目: /home/wwwroot/movie/
    laravel 项目配置文件:/usr/local/nginx/conf/vhost/movie.conf

下面开始配置:
修改

/usr/local/nginx/conf/fastcgi.conf

将里面的

fastcgi_param PHP_ADMIN_VALUE “open_basedir=$document_root/:/tmp/:/proc/”;

给删掉或注释掉,结果如下:

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;
#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

第二步,将项目路径指向public目录:
修改

/usr/local/nginx/conf/vhost/movie.conf
将路径指向public 目录
root /home/wwwroot/movie/public;

第三步,到项目根路径下,如果存在 .user.ini 文件,就删掉
删除方法:

chattr -i .user.ini & rm .user.ini -rf

第四步,在public 目录下创建 .user.ini 文件(有就不用创建了)
修改里面的内容为:

open_basedir=/home/wwwroot/movie/:/tmp/:/proc/

第五步,重启lnmp 你就能看到你的项目配置完了

lnmp restart

相关标签: 项目部署