就在两三天前(开始写这个文章是 9 月 8 号,确实是 2,3 天前,然而写完的时候已经是 9 月 25 号了,😂 ),Lumen 发布了 5.5 版本。傻乎乎的我就在第一时间把现有运行着 Lumen 5.4 的系统都升级到了 5.5 版本。因为很多东西变化了,升级过程中出现了不少的坑,尤其是第三方的库对于新系统的支持还非常的不好。
不过今天主要想要讨论的不是如何将 Lumen 从 5.4 升级到 5.5,而是介绍如何搭建 Lumen 开发环境。
之前 Madison 同学一直苦恼于如何在 macOS 下搭建基于 PHP 的 Lumen 开发环境,我就随手把配置文件给他了,也没有时间好好解释一下为什么。
正好借着这次系统升级的机会,写篇文章简单介绍下,也算是给 Madison 同学一个交代了。
准备工作
安装 Docker
作为一个使用 macOS 的工程师,Homebrew 是必不可少的,没有的话自己安装吧。
首先安装 Docker 相关的程序
1 2
| brew update brew install docker docker-machine docker-compose
|
如果你没有安装过 VirtualBox 的话,你还需要先安装一个
1
| brew cask install virtualbox
|
接着创建一个 Docker 虚拟机,名字用 default
就好,当然你也可以改成你喜欢的名字
1
| docker-machine create default
|
接着就是要下载需要的 Docker 镜像了
1 2 3
| docker pull tommylau/php:7.1 docker pull nginx:1.12-alpine docker pull mysql:5.7
|
分别对应我们需要的 MySQL
、PHP
和 Nginx
,到这里 Docker 的准备工作就算是完成了。
获取 Lumen 程序
Lumen 官方的建议是使用命令行的方式来安装,因为我在写这篇文章的时候,官方的 Lumen 还停留在 5.4 的版本,没有 5.5 的版本,所以我就直接下载了。
https://github.com/laravel/lumen/archive/v5.5.0.tar.gz
1
| tar zxvf lumen-5.5.0.tar.gz
|
解压缩到任意目录,然后进入该目录,Lumen 的准备工作就算是完成了。
Nginx 配置文件
在 Lumen 目录里面创建一个名为 default.conf
的 Nginx 配置文件,内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| 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 文件
创建一个名为 docker-compose.yml
的文件,用于配置 MySQL
、PHP
、Nginx
服务,同时还会创建一个用于数据库的存储空间。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| 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 的用户名、密码还有数据库的名字都是:lumen
,数据库的文件存储名为:data
配置 Lumen 的数据库
首先先复制一份预配置的文件,并命名为 .env
,这个文件务必要在 Lumen 的根目录。
然后修改 .env
文件的内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| 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
|
运行 Docker compose
我们只需要一条简单的命令,便可以将几个服务跑起来了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
| $ 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.
|
我们可以运行一下 docker ps
来看一下现在 Docker 的运行情况。
1 2 3 4 5
| $ 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
|
可以看到几个服务都已经在正常运行了。
Lumen Composer 安装
几个服务跑起来了以后,并不代表着 Lumen 就可以正常使用了,因为还有很多的第三方依赖关系,是需要通过 Composer
来完成的。
这个时候我们需要进入到 PHP Container 的内部,来执行 PHP Composer 相关的命令来加载第三方的库。
1
| docker exec -ti lumen550_php_1 sh
|
通过上面的命令,我们就可以进入到 PHP 的容器里面。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| $ 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 默认的虚拟机地址为:192.168.99.100
所以我们访问下:http://192.168.99.100/
应该就会看到正在运行的 Lumen 输出了。
参考