怎么在Docker中配置一個(gè)PHP開(kāi)發(fā)環(huán)境?相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。
站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到永善網(wǎng)站設(shè)計(jì)與永善網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊(cè)、虛擬主機(jī)、企業(yè)郵箱。業(yè)務(wù)覆蓋永善地區(qū)。配置自己的php鏡像
首先在自己的任意一個(gè)目錄下創(chuàng)建如下三個(gè)文件
run.sh
#!/bin/bash /usr/sbin/php-fpm7.0 /usr/sbin/nginx tailf /etc/apt/sources.list
sources.list
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties deb http://archive.canonical.com/ubuntu xenial partner deb-src http://archive.canonical.com/ubuntu xenial partner deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
Dockerfile
FROM ubuntu:16.04 # =========================== # 配置虛擬主機(jī) # -v default:/etc/nginx/sites-enabled/default # 配置程序目錄 # -v web:/var/www/html # 配置映射端口 # -p 8008:80 # =========================== MAINTAINER chengtao "751753158@qq.com" ADD sources.list /etc/apt/sources.list ADD run.sh /root/run.sh RUN chmod +x /root/run.sh RUN apt-get update RUN apt-get install -y php-fpm php-mysql nginx RUN sed -i 's/;date.timezone =/date.timezone = Asia\/Shanghai/' /etc/php/7.0/fpm/php.ini RUN mkdir -p /run/php/ EXPOSE 80 CMD ["/bin/bash","/root/run.sh"]
執(zhí)行命令
docker build -t d1studio:php-base:0.1 .
配置php mysql開(kāi)發(fā)環(huán)境
mkdir -p ~/projects/php-app cd ~/projects/php-app mkdir mysql mkdir www
www/index.php
nginx.conf
server { listen 80 default_server; root /var/www/html; index index.html index.htm index.php; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } }docker-compose.yml
version: '2' services: mysql: image: mysql:5.6 volumes: - ./mysql/:/var/lib/mysql/ ports: - "3307:3306" environment: - MYSQL_ROOT_PASSWORD=123456 php-app: image: d1studio/php-base:0.1 ports: - "8009:80" volumes: - ./nginx.conf:/etc/nginx/sites-enabled/default - ./www/:/var/www/html/ links: - mysql開(kāi)啟php的測(cè)試項(xiàng)目
#開(kāi)啟 docker-compose up #關(guān)閉 docker-compose down看完上述內(nèi)容,你們掌握怎么在Docker中配置一個(gè)PHP開(kāi)發(fā)環(huán)境的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
分享題目:怎么在Docker中配置一個(gè)PHP開(kāi)發(fā)環(huán)境-創(chuàng)新互聯(lián)
路徑分享:http://weahome.cn/article/dpjcod.html