docker run -it -p 18080:80 -p 21:21 -p 3306-3306 php:7.2.4-fpm-alpine3.6 /bin/sh
cd /etc/apk vi repositories
http://mirrors.aliyun.com/alpine/v3.6/main http://mirrors.aliyun.com/alpine/v3.6/community
apt add --no-cache nginx
cd /run mkdir nginx
cd /var/www/html vi index.html
hello world
server { listen 80 default_server; location / { index index.html; root /var/www/html; } location = /404.html { internal; } }
nginx -s reload
/usr/sbin/nginx -c /etc/nginx/nginx.conf
打開瀏覽器,輸入127.0.0.1,看到網頁顯示hello world,nginx安裝成功。php
server { listen 80; index index.html index.php; location / { index index.html; root /var/www/html; #實現PHP僞靜態 try_files $uri /index.php?$args; } # You may need this to prevent return 404 recursion. location = /404.html { internal; } #添加php支持 location ~ .php { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name; include fastcgi_params; } }
請確認 /etc/nginx/nginx.conf中包含include config.d/*.conf語句,不然default.conf將不會生效,另外,nginx.conf中若是已經有一個server服務器,也可能形成端口衝突,這些問題的處理方式,和其它linux發行版是同樣的。
vi info.php
<?php phpinfo();
vi index.php
<?php echo 'Hello php';
php-fpm --daemonize nginx -s reload
Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip
因爲咱們選擇的鏡像不是最基本的alpine而是php:7.2.4-fpm-alpine3.6 ,這些鏡象其實都已經預裝了,因此下面的命令只是一個示範,它會提示擴展已安裝過:html
docker-php-ext-install fileinfo
若是要裝這些之外的擴展就會比較複雜,這篇文章裏就不提了。mysql
如今咱們已經熟悉了alpine,接下來我會練習用dockerfile完成今天的工做,製做第一個本身的docker鏡像。linux
本文來自 第九區,轉載請保留本段文字。nginx