1 安装php:7.3-fpm镜像
1.1 下载镜像
docker pull php:7.3-fpm
1.2 运行镜像
docker run -p 9000:9000 -d --name myphp-fpm -v /myweb/html:/var/www/html php:7.3-fpm
1.3 查看ip
docker inspect myphp-fpm|grep "IPAddress"
2 安装nginx镜像
2.1 下载镜像
docker pull nginx
2.2 运行镜像
docker run -p 8080:80 -v /myweb/html:/usr/share/nginx/html -v /myweb/nginx/conf.d:/etc/nginx/conf.d -v /myweb/log:/var/log/nginx --name my_nginx_test -d nginx
2.3 配置 laravel_php.conf
/myweb/nginxconf.d/laravel_php.conf
server { listen 80; server_name localhost; root /usr/share/nginx/html/yourname/public; #nginx容器的目录 index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } location ~ .php$ { #/var/www/html/yourname/public #php-fpm目录 root /var/www/html/yourname/public; fastcgi_pass 172.17.0.2:9000; #fastcgi_pass 172.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_param SCRIPT_FILENAME /etc/nginx/html/yourname/public$fastcgi_script_name; include fastcgi_params; } location ~ /.ht { deny all; } }
2.4 重新加载
docker exec my_nginx_test nginx -s reload
3 laravel
3.1 安装扩展
yum install php_mbstring yum install php_xml
3.2 用composer安装laravel
在/myweb/html目录中安装
composer create-project laravel/laravel yourname --prefer-dist "7.*"