Google App Engine写入权限被拒绝

时间:2018-06-14 10:27:07

标签: php google-app-engine laravel-5 file-permissions octobercms

我已使用以下控制台命令将OctoberCMS(基于Laravel 5的CMS)上传到灵活的Google App Engine:

╭─yusuf@berkarya ~/htdocs/Project_October 
╰─➤  gcloud app deploy 

然后将其部署到Cloud Service,并显示以下消息:

Updating service [default] (this may take several minutes)...done.                                                                                                      
Setting traffic split for service [default]...done.                                                                                                                     
Stopping version [obundaoctober/default/20180614t144216].
Sent request to stop version [obundaoctober/default/20180614t144216]. This operation may take some time to complete. If you would like to verify that it succeeded, run:
  $ gcloud app versions describe -s default 20180614t144216
until it shows that the version has stopped.
Deployed service [default] to [https://obundaoctober.appspot.com]

You can stream logs from the command line by running:
  $ gcloud app logs tail -s default

To view your application in the web browser run:
  $ gcloud app browse

问题是当我尝试打开以下网址https://obundaoctober.appspot.com时,我收到一条错误消息,告知我没有足够的权限访问权限:

We're sorry, but an unhandled error occurred. Please see the details below.

The stream or file "/app/storage/logs/system.log" could not be opened: failed to open stream: Permission denied
/app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php line 107

enter image description here

在灵活的Google App Engine中更改文件夹/文件权限以解决此类错误的任何正确方法?

非常感谢任何帮助。

由于

2 个答案:

答案 0 :(得分:0)

GAE tutorial for Laravel中是一个更改composer.json中post-install-cmd权限的示例

"scripts": {
    "post-install-cmd": [
        "chmod -R 755 bootstrap\/cache",
        "php artisan cache:clear"
    ]
}

我认为这也适用于存储文件夹。

答案 1 :(得分:0)

您可以在 app.yaml 中设置“runtime: custom”并使用 Dockerfile 配置 Docker 容器。在 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

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