• nginx安装laravel 7.3


    安装php72w

    安装mysql57

    安装nginx

    下面说安装 laravel7.3

    安装下载composer,然后拷贝到bin目录

    curl -sS https://getcomposer.org/installer | php

    mv composer.phar /usr/bin/composer

    chmod +777 /usr/bin/composer

    #查看版本

    composer -V

    #更新国内镜像源

    composer config -g repo.packageist composer https://packagist.phpcomposer.com

    cd /usr/share/nginx/html

    #composer create-project laravel/laravel test "5.5.*"  #指定版本,但是没有安装成功

    #安装test应用

    composer create-project laravel/laravel test

    如果遇到目录已经存在test,就删除。

    编辑nginx.conf,将根目录指定到test的public目录

     server {
            listen       80;
            listen       [::]:80;
            server_name  _;
     #       root         /usr/share/nginx/html;
            root  /usr/share/nginx/test/public;
            # Load configuration files for the default server block.
            include /etc/nginx/default.d/*.conf;
    
            location /{
            root /usr/share/nginx/test/public;
            index index.php index.html index.htm;
            try_files $uri $uri/ /index.php?$query_string;
            }
          
    
    
             location ~\.php($|/) {                        # 后缀关键,~\ 之间无空格
    
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_split_path_info ^(.+\.php)(.*)$;      #关键,访问二级目录时必须
                fastcgi_param   PATH_INFO $fastcgi_path_info;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param    PATH_TRANSLATED    $document_root$fastcgi_path_info;
                include        fastcgi_params;
            }

    安装完毕后,进入test目录,接着安装laravel-admin

    cd test

    composer require encore/laravel-admin

    php artisan vendor:publish --provider="Encore\Admin\AdminServiceProvider"

    这一步需要编辑  test目录下的.env文件,写上数据库连接信息,并且在mysql中建立 laravel 数据库

    php artisan admin:install

    安装完毕后,登录 ,用户名admin,密码admin

    回到test根目录

    创建控制器

    php artisan admin:make UserController  --model=App\\User

    创建路由

    vim test/routes/web.php

    <?php
    
    use Illuminate\Support\Facades\Route;
    
    /*
    |--------------------------------------------------------------------------
    | Web Routes
    |--------------------------------------------------------------------------
    |
    | Here is where you can register web routes for your application. These
    | routes are loaded by the RouteServiceProvider within a group which
    | contains the "web" middleware group. Now create something great!
    |
    */
    
    Route::get('/', function () {
        return view('welcome');
    });
    
    
    Route::get('/u',function(){
    
     return view('test');
    });
    ~                   

    在resource目录下views建立 test.blade.php 文件,即可实现访问。http://47.104.226.34/u

  • 相关阅读:
    TCP协议的常见面试题
    Fedora 31 Beta 发布
    教你玩转Git-合并冲突
    使用Python搭建http服务器
    如何在Linux中复制文档
    小知识:讲述Linux命令别名与资源文件的区别
    centos7配置nfs共享存储服务
    30个关于Shell脚本的经典案例(中)
    轻量级前端MVVM框架avalon
    轻量级前端MVVM框架avalon
  • 原文地址:https://www.cnblogs.com/sdgtxuyong/p/15958460.html
Copyright © 2020-2023  润新知