How to make the project run when there is only a Linux system?

藏色散人
Release: 2022-07-23 14:22:41
forward
2377 people have browsed it

When I only have the Linux system, I do n’t want to install Nginx, PHP, MySQL, but I want to let the project run, what to do, think about it again and again.

Make a dockerfile so that local projects can run in the container!

1. Create a project

How to make the project run when there is only a Linux system?

Please click here to exit full-screen mode:

How to make the project run when there is only a Linux system?

2. Write the dockerfile

"Dockerfile
FROM php:5.6-apache
RUN docker-php-ext-install mysqli
ADD project1 /var/www/html
"
Copy after login

After editing the dockerfile, generate the image. The command is: docker build -t malina_php_project .

When you see
How to make the project run when there is only a Linux system?

, it means the image has been generated successfully

##3. Generate the container and run the image
"
docker run -it -d    --name malina_php_project malina_php_project
"
Copy after login
进行查看镜像是否处于活动状态
docker ps
Copy after login

How to make the project run when there is only a Linux system?

4. Run the file in the container
在浏览器输入localhost,发现这什么鬼,也不报错也不显示,可以docker logs (容器id)18b429b2ceac
看见ip了
Copy after login

How to make the project run when there is only a Linux system?

再次在浏览器输入访问:http://x.x.0.2/phpinfo.php,访问到了开心不,激动不
Copy after login

How to make the project run when there is only a Linux system?

5. What files were added?
ADD project1 /var/www/html
将项目copy到容器的var/www/html目录下,这里只会把project1下面的内容,project1本身目录不复制
Copy after login

How to make the project run when there is only a Linux system?

docker exec -it 18b429b2ceac(容器id) /bin/bash
Copy after login

How to make the project run when there is only a Linux system?

## 6. Directory mounting
docker run -it -v /宿主机目录:/容器目录 镜像名:镜像标签

docker run -it -d -v /home/malina/project/project1:/var/www/html malina_php_project:latest
Copy after login
This article is reprinted, original address: https://learnku.com/articles/69078

The above is the detailed content of How to make the project run when there is only a Linux system?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template