容器化部署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 foundfastcgi_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;}
}
查看更多 [每周一更]-(第67期):docker-compose 部署php的laravel项目