侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

ubuntu中搭建lnmp环境部署laravel9框架项目流程步骤

框架(架构)  /  管理员 发布于 3年前   1919

ubuntu系统中部署laravel9框架项目,centos7马上就要停止维护;

我打算后面可能用ubuntu替换,所以先搞两个项目跑跑测试测试;

不过后面的话基本也是用基于docke的dnmp环境了。

ubuntu版本:

root@iZwz984fp76m12whtx8tpgZ:~# lsb_release -a
LSB Version:core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID:Ubuntu
Description:Ubuntu 20.04.3 LTS
Release:20.04
Codename:focal


lnmp环境:LNMP一键安装包V1.8正式版

root@iZwz984fp76m12whtx8tpgZ:~# php -v
PHP 8.0.8 (cli) (built: Mar  2 2022 11:43:54) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.8, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.8, Copyright (c), by Zend Technologies
root@iZwz984fp76m12whtx8tpgZ:~# mysql -V
mysql  Ver 8.0.28 for Linux on x86_64 (Source distribution)
root@iZwz984fp76m12whtx8tpgZ:~# nginx -v
nginx version: nginx/1.20.1

安装好了 如下:

root@iZwz984fp76m12whtx8tpgZ:~# lnmp status
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
nginx (pid 222682) is running...
php-fpm is runing!
● mysql.service - MySQL Community Server
     Loaded: loaded (/etc/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-03-02 13:13:24 CST; 2h 11min ago
    Process: 222699 ExecStart=/etc/init.d/mysql start (code=exited, status=0/SUCCESS)
   Main PID: 222714 (mysqld_safe)
      Tasks: 17 (limit: 19140)
     Memory: 171.1M
     CGroup: /system.slice/mysql.service
             ├─222714 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/var --pid-file=/usr/local/mysql/var/iZwz984fp76m12whtx8tpgZ.pid
             └─223225 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-err…
Mar 02 13:13:22 iZwz984fp76m12whtx8tpgZ systemd[1]: Starting MySQL Community Server...
Mar 02 13:13:22 iZwz984fp76m12whtx8tpgZ mysql[222699]: Starting MySQL
Mar 02 13:13:24 iZwz984fp76m12whtx8tpgZ mysql[222699]: .. *
Mar 02 13:13:24 iZwz984fp76m12whtx8tpgZ systemd[1]: Started MySQL Community Server.


安装opcache 

root@iZwz984fp76m12whtx8tpgZ:~/lnmp1.8# ./addons.sh install opcache 


注释掉fastcgi.conf中的open_basedir的配置,安全问题会出现500错误

/usr/local/nginx/conf/fastcgi.conf
#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";



在php.ini配置文件中删除php禁用函数disable_functions

/usr/local/php/etc/php.ini 
proc_open,proc_get_status


创建laravel9项目nginx配置文件 做点简单配置

/usr/local/nginx/conf/vhost/laraver9.conf
server
    {
        listen 80;
        server_name laravel9.com;
index index.html index.htm index.php;
root  /home/www/laravel9/public;
        #error_page   404   /404.html;
        include enable-php.conf;
        location /nginx_status
        {
            stub_status off;
            access_log   off;
        }
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }
      
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
access_log   off;
        }
        location ~ .*\.(js|css)?$
        {
           #expires      12h;
access_log   off;       
 }
        location ~ /\.
        {
            deny all;
        }
        access_log  /home/wwwlogs/laravel9.log;
}


拉取laravel9项目准备

因为我用的是阿里云ecs所以git,composer都默认装好了

root@iZwz984fp76m12whtx8tpgZ:~# git version
git version 2.25.1
root@iZwz984fp76m12whtx8tpgZ:~# composer -v
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.2.6 2022-02-04 17:00:38

新建laravel9项目存放目录/home/www

root@iZwz984fp76m12whtx8tpgZ:~# cd /home/www
root@iZwz984fp76m12whtx8tpgZ:/home/www# ll
total 8
drwxr-xr-x 2 root root 4096 Mar  2 12:37 ./
drwxr-xr-x 5 root root 4096 Mar  2 12:37 ../

composer拉取最新laravel9.2框架代码

root@iZwz984fp76m12whtx8tpgZ:/home/www# composer create-project --prefer-dist laravel/laravel laravel9
Creating a "laravel/laravel" project at "./laravel9"
Installing laravel/laravel (v9.1.0)
  - Installing laravel/laravel (v9.1.0): Extracting archive
Created project in /home/www/laravel9
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 108 installs, 0 updates, 0 removals
  - Locking brick/math (0.9.3)
...
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 108 installs, 0 updates, 0 removals
  - Downloading doctrine/inflector (2.0.4)
...
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: laravel/sail
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: spatie/laravel-ignition
Package manifest generated successfully.
78 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
No publishable resources for tag [laravel-assets].
Publishing complete.
> @php artisan key:generate --ansi
Application key set successfully.


最后统一重启lnmp服务 

root@iZwz984fp76m12whtx8tpgZ:~# lnmp restart

注意:

我这里是统一重启,之前的php配置文件修改也的单独重启php-fpm服务;

修改nginx配置文件也的热加载nginx配置文件 先检测后reload

root@iZwz984fp76m12whtx8tpgZ:~# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
root@iZwz984fp76m12whtx8tpgZ:~# /usr/local/nginx/sbin/nginx -s reload


客户端修改一下hosts 本地解析一下域名

C:\Windows\System32\drivers\etc\hosts
10.0.1.180  laravel9.com


访问一下

laravel9.png



  • 上一条:
    centos7+dnmp环境中部署laravel8框架项目的流程步骤
    下一条:
    go语言包管理工具Go Module在go1.16版本中更新的功能
  • 昵称:

    邮箱:

    2条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • Filament v3.1版本发布(0个评论)
    • docker + gitea搭建一个git服务器流程步骤(0个评论)
    • websocket的三种架构方式使用优缺点浅析(0个评论)
    • ubuntu20.4系统中宿主机安装nginx服务,docker容器中安装php8.2实现运行laravel10框架网站(0个评论)
    • phpstudy_pro(小皮面板)中安装最新php8.2.9版本流程步骤(0个评论)
    • 近期文章
    • 在go+gin中使用"github.com/skip2/go-qrcode"实现url转二维码功能(0个评论)
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • 在go + gin中gorm实现指定搜索/区间搜索分页列表功能接口实例(0个评论)
    • 在go语言中实现IP/CIDR的ip和netmask互转及IP段形式互转及ip是否存在IP/CIDR(0个评论)
    • PHP 8.4 Alpha 1现已发布!(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2018-05
    • 2020-02
    • 2020-03
    • 2020-05
    • 2020-06
    • 2020-07
    • 2020-08
    • 2020-11
    • 2021-03
    • 2021-09
    • 2021-10
    • 2021-11
    • 2022-01
    • 2022-02
    • 2022-03
    • 2022-08
    • 2023-08
    • 2023-10
    • 2023-12
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客