GithubHelp home page GithubHelp logo

tianmeds / laradock Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 71 KB

This is the way on how to install laradock in your projects

Home Page: https://medium.com/@TianMeds/how-to-install-laradock-to-your-project-1f14f8ac31f6

docker docker-compose laradock laravel nginx docker-containers laravel-framework-10

laradock's Introduction

Laradock

How to install Laradock to your project

So, right now we’re going to talk about how to install a Laradock or a dockerized Laravel application, but first, what is Laradock?

Laradock

  • Laradock simplifies the process of dockerizing Laravel applications, offering a convenient and efficient solution for developers. Dockerizing your Laravel project with Laradock allows you to encapsulate the entire development environment, making it portable and reproducible across different systems. This guide will walk you through the straightforward process of installing Laradock for your Laravel project. You can Visit Laradock Documentation here

Tools We need

  • Docker
  • Visual Studio Code or any IDE you want
  • Browser
  • Composer Installed
  • PHP Installed

Steps for Installing Laradock

  • Step 1: Create a folder of you want to create your file, so in my case i create a folder structure like this

  •  Folder Structure
  • Step 2: So you should cd to your Backend Folder, so if you are in the Desktop this is how you will do it.

  • cd Main Folder
    cd Backend Folder
    
  • Step 3: Clone Laradock to folder of choice

  • git clone https://github.com/Laradock/laradock.git
    
  • Step 4: Enter the Laradock folder created inside the Backend Folder, so it means that you will cd again after that rename .env.example to .env

  • cp .env.example .env
    
  • Step 5: Change PHP version in .env to 8.2

  • PHP Version ENV
  • Step 6: Run your Docker containers

  • docker-compose up -d nginx mysql phpmyadmin workspace
    
  • Step 7: Enter Workspace container, to run commands like artisan, phpunit

  • docker-compose exec workspace bash
    
  • Step 8: Create the project or the Laravel Application

  • composer create-project laravel/laravel `your-project-name`
    
  • Step 9: Create DB for the project

    • Open phpMyAdmin, localhost:8081
    • server: mysql
    • username: root
    • pass: root
  • Step 10: Create NGINX Configuration for the project

  • Note you can name it all the way you i just make it consistent so not too hard to remember

    1. Open /nginx/sites/
    2. Duplicate laravel.conf.example
    3. Rename the duplicate to `your-project-name`.conf
    4. Change these Lines 18-19
        server_name `your-project-name`; // add that to your machines /etc/hosts
        root /var/www/`your-project-name`/public;
    
  • Step 11: Now after that make sure to go to your /etc/hosts in your Unit for window users you can thru it by

  • C Drive -> Windows -> System32 -> Drivers -> etc -> hosts
    

    Note: Make sure to run the hosts as Administrator

    After that edit the hosts file to like this and then saved it.

    --- hosts file ---
    
    #End of section
    127.0.0.1  `Name it on what you named in the step 10`
    
  • Step 12: Now Laravel Interface should be searchable and seen when you search it, It will be like this when you search it.

  • http://name-you-put-in-hosts-and-step10
    

    This is the output should look or make sure its accessible in short

    Laravel Interface

Issues might encounter

  • First Issue: 404 not found:: Can’t access the static Laravel front-end

  • Ensure that Nginx has the necessary permissions to access the files in your Laravel project. The Nginx process needs to have read permissions for the files and execute permissions for the directories.

    docker-compose exec workspace chmod -R 755 /var/www/your-project-name
    
  • Second Issue: laravel — The stream or file “/storage/logs/laravel.log” could not be opened in append mode: failed to open stream: Permission denied

  • /var/www/`project-name`#  sudo chmod -R ugo+rw storage
    

Notes

  • Rebuilding a container
docker-compose build `container` 
docker-compose build workspace
  • Recreating a container
docker-compose up -d `container`
docker-compose up -d workspace

References

Special Contribution

Special thanks also for John Christian Berbon for this guide

laradock's People

Contributors

tianmeds avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.