容器化部署laravel框架的php项目
操作步骤
参考:
- https://www.cnblogs.com/jingjingxyk/p/16842937.html
- https://developer.aliyun.com/article/708976
0、plv项目修改
- composer install
- .env 修改后台地址 IP:端口
- chmod -R 777 public / chmod -R 777 storage
- vim resources/views/welcome.blade.php 修改后台地址 IP:端口
- php镜像更换自建镜像:firehmx/php-7.3.33-fpm-alpine3.14:v1
- docker-compose 监听8084端口
1、创建nginx配置
- nginx-config/default.conf
server { listen 80; server_name localhost; root /var/www/html/public; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php$is_args$query_string; if (!-e $request_filename){ rewrite ^/(.*)$ /index.php?s=$1 last; } } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { # root /var/www/html/public; # 忽略这个容器php文件 File not found fastcgi_pass php:9000; fastcgi_index index.php; include fastcgi_params; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; }}
2、创建docker-compose
docker-composer.yml
version: '3'networks: nginx-php-network:services: web: image: nginx:latest ports: - "8081:80" volumes: - ./nginx-config:/etc/nginx/conf.d - ./:/var/www/html depends_on: - php networks: - nginx-php-network restart: always # 指定容器退出后的重启策略为始终重启php: image: webdevops/php-nginx:7.3-alpine # 可替换php-7.3.33-fpm-alpine3.14:v1 ports: - "9000:9000" restart: always networks: - nginx-php-network volumes: - ./:/var/www/html
查看更多 [每周一更]-(第67期):docker-compose 部署php的laravel项目
来源地址:https://blog.csdn.net/hmx224_2014/article/details/133819070