一般企业正式服环境用的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/
- 运行成功
编辑