【问题标题】:Unable to deploy October/Laravel to Google cloud platform无法将 October/Laravel 部署到谷歌云平台
【发布时间】:2018-03-08 06:23:51
【问题描述】:

我已经连续好几个小时敲了敲脑袋,试图找出我的代码哪里出了问题。尝试将 October/Laravel 的全新安装部署到 Google 云上的 App 引擎实例。

错误消息是典型的致命 500

This page isn’t working 
xx.appspot.com is currently unable to handle this request. 
HTTP ERROR 500

查看 Google 云平台 ir 中的日志,似乎带有 500 响应的初始 GET 请求发生在任何有关日志记录的致命错误之前。

代码库在我通过 SQL 代理连接到 Google SQL 引擎的本地环境中运行良好。它似乎是以下两件事之一:

  1. 日志记录的权限问题(不太可能是因为在此之前有 500 错误。
  2. 配置有问题?遍历 app.yaml 文件一百次,SQL 配置似乎没问题,因为它在本地使用相同的数据库。
  3. 其他与 10 月的配置方式有关的内容?什么?

app.yaml 文件:

runtime: php
env: flex

runtime_config:
  document_root: .

# Ensure we skip ".env", which is only for local development
  skip_files:
    - .env

env_variables:
# Put production environment variables here.
APP_LOG: errorlog
APP_KEY: xxxx
STORAGE_DIR: /tmp
CACHE_DRIVER: database
SESSION_DRIVER: database

## Set these environment variables according to your CloudSQL configuration.
MYSQL_DSN: mysql:unix_socket=/cloudsql/xxx;dbname=yyy
MYSQL_USER: xx
MYSQL_PASSWORD: xx

beta_settings:
  # for Cloud SQL, set this value to the Cloud SQL connection name,
  # e.g. "project:region:cloudsql-instance"
  cloud_sql_instances: "xx"

对此的任何帮助将不胜感激

【问题讨论】:

标签: php laravel google-app-engine octobercms


【解决方案1】:

关于问题1:权限问题可以通过在app.yaml中设置“runtime:custom”并创建Dockerfile来解决。

FROM gcr.io/google-appengine/php73
 
ARG COMPOSER_FLAGS='--prefer-dist'
ENV COMPOSER_FLAGS=${COMPOSER_FLAGS}
ENV SWOOLE_VERSION=4.3.4
ENV DOCUMENT_ROOT=/app
 
COPY . $APP_DIR
 
RUN apt-get update -y \
&& apt-get install -y \
unzip \
autoconf \
build-essential \
libmpdec-dev \
libpq-dev \
&& pecl install decimal \
&& curl -o /tmp/swoole.tar.gz https://github.com/swoole/swoole-src/archive/v$SWOOLE_VERSION.tar.gz -L \
&& tar zxvf /tmp/swoole.tar.gz \
&& cd swoole-src* \
&& phpize \
&& ./configure \
--enable-async-redis \
&& make \
&& make install \
&& chown -R www-data.www-data $APP_DIR \
&& /build-scripts/composer.sh \
&& mv $APP_DIR/storage $APP_DIR/storagestatic \
&& ln -s /tmp $APP_DIR/storage \
&& cp -TRv $APP_DIR/storagestatic/ $APP_DIR/storage/ \
&& chown -R www-data.www-data $APP_DIR/storage \
&& chmod -R 777 $APP_DIR/storage ;
 
ENTRYPOINT ["/build-scripts/entrypoint.sh"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
 
EXPOSE 8080

关于问题 2 和 3:需要配置多个 env_variables 并相应修改 Laravel 配置。以下是 app.yaml 的示例:

env_variables:
APP_STORAGE_PATH: gs://inset-bucket-name/storage/app
APP_STORAGE_URL: https://storage.googleapis.com/inset-bucket-name/storage/app
APP_DEBUG: false
APP_ENV: production
SESSION_DRIVER: cookie
DATABASE_HOST: insert-database-ip
DATABASE: insert-database-name
DATABASE_USERNAME: insert-database-user
DATABASE_PASSWORD: insert-database-password
DATABASE_PORT: 3306
URL: insert-app-engine-url
KEY: insert-laravel-key
CIPHER: AES-256-CBC

完整教程:https://webmotion.medium.com/how-to-install-octobercms-laravel-application-on-google-app-engine-c77a9185f420

【讨论】:

    猜你喜欢
    • 2020-03-09
    • 2014-11-21
    • 1970-01-01
    • 1970-01-01
    • 2017-07-21
    • 1970-01-01
    • 2015-12-22
    • 2017-05-07
    • 2018-07-19
    相关资源
    最近更新 更多