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 install php7 in docker

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the knowledge of "how to install php7 in docker". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Docker installs php7: 1, install Docker;2, install Ngnix image and php image; 3, create new folders and use them for mapping; 4, check whether the php environment is installed successfully by creating index.php.

The operating environment of this paper: Windows7 system, PHP7.1.3, Dell G3.

How does docker install php7?

Build Php7 development environment in Docker seconds

I have always heard that Docker is quite powerful, but I have never understood it. After brushing an introductory course on bilibili today, I almost found a new world. It was really too late to understand the power of Docker. This article on building a php7 environment using Docker requires a bit of getting started. Here we go.

Environment

Install Docker first, whether you are Windows or Linux or MocOS. Install Docker's own Baidu.

Docker mirror source

Just visit https://hub.docker.com, which is a large image repository.

Install the Ngnix image

Enter:

Docker pull nginx installation php image docker pull php:7.1.30-fpm instantiation preparation

Create several new folders to map: site root, nginx configuration files, and log files.

Mkdir-p ~ / nginx/www ~ / nginx/logs ~ / nginx/conf

Create a new: index.php in the newly created www directory to check whether the php environment has been built successfully:

Under the nginx configuration file directory conf, create a new: test-php.conf with the suffix .conf:

Server {listen 80; server_name localhost; location / {root / usr/share/nginx/html; index index.html index.htm index.php;} error_page 500 502 503 504 / 50x.htl; location = / 50x.html {root / usr/share/nginx/html;} location ~\ .php$ {fastcgi_pass php:9000; fastcgi_index index.php Fastcgi_param SCRIPT_FILENAME / www/$fastcgi_script_name; include fastcgi_params;}}

This is the most common default configuration of php, and the default is fine.

Instantiate phpdocker run-- name myphp7-v ~ / nginx/www:/www-d php:7.1.30-fpm instantiate nginxdocker run-- name php-nginx-p 80:80-v ~ / Documents/dock/nginx/www:/usr/share/nginx/html-v ~ / Documents/dock/nginx/conf:/etc/nginx/conf.d-- link myphp7:php-d nginx

This is the designated port, site root directory, site configuration file directory, in fact, there is no specified site log directory, I don't know if you can see it, ha!

Enter docker ps to see:

Visit: 127.0.0.1

Of course, this is a completely smooth result, need to keep trying, just tried a lot of holes to understand some of the details. After understanding it, I feel that the deployment of Docker is really convenient and fast, and the sandboxie mechanism is very clean.

Dig a small hole, and then continue to study how Flask+uwsgi+nginx needs to operate and deploy with docker.

This is the end of "how docker installs php7". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Development

Wechat

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

12
Report