Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a Laravel local environment in Docker

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about how to build a Laravel local environment in Docker. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Install docker

Install docker first.

Clone laradock

Laradock official document: http://laradock.io/

Laradock github: https://github.com/laradock/laradock

Laradock is a PHP runtime environment that includes full functionality for docker and is deployed using docker-compose. (special note: it is not only used for Laravel environment building, but also supports all other PHP frameworks, it is a complete set of PHP environment. )

Deploy the PHP environment

1. Clone laradock

Git clone https://github.com/Laradock/laradock.git

two。 Create an environment variable file

Cp env-example .env

3. Run the services that need to be enabled directly with docker-compose, such as:

Docker-compose up-d nginx mysql redis beanstalkd

This starts the required PHP runtime environment, and php-fpm runs by default, so you don't need to specify it.

Laravel profile

The problem with the Laravel configuration file is that in the .env file, the addresses of mysql and redis need to be filled in like this, rather than in the form of ip addresses:

DB_CONNECTION=mysqlDB_HOST=mysqlDB_PORT=3306DB_DATABASE=tanteng.meDB_USERNAME=rootDB_PASSWORD=rootREDIS_HOST=redisREDIS_PASSWORD=nullREDIS_PORT=6379

Pay attention to the highlights in the code.

Nginx configuration

To access the site locally by domain name, to bind the domain name in host to the local, you also need to add nginx configuration.

As shown in the figure, you can add a configuration file under the sites directory under the nginx folder of the laradock project.

Execute composer

To perform operations such as composer, you need to enter the workspace container and use the command:

Docker-compose exec workspace bash above is the editor to share with you how to build a Laravel local environment in Docker. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report