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

What is the configuration for developing PHP with Docker

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Use Docker to develop PHP configuration, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

PHP, or "hypertext preprocessor", is a general open source scripting language. PHP is a scripting language executed on the server side, which is similar to C language and is a commonly used website programming language. PHP's unique syntax is a mix of C, Java, Perl, and PHP's own syntax.

Create a new PHP project folder

Create a new folder in. / app (this article takes my_php_project as an example).

$cd lnmp/app$ mkdir my_php_project$ cd my_php_project$ vi index.php

For Windows 10 users, please create a new one manually in Explorer.

Configure NGINX

Open. / config/nginx/, to create a new NGINX configuration file my_php_project.conf

$cd config/nginx$ vi my_php_project.conf

For the contents of the configuration file, please refer to the sample configuration file in this directory (both http or https have a sample configuration)

Windows 10 users please manually create and edit the configuration file in Explorer

Start / restart the project

# $. / lnmp-docker up$. / lnmp-docker restart nginx

For Windows 10 users, please execute it in Power Shell, which will not be discussed later.

Verification

When a browser opens DOCKER_HOST, there are several situations:

Generally 127.0.0.1

If your Docker is running on a virtual machine, please open the corresponding virtual machine IP

If your Docker runs on a CVM (Ali Cloud, Tencent Cloud, etc.), please open the corresponding public network IP

Multi-domain name configuration

Please set up your own development environment / etc/hosts

We can assign a URL to each project. After the above introduction, we should already know how to configure it. Here is a brief example.

For example, we have the following two projects

. / app/my_first_project corresponding URL app1.khs1994.com./app/my_other_project corresponding URL app1.khs1994.com

Then we create two new NGINX files in the. / config/nginx/ directory

App1.khs1994.com.confapp1.khs1994.com.conf

Then restart, or start the project.

The following command chooses one of the two to execute, and if the project has been started before, restart, otherwise start.

Restart the project

$. / lnmp-docker restart nginx

Start the project

$. / lnmp-docker up

The browser opens the URL to test.

Original address: https://www.linuxprobe.com/php-docker-configuration.html

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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