简体   繁体   中英

Google App Engine writing Permission denied

I have uploaded my OctoberCMS (Laravel 5 based CMS) to Flexible Google App Engine using following console command:

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

And then it deployed to the Cloud Service with following messages:

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

The problem is when I tried open following url https://obundaoctober.appspot.com I got an error message that inform me it has no sufficient permission access:

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

在此处输入图片说明

Any proper way to change folder/file permission in flexible Google App Engine to solve this kind of error ?

Any help will be extremely appreciated.

Thanks

In the GAE tutorial for Laravel is an example to change permissions in the post-install-cmd in composer.json

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

I think this will also work with the storage folder.

You can set "runtime: custom" in app.yaml and configure the Docker container with a Dockerfile. In the Dockerfile you can set the write permissions.

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

Full tutorial: https://webmotion.medium.com/how-to-install-octobercms-laravel-application-on-google-app-engine-c77a9185f420

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM