ubuntu中搭建lnmp环境部署laravel9框架项目流程步骤
框架(架构)  /  管理员 发布于 3年前   1901
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
访问一下
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号