linux安装lnmp一键安装包(解决安装laravel的Warning: file_exists(): open_basedir restriction in effect)

一般企业正式服环境用的lnmp.org一键安装包,下面做下简单介绍:

官网:https://lnmp.org

1.安装(官网上有详细的安装步骤)

  • screen -S lnmp是为了在安装的过程中,断线的后台会继续保持执行

执行安装命令:

#目前是最新的在线安装命令,后续更新按照官网最新的安装
wget https://soft.lnmp.com/lnmp/lnmp2.1.tar.gz -O lnmp2.1.tar.gz && tar zxf lnmp2.1.tar.gz && cd lnmp2.1 && ./install.sh lnmp
  • 出现ok安装成功

2.添加站点(添加、删除虚拟主机及伪静态管理

参考地址:LNMP添加、删除虚拟主机及伪静态使用教程 - LNMP一键安装包

#添加站点
lnmp vhost add

  • 填写伪静态,这里填写laravel

  • 对应的目录安装laravel
composer create-project --prefer-dist laravel/laravel laravel 8.*

  • 修改nginx上配置的项目路径 主要修改root  /home/wwwroot/host.xxx.cn/laravel/public
cd /usr/local/nginx/conf/vhost/
vim 你的配置.conf

server
    {
        listen 80;
        #listen [::]:80;
        server_name host.xxx.cn ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/host.xxx.cn/laravel/public;

        include rewrite/laravel.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php-pathinfo.conf;

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

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

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/host.hojian.cn.log;
    }
  • 重载nginx
重载nginx
lnmp nginx reload
  • 打开php调试模式,开启错误提示
#进入php.ini目录修改
cd /usr/local/php/etc
vim php.ini
#把display_errors = Off 改成 On
display_errors = Off
display_errors = On
#重载php
lnmp php-fpm reload

  • 打开网页会报这样的错Warning: file_exists(): open_basedir restriction in effect.

  • 解决 /usr/local/nginx/conf/fastcgi.conf 将$document_root改为/home/wwwroot
进入nginx配置目录
/usr/local/nginx/conf
#编辑fastcgi.conf
vim fastcgi.conf
#将$document_root改为/home/wwwroot
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
fastcgi_param PHP_ADMIN_VALUE "open_basedir=/home/wwwroot/:/tmp/:/proc/";
#重启nginx
lnmp nginx reload
  •  Laravel 项目需要对目录 storage/, bootstrap/cache, public / 赋予读写权限

#赋予三个目录读写权限
chmod -R 777 bootstrap/
chmod -R 777 storage/
chmod -R 777 public/
  • 运行成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值