您的位置 首页 php

docker安装PHP:5.4.45-fpm镜像搭建本地环境

## 安装docker

brew install –cask –appdir=/Applications docker

## 搜索镜像

## 下载镜像

docker pull php:5.4.45-fpm

## 创建并运行容器

docker run –name myphp-fpm -p 9001:9000 -v /www:/www –privileged=true -d php:5.4.45-fpm

1.本地9001端口映射容器9000端口

2.容器名称 myphp-fpm

3.本地www目录映射容器www目录

## 进入容器

sudo docker exec -it 容器ID /bin/bash

安装工具和扩展

# 安装 ifconfig, ping

apt update

apt install net-tools iputils-ping

# 安装依赖(安装gd扩展等必须要先安装系统依赖)

apt install libfreetype6-dev libmcrypt-dev libpng-dev libjpeg-dev libpng-dev sendmail zlib1g-dev

# docker-php-ext-install 安装扩展

docker-php-ext-install mysql

docker-php-ext-install gd

docker-php-ext-install zip

docker-php-ext-install mbstring

docker-php-ext-install pdo_mysql

# 个别扩展需要pecl安装,容器自带pecl

pecl install redis-4.0.1

docker-php-ext-enable redis

# 重启容器

## 配置宿主机nginx

本地/www目录

fastcgi解析目录为容器映射目录 /www

“`

server {

listen 80;

server_name localhost;

root /www;

index index.php index.html;

# location / {

# if (!-e $request_filename) {

# rewrite ^(.*)$ /index.php?s=/$1 last;

# break;

# }

# }

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.php$ {

fastcgi_pass 127.0.0.1:9001;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /www/$fastcgi_script_name;

include fastcgi_params;

}

}

“`

## 其他

安装vim : apt-get install vim

更新软件列表: apt-get update

## 注意

容器访问宿主机数据库

host需要改成 host.docker.internal

不能用 127.0.0.1

文章来源:智云一二三科技

文章标题:docker安装PHP:5.4.45-fpm镜像搭建本地环境

文章地址:https://www.zhihuclub.com/150004.shtml

关于作者: 智云科技

热门文章

评论已关闭

6条评论

  1. The incidence of reactive arthritis varies considerably based on a host of factors, including geographic differences between populations, genetic makeup, and local pathogens

  2. Women, are you increasingly noticing subtle signs that your body just isn t at peak performance anymore 03, Center for Multilevel Modeling, Bristol, UK

  3. 3 versus cryopreserved sperm quality or not be fertile time we recommend taking clomid Moreover, we recently found that the HIF 1О± gene bears a canonical ER binding element that responds to estrogen signaling, demonstrating a direct regulatory link between the ERО± and HIF 1О± pathways in breast cancer 14

网站地图