laravel11 笔记
大约 2 分钟
配置文件
APP_TIMEZONE=Asia/Shanghai
OCTANE_SERVER=swoole
OCTANE_HTTPS=false
APP_LOCALE=zh-CN
APP_FALLBACK_LOCALE=zh-CN
APP_FAKER_LOCALE=zh_CN
octane 使用
composer require laravel/octane
php artisan octane:install # swoole
php artisan octane:start --server=swoole --host=0.0.0.0 --port=8089
docker打包
dockerfile
FROM hyperf/hyperf:8.2-alpine-vedge-swoole-slim-v5
ENV TZ Asia/Shanghai
RUN apk add tzdata && cp /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo ${TZ} > /etc/timezone
WORKDIR /app
COPY . /app
RUN composer install --optimize-autoloader --prefer-dist
CMD ["php", "artisan", "octane:start", "--server=swoole", "--host=0.0.0.0", "--port=8089"]
docker-compose.yml
services:
app:
# image: registry.cn-hangzhou.aliyuncs.com/orangbus/math-api
build:
context: .
privileged: true
restart: unless-stopped
ports:
- "8089:8089"
volumes:
- ./.env:/app/.env
- ./logs:/app/storage/logs
network_mode: bridge
command: php artisan octane:start --server=swoole --port=8089
queue:
image: registry.cn-hangzhou.aliyuncs.com/orangbus/math-api
restart: unless-stopped
volumes:
- .env:/app/.env
command: php artisan queue:work --tries=3
schedule:
image: registry.cn-hangzhou.aliyuncs.com/orangbus/math-api
restart: unless-stopped
volumes:
- .env:/app/.env
command: php artisan schedule:work
云效配置

env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:CyER66l1OOfO3UVuVIhbiMbFzoT5wNuFK82ntyBFjqU=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=http://localhost
OCTANE_SERVER=swoole
OCTANE_HTTPS=false
APP_LOCALE=zh
APP_FALLBACK_LOCALE=zh
APP_FAKER_LOCALE=zh_CN
APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database
PHP_CLI_SERVER_WORKERS=4
BCRYPT_ROUNDS=12
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=math
DB_USERNAME=math
DB_PASSWORD=
SESSION_DRIVER=redis
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
BROADCAST_CONNECTION=redis
FILESYSTEM_DISK=local
QUEUE_CONNECTION=redis
CACHE_STORE=redis
CACHE_PREFIX=
MEMCACHED_HOST=127.0.0.1
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=
REDIS_PORT=6379
MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=admin
AWS_SECRET_ACCESS_KEY=admin666
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=web
AWS_USE_PATH_STYLE_ENDPOINT=false
AWS_ENDPOINT=http://192.168.110.134:9000
AWS_URL=//home.cc:9000
VITE_APP_NAME="${APP_NAME}"
nginx-api
server {
listen 80;
listen [::]:80;
server_name domain.com;
server_tokens off;
location /index.php {
try_files /not_exists @octane;
}
location / {
try_files $uri $uri/ @octane;
}
location @octane {
set $suffix "";
if ($uri = /index.php) {
set $suffix ?$query_string;
}
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header Scheme $scheme;
proxy_set_header SERVER_PORT $server_port;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://127.0.0.1:8000$suffix; # 修改为自己的地址
}
}
nginx-dockerfile
FROM nginx:alpine
WORKDIR /usr/share/nginx/html
COPY ./dist/ ./
# 配置 Nginx,如果需要配置反向代理,可以在这里添加配置
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
# 暴露 80 端口
EXPOSE 80
# 启动 Nginx 服务
CMD ["nginx", "-g", "daemon off;"]
nginx-admin
server {
listen 80;
server_name orangbus.cn;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location /admin {
proxy_pass http://ip:4041; # 修改为服务器端域名 或者 ip+端口
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
charset utf-8;
}