在 macOS 下用 Docker 配置 Lumen 開發(fā)環(huán)境

Lumen

就在兩三天前(開始寫這個(gè)文章是 9 月 8 號,確實(shí)是 2闷叉,3 天前庇勃,然而寫完的時(shí)候已經(jīng)是 9 月 25 號了檬嘀,?? ),Lumen 發(fā)布了 5.5 版本责嚷。傻乎乎的我就在第一時(shí)間把現(xiàn)有運(yùn)行著 Lumen 5.4 的系統(tǒng)都升級到了 5.5 版本鸳兽。因?yàn)楹芏鄸|西變化了,升級過程中出現(xiàn)了不少的坑再层,尤其是第三方的庫對于新系統(tǒng)的支持還非常的不好。

不過今天主要想要討論的不是如何將 Lumen 從 5.4 升級到 5.5堡纬,而是介紹如何搭建 Lumen 開發(fā)環(huán)境聂受。

之前 Madison 同學(xué)一直苦惱于如何在 macOS 下搭建基于 PHP 的 Lumen 開發(fā)環(huán)境,我就隨手把配置文件給他了烤镐,也沒有時(shí)間好好解釋一下為什么蛋济。

正好借著這次系統(tǒng)升級的機(jī)會(huì),寫篇文章簡單介紹下炮叶,也算是給 Madison 同學(xué)一個(gè)交代了碗旅。

準(zhǔn)備工作

安裝 Docker

作為一個(gè)使用 macOS 的工程師,Homebrew 是必不可少的镜悉,沒有的話自己安裝吧祟辟。

首先安裝 Docker 相關(guān)的程序

brew update
brew install docker docker-machine docker-compose

如果你沒有安裝過 VirtualBox 的話,你還需要先安裝一個(gè)

brew cask install virtualbox

接著創(chuàng)建一個(gè) Docker 虛擬機(jī)侣肄,名字用 default 就好旧困,當(dāng)然你也可以改成你喜歡的名字

docker-machine create default

接著就是要下載需要的 Docker 鏡像了

docker pull tommylau/php:7.1
docker pull nginx:1.12-alpine
docker pull mysql:5.7

分別對應(yīng)我們需要的 MySQLPHPNginx稼锅,到這里 Docker 的準(zhǔn)備工作就算是完成了吼具。

獲取 Lumen 程序

Lumen 官方的建議是使用命令行的方式來安裝,因?yàn)槲以趯戇@篇文章的時(shí)候矩距,官方的 Lumen 還停留在 5.4 的版本拗盒,沒有 5.5 的版本,所以我就直接下載了锥债。

https://github.com/laravel/lumen/archive/v5.5.0.tar.gz

tar zxvf lumen-5.5.0.tar.gz

解壓縮到任意目錄陡蝇,然后進(jìn)入該目錄脆侮,Lumen 的準(zhǔn)備工作就算是完成了该溯。

Nginx 配置文件

在 Lumen 目錄里面創(chuàng)建一個(gè)名為 default.conf 的 Nginx 配置文件,內(nèi)容如下:

server {
    listen       80;
    server_name  localhost;

    root /var/www/public;
    index index.html index.htm index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass   php:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $request_filename;
        include        fastcgi_params;
    }
}

配置 Docker compose 文件

創(chuàng)建一個(gè)名為 docker-compose.yml 的文件驻民,用于配置 MySQL绽左、PHP悼嫉、Nginx 服務(wù),同時(shí)還會(huì)創(chuàng)建一個(gè)用于數(shù)據(jù)庫的存儲空間拼窥。

version: '3'

services:
  mysql:
    image: mysql:5.7
    volumes:
      - data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: Passw0rd
      MYSQL_DATABASE: lumen
      MYSQL_USER: lumen
      MYSQL_PASSWORD: lumen

  php:
    depends_on:
      - mysql
    image: tommylau/php:7.1
    volumes:
      - $PWD:/var/www
    restart: always

  nginx:
    depends_on:
      - php
    image: nginx:1.12-alpine
    ports:
      - 80:80
      - 443:443
    volumes:
      - $PWD:/var/www
      - $PWD/default.conf:/etc/nginx/conf.d/default.conf

volumes:
  data

其中 MySQL 的用戶名戏蔑、密碼還有數(shù)據(jù)庫的名字都是:lumen蹋凝,數(shù)據(jù)庫的文件存儲名為:data

配置 Lumen 的數(shù)據(jù)庫

首先先復(fù)制一份預(yù)配置的文件,并命名為 .env总棵,這個(gè)文件務(wù)必要在 Lumen 的根目錄鳍寂。

cp .env.example .env

然后修改 .env 文件的內(nèi)容如下:

APP_ENV=local
APP_DEBUG=true
APP_KEY=
APP_TIMEZONE=UTC

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=lumen
DB_USERNAME=lumen
DB_PASSWORD=lumen

CACHE_DRIVER=array
QUEUE_DRIVER=array

運(yùn)行 Docker compose

我們只需要一條簡單的命令,便可以將幾個(gè)服務(wù)跑起來了情龄。

$ docker-compose up -d
Creating network "lumen550_default" with the default driver
Creating volume "lumen550_data" with default driver
Pulling mysql (mysql:5.7)...
5.7: Pulling from library/mysql
ad74af05f5a2: Pull complete
0639788facc8: Pull complete
de70fa77eb2b: Pull complete
724179e94999: Pull complete
50c77fb16ba6: Pull complete
d51f459239fb: Pull complete
937bbdd4305a: Pull complete
35369f9634e1: Pull complete
f6016aab25f1: Pull complete
5f1901e920da: Pull complete
fdf808213c5b: Pull complete
Digest: sha256:96edf37370df96d2a4ee1715cc5c7820a0ec6286551a927981ed50f0273d9b43
Status: Downloaded newer image for mysql:5.7
Pulling php (tommylau/php:7.1)...
7.1: Pulling from tommylau/php
90f4dba627d6: Pull complete
19ae35d04742: Pull complete
6d34c9ec1436: Pull complete
729ea35b870d: Pull complete
d9a9bce03ae5: Pull complete
14722aee56a9: Pull complete
cddf82133cfb: Pull complete
f947a5248e64: Pull complete
df8066eb849b: Pull complete
f1c3a7903b82: Pull complete
f79a49b80174: Pull complete
9b1090fd4e6a: Pull complete
Digest: sha256:08c2f4a744cc1691a91b38e3dc8b59c494c68e3b2e80a8533d170949d5eb5fce
Status: Downloaded newer image for tommylau/php:7.1
Pulling nginx (nginx:1.12-alpine)...
1.12-alpine: Pulling from library/nginx
019300c8a437: Pull complete
6699c6d12419: Pull complete
49502b430ca1: Pull complete
9bb3a196cbc6: Pull complete
Digest: sha256:d4656aba193a5e0df453a7e6eea3e339c2137097beb1ed06b8d76528edfc0a8a
Status: Downloaded newer image for nginx:1.12-alpine
Creating lumen550_mysql_1 ...
Creating lumen550_mysql_1 ... done
Creating lumen550_php_1 ...
Creating lumen550_php_1 ... done
Creating lumen550_nginx_1 ...
Creating lumen550_nginx_1 ... done
Attaching to lumen550_mysql_1, lumen550_php_1, lumen550_nginx_1
mysql_1  | Initializing database
mysql_1  | 2017-09-08T03:31:18.235209Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql_1  | 2017-09-08T03:31:18.495735Z 0 [Warning] InnoDB: New log files created, LSN=45790
mysql_1  | 2017-09-08T03:31:18.533504Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
mysql_1  | 2017-09-08T03:31:18.593576Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 2d40d947-9446-11e7-9d10-0242ac120002.
mysql_1  | 2017-09-08T03:31:18.594961Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
mysql_1  | 2017-09-08T03:31:18.595220Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
mysql_1  | 2017-09-08T03:31:18.974914Z 1 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:18.975846Z 1 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:18.975888Z 1 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:18.977453Z 1 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:18.977474Z 1 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:18.977500Z 1 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:18.977543Z 1 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:18.977559Z 1 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  | Database initialized
mysql_1  | Initializing certificates
mysql_1  | Generating a 2048 bit RSA private key
mysql_1  | ..................+++
mysql_1  | ..............................................................................+++
mysql_1  | unable to write 'random state'
mysql_1  | writing new private key to 'ca-key.pem'
mysql_1  | -----
mysql_1  | Generating a 2048 bit RSA private key
mysql_1  | ............................+++
mysql_1  | ...........................+++
mysql_1  | unable to write 'random state'
mysql_1  | writing new private key to 'server-key.pem'
mysql_1  | -----
mysql_1  | Generating a 2048 bit RSA private key
mysql_1  | ...........+++
mysql_1  | .......................................................................................+++
mysql_1  | unable to write 'random state'
mysql_1  | writing new private key to 'client-key.pem'
mysql_1  | -----
mysql_1  | Certificates initialized
mysql_1  | MySQL init process in progress...
mysql_1  | 2017-09-08T03:31:21.203861Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql_1  | 2017-09-08T03:31:21.204753Z 0 [Note] mysqld (mysqld 5.7.19) starting as process 87 ...
mysql_1  | 2017-09-08T03:31:21.207345Z 0 [Note] InnoDB: PUNCH HOLE support available
mysql_1  | 2017-09-08T03:31:21.207429Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mysql_1  | 2017-09-08T03:31:21.207443Z 0 [Note] InnoDB: Uses event mutexes
mysql_1  | 2017-09-08T03:31:21.207456Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
mysql_1  | 2017-09-08T03:31:21.207465Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
mysql_1  | 2017-09-08T03:31:21.207474Z 0 [Note] InnoDB: Using Linux native AIO
mysql_1  | 2017-09-08T03:31:21.207635Z 0 [Note] InnoDB: Number of pools: 1
mysql_1  | 2017-09-08T03:31:21.207707Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysql_1  | 2017-09-08T03:31:21.208790Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
mysql_1  | 2017-09-08T03:31:21.214422Z 0 [Note] InnoDB: Completed initialization of buffer pool
mysql_1  | 2017-09-08T03:31:21.217735Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
mysql_1  | 2017-09-08T03:31:21.229522Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
mysql_1  | 2017-09-08T03:31:21.236377Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
mysql_1  | 2017-09-08T03:31:21.236517Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
mysql_1  | 2017-09-08T03:31:21.253899Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
mysql_1  | 2017-09-08T03:31:21.255052Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
mysql_1  | 2017-09-08T03:31:21.255095Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
mysql_1  | 2017-09-08T03:31:21.255560Z 0 [Note] InnoDB: Waiting for purge to start
mysql_1  | 2017-09-08T03:31:21.305698Z 0 [Note] InnoDB: 5.7.19 started; log sequence number 2539315
mysql_1  | 2017-09-08T03:31:21.306978Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysql_1  | 2017-09-08T03:31:21.310284Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
mysql_1  | 2017-09-08T03:31:21.310489Z 0 [Warning] CA certificate ca.pem is self signed.
mysql_1  | 2017-09-08T03:31:21.310681Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mysql_1  | 2017-09-08T03:31:21.312210Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170908  3:31:21
mysql_1  | 2017-09-08T03:31:21.318300Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:21.318379Z 0 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:21.318405Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:21.318431Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:21.318445Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:21.318461Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:21.319426Z 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:21.319455Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:21.323252Z 0 [Note] Event Scheduler: Loaded 0 events
mysql_1  | 2017-09-08T03:31:21.323374Z 0 [Note] mysqld: ready for connections.
mysql_1  | Version: '5.7.19'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server (GPL)
mysql_1  | 2017-09-08T03:31:21.323390Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check.
mysql_1  | 2017-09-08T03:31:21.323398Z 0 [Note] Beginning of list of non-natively partitioned tables
mysql_1  | 2017-09-08T03:31:21.335016Z 0 [Note] End of list of non-natively partitioned tables
mysql_1  | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
mysql_1  | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
mysql_1  | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
mysql_1  | 2017-09-08T03:31:23.416481Z 5 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:23.416577Z 5 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:23.416605Z 5 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:23.416617Z 5 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:23.416633Z 5 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:23.416665Z 5 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:23.416681Z 5 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  | mysql: [Warning] Using a password on the command line interface can be insecure.
mysql_1  | mysql: [Warning] Using a password on the command line interface can be insecure.
mysql_1  | mysql: [Warning] Using a password on the command line interface can be insecure.
mysql_1  | mysql: [Warning] Using a password on the command line interface can be insecure.
mysql_1  | 2017-09-08T03:31:23.431887Z 9 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:23.431938Z 9 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:23.431972Z 9 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:23.431987Z 9 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:23.432004Z 9 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:23.432123Z 9 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:23.432144Z 9 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  |
mysql_1  | 2017-09-08T03:31:23.434536Z 0 [Note] Giving 0 client threads a chance to die gracefully
mysql_1  | 2017-09-08T03:31:23.434596Z 0 [Note] Shutting down slave threads
mysql_1  | 2017-09-08T03:31:23.434614Z 0 [Note] Forcefully disconnecting 0 remaining clients
mysql_1  | 2017-09-08T03:31:23.434630Z 0 [Note] Event Scheduler: Purging the queue. 0 events
mysql_1  | 2017-09-08T03:31:23.434700Z 0 [Note] Binlog end
mysql_1  | 2017-09-08T03:31:23.435339Z 0 [Note] Shutting down plugin 'ngram'
mysql_1  | 2017-09-08T03:31:23.435363Z 0 [Note] Shutting down plugin 'ARCHIVE'
mysql_1  | 2017-09-08T03:31:23.435377Z 0 [Note] Shutting down plugin 'partition'
mysql_1  | 2017-09-08T03:31:23.435386Z 0 [Note] Shutting down plugin 'BLACKHOLE'
mysql_1  | 2017-09-08T03:31:23.435396Z 0 [Note] Shutting down plugin 'MyISAM'
mysql_1  | 2017-09-08T03:31:23.435409Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
mysql_1  | 2017-09-08T03:31:23.435418Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
mysql_1  | 2017-09-08T03:31:23.435426Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
mysql_1  | 2017-09-08T03:31:23.435434Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
mysql_1  | 2017-09-08T03:31:23.435443Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
mysql_1  | 2017-09-08T03:31:23.435451Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
mysql_1  | 2017-09-08T03:31:23.435459Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
mysql_1  | 2017-09-08T03:31:23.435468Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
mysql_1  | 2017-09-08T03:31:23.435482Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
mysql_1  | 2017-09-08T03:31:23.435492Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
mysql_1  | 2017-09-08T03:31:23.435500Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
mysql_1  | 2017-09-08T03:31:23.435508Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
mysql_1  | 2017-09-08T03:31:23.435515Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
mysql_1  | 2017-09-08T03:31:23.435523Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
mysql_1  | 2017-09-08T03:31:23.435531Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
mysql_1  | 2017-09-08T03:31:23.435539Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
mysql_1  | 2017-09-08T03:31:23.435547Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
mysql_1  | 2017-09-08T03:31:23.435570Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
mysql_1  | 2017-09-08T03:31:23.435579Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
mysql_1  | 2017-09-08T03:31:23.435586Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
mysql_1  | 2017-09-08T03:31:23.435594Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
mysql_1  | 2017-09-08T03:31:23.435602Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
mysql_1  | 2017-09-08T03:31:23.435610Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
mysql_1  | 2017-09-08T03:31:23.435617Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
mysql_1  | 2017-09-08T03:31:23.435625Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
mysql_1  | 2017-09-08T03:31:23.435633Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
mysql_1  | 2017-09-08T03:31:23.435641Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
mysql_1  | 2017-09-08T03:31:23.435648Z 0 [Note] Shutting down plugin 'INNODB_CMP'
mysql_1  | 2017-09-08T03:31:23.435656Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
mysql_1  | 2017-09-08T03:31:23.435664Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
mysql_1  | 2017-09-08T03:31:23.435672Z 0 [Note] Shutting down plugin 'INNODB_TRX'
mysql_1  | 2017-09-08T03:31:23.435679Z 0 [Note] Shutting down plugin 'InnoDB'
mysql_1  | 2017-09-08T03:31:23.435746Z 0 [Note] InnoDB: FTS optimize thread exiting.
mysql_1  | 2017-09-08T03:31:23.435927Z 0 [Note] InnoDB: Starting shutdown...
mysql_1  | 2017-09-08T03:31:23.537135Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
mysql_1  | 2017-09-08T03:31:23.537513Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 170908  3:31:23
mysql_1  | 2017-09-08T03:31:25.151481Z 0 [Note] InnoDB: Shutdown completed; log sequence number 12143451
mysql_1  | 2017-09-08T03:31:25.153272Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
mysql_1  | 2017-09-08T03:31:25.153318Z 0 [Note] Shutting down plugin 'CSV'
mysql_1  | 2017-09-08T03:31:25.153341Z 0 [Note] Shutting down plugin 'MEMORY'
mysql_1  | 2017-09-08T03:31:25.153354Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
mysql_1  | 2017-09-08T03:31:25.153387Z 0 [Note] Shutting down plugin 'sha256_password'
mysql_1  | 2017-09-08T03:31:25.153402Z 0 [Note] Shutting down plugin 'mysql_native_password'
mysql_1  | 2017-09-08T03:31:25.153632Z 0 [Note] Shutting down plugin 'binlog'
mysql_1  | 2017-09-08T03:31:25.154298Z 0 [Note] mysqld: Shutdown complete
mysql_1  |
mysql_1  |
mysql_1  | MySQL init process done. Ready for start up.
mysql_1  |
mysql_1  | 2017-09-08T03:31:25.360932Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql_1  | 2017-09-08T03:31:25.361606Z 0 [Note] mysqld (mysqld 5.7.19) starting as process 1 ...
mysql_1  | 2017-09-08T03:31:25.364436Z 0 [Note] InnoDB: PUNCH HOLE support available
mysql_1  | 2017-09-08T03:31:25.364484Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mysql_1  | 2017-09-08T03:31:25.364497Z 0 [Note] InnoDB: Uses event mutexes
mysql_1  | 2017-09-08T03:31:25.364511Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
mysql_1  | 2017-09-08T03:31:25.364522Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
mysql_1  | 2017-09-08T03:31:25.364532Z 0 [Note] InnoDB: Using Linux native AIO
mysql_1  | 2017-09-08T03:31:25.364785Z 0 [Note] InnoDB: Number of pools: 1
mysql_1  | 2017-09-08T03:31:25.364914Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysql_1  | 2017-09-08T03:31:25.365918Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
mysql_1  | 2017-09-08T03:31:25.371658Z 0 [Note] InnoDB: Completed initialization of buffer pool
mysql_1  | 2017-09-08T03:31:25.373208Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
mysql_1  | 2017-09-08T03:31:25.384808Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
mysql_1  | 2017-09-08T03:31:25.391336Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
mysql_1  | 2017-09-08T03:31:25.391463Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
mysql_1  | 2017-09-08T03:31:25.404213Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
mysql_1  | 2017-09-08T03:31:25.404731Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
mysql_1  | 2017-09-08T03:31:25.404753Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
mysql_1  | 2017-09-08T03:31:25.405016Z 0 [Note] InnoDB: Waiting for purge to start
mysql_1  | 2017-09-08T03:31:25.455194Z 0 [Note] InnoDB: 5.7.19 started; log sequence number 12143451
mysql_1  | 2017-09-08T03:31:25.455947Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysql_1  | 2017-09-08T03:31:25.458896Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
mysql_1  | 2017-09-08T03:31:25.459094Z 0 [Warning] CA certificate ca.pem is self signed.
mysql_1  | 2017-09-08T03:31:25.460412Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
mysql_1  | 2017-09-08T03:31:25.460486Z 0 [Note] IPv6 is available.
mysql_1  | 2017-09-08T03:31:25.460505Z 0 [Note]   - '::' resolves to '::';
mysql_1  | 2017-09-08T03:31:25.460526Z 0 [Note] Server socket created on IP: '::'.
mysql_1  | 2017-09-08T03:31:25.460875Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mysql_1  | 2017-09-08T03:31:25.462385Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:25.462432Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:25.462460Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:25.462471Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql_1  | 2017-09-08T03:31:25.462487Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.

我們可以運(yùn)行一下 docker ps 來看一下現(xiàn)在 Docker 的運(yùn)行情況迄汛。

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                      NAMES
dfbe025c3dce        nginx:1.12-alpine   "nginx -g 'daemon ..."   2 minutes ago       Up 13 seconds       0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   lumen550_nginx_1
b9088942eff5        tommylau/php:7.1    "docker-php-entryp..."   2 minutes ago       Up 13 seconds       9000/tcp                                   lumen550_php_1
8f67ea7e4a75        mysql:5.7           "docker-entrypoint..."   2 minutes ago       Up 13 seconds       3306/tcp                                   lumen550_mysql_1

可以看到幾個(gè)服務(wù)都已經(jīng)在正常運(yùn)行了。

Lumen Composer 安裝

幾個(gè)服務(wù)跑起來了以后骤视,并不代表著 Lumen 就可以正常使用了鞍爱,因?yàn)檫€有很多的第三方依賴關(guān)系,是需要通過 Composer 來完成的专酗。

這個(gè)時(shí)候我們需要進(jìn)入到 PHP Container 的內(nèi)部睹逃,來執(zhí)行 PHP Composer 相關(guān)的命令來加載第三方的庫。

docker exec -ti lumen550_php_1 sh

通過上面的命令祷肯,我們就可以進(jìn)入到 PHP 的容器里面沉填。

$ composer install --optimize-autoloader --no-dev
Loading composer repositories with package information
Updating dependencies
Package operations: 41 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-mbstring (v1.5.0): Downloading (100%)
  - Installing symfony/http-foundation (v3.3.8): Downloading (100%)
  - Installing symfony/event-dispatcher (v3.3.8): Downloading (100%)
  - Installing psr/log (1.0.2): Downloading (100%)
  - Installing symfony/debug (v3.3.8): Downloading (100%)
  - Installing symfony/http-kernel (v3.3.8): Downloading (100%)
  - Installing nikic/fast-route (v1.2.0): Downloading (100%)
  - Installing mtdowling/cron-expression (v1.2.0): Downloading (100%)
  - Installing monolog/monolog (1.23.0): Downloading (100%)
  - Installing symfony/translation (v3.3.8): Downloading (100%)
  - Installing nesbot/carbon (1.22.1): Downloading (100%)
  - Installing psr/simple-cache (1.0.0): Downloading (100%)
  - Installing psr/container (1.0.0): Downloading (100%)
  - Installing illuminate/contracts (v5.5.2): Downloading (100%)
  - Installing doctrine/inflector (v1.2.0): Downloading (100%)
  - Installing illuminate/support (v5.5.2): Downloading (100%)
  - Installing symfony/finder (v3.3.8): Downloading (100%)
  - Installing illuminate/filesystem (v5.5.2): Downloading (100%)
  - Installing illuminate/container (v5.5.2): Downloading (100%)
  - Installing illuminate/events (v5.5.2): Downloading (100%)
  - Installing illuminate/view (v5.5.2): Downloading (100%)
  - Installing illuminate/translation (v5.5.2): Downloading (100%)
  - Installing illuminate/validation (v5.5.2): Downloading (100%)
  - Installing symfony/process (v3.3.8): Downloading (100%)
  - Installing illuminate/database (v5.5.2): Downloading (100%)
  - Installing symfony/console (v3.3.8): Downloading (100%)
  - Installing illuminate/console (v5.5.2): Downloading (100%)
  - Installing illuminate/queue (v5.5.2): Downloading (100%)
  - Installing illuminate/pipeline (v5.5.2): Downloading (100%)
  - Installing illuminate/pagination (v5.5.2): Downloading (100%)
  - Installing illuminate/session (v5.5.2): Downloading (100%)
  - Installing illuminate/http (v5.5.2): Downloading (100%)
  - Installing illuminate/hashing (v5.5.2): Downloading (100%)
  - Installing illuminate/encryption (v5.5.2): Downloading (100%)
  - Installing illuminate/config (v5.5.2): Downloading (100%)
  - Installing illuminate/cache (v5.5.2): Downloading (100%)
  - Installing illuminate/bus (v5.5.2): Downloading (100%)
  - Installing illuminate/broadcasting (v5.5.2): Downloading (100%)
  - Installing illuminate/auth (v5.5.2): Downloading (100%)
  - Installing laravel/lumen-framework (v5.5.0): Downloading (100%)
  - Installing vlucas/phpdotenv (v2.4.0): Downloading (100%)
Writing lock file
Generating optimized autoload files
$ composer dump-autoload --optimize
Generating optimized autoload files

這樣,所有需要的文件就算齊備了佑笋。

一般 macOS 下 VirtualBox 默認(rèn)的虛擬機(jī)地址為:192.168.99.100

所以我們訪問下:http://192.168.99.100/

應(yīng)該就會(huì)看到正在運(yùn)行的 Lumen 輸出了翼闹。

參考

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市蒋纬,隨后出現(xiàn)的幾起案子橄碾,更是在濱河造成了極大的恐慌,老刑警劉巖颠锉,帶你破解...
    沈念sama閱讀 207,248評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件法牲,死亡現(xiàn)場離奇詭異,居然都是意外死亡琼掠,警方通過查閱死者的電腦和手機(jī)拒垃,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,681評論 2 381
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來瓷蛙,“玉大人悼瓮,你說我怎么就攤上這事〖桠” “怎么了横堡?”我有些...
    開封第一講書人閱讀 153,443評論 0 344
  • 文/不壞的土叔 我叫張陵,是天一觀的道長冠桃。 經(jīng)常有香客問我命贴,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 55,475評論 1 279
  • 正文 為了忘掉前任胸蛛,我火速辦了婚禮污茵,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘葬项。我一直安慰自己泞当,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,458評論 5 374
  • 文/花漫 我一把揭開白布民珍。 她就那樣靜靜地躺著襟士,像睡著了一般。 火紅的嫁衣襯著肌膚如雪嚷量。 梳的紋絲不亂的頭發(fā)上陋桂,一...
    開封第一講書人閱讀 49,185評論 1 284
  • 那天,我揣著相機(jī)與錄音津肛,去河邊找鬼章喉。 笑死汗贫,一個(gè)胖子當(dāng)著我的面吹牛身坐,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播落包,決...
    沈念sama閱讀 38,451評論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼部蛇,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了咐蝇?” 一聲冷哼從身側(cè)響起涯鲁,我...
    開封第一講書人閱讀 37,112評論 0 261
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎有序,沒想到半個(gè)月后抹腿,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 43,609評論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡旭寿,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,083評論 2 325
  • 正文 我和宋清朗相戀三年警绩,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片盅称。...
    茶點(diǎn)故事閱讀 38,163評論 1 334
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡肩祥,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出缩膝,到底是詐尸還是另有隱情混狠,我是刑警寧澤,帶...
    沈念sama閱讀 33,803評論 4 323
  • 正文 年R本政府宣布疾层,位于F島的核電站将饺,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜俯逾,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,357評論 3 307
  • 文/蒙蒙 一贸桶、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧桌肴,春花似錦皇筛、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,357評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至彪置,卻和暖如春拄踪,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背拳魁。 一陣腳步聲響...
    開封第一講書人閱讀 31,590評論 1 261
  • 我被黑心中介騙來泰國打工惶桐, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人潘懊。 一個(gè)月前我還...
    沈念sama閱讀 45,636評論 2 355
  • 正文 我出身青樓姚糊,卻偏偏與公主長得像,于是被迫代替她去往敵國和親授舟。 傳聞我的和親對象是個(gè)殘疾皇子救恨,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,925評論 2 344

推薦閱讀更多精彩內(nèi)容