title: Deploy Laravel on Google App Engine - Flexible
body: <p>After deploying Laravel 6 to Google App Engine, got this error when run the url <code>https://PROJECT_ID.appspot.com/</code>.</p>
  
  <p><code>The stream or file "/app/storage/logs/laravel-2019-12-31.log" could not be opened: failed to open stream: Permission denied</code></p>
  
  <p><a href="https://i.stack.imgur.com/FQ8rM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FQ8rM.png" alt="enter image description here"></a>  </p>
  
  <p>I have followed the instrucation given on <a href="https://cloud.google.com/community/tutorials/run-laravel-on-appengine-flexible" rel="nofollow noreferrer">https://cloud.google.com/community/tutorials/run-laravel-on-appengine-flexible</a><a href="https://cloud.google.com/community/tutorials/run-laravel-on-appengine-flexible" rel="nofollow noreferrer">2</a>  </p>
  
  <p>Here is my <strong>app.yaml</strong> file  </p>
  
  <pre><code>runtime: php  # language of the app
  env: flex     # let app engine know we use flexible environment
  runtime_config:
   document_root: .   #folder where index.php is
  # Ensure we skip ".env", which is only for local development
  skip_files:
   - .env #we want to skip this to make sure we don’t mess stuff up on the server
  env_variables:
   # Put production environment variables here.
   APP_ENV: production   # or production
   APP_DEBUG : true # or false 
   APP_KEY: YOUR_API_KEY
  #go to generate app key paragraf in this tutorial
   CACHE_DRIVER: database
  # instead of putting the cache in the database I recommend using redis
   SESSION_DRIVER: database #or file since both work
   APP_LOG: errorlog
   APP_TIMEZONE: UTC #your timezone of choice
  # follow the part of the tutorial on setting up your SQL database
   DB_CONNECTION: mysql
   DB_HOST: localhost
   DB_DATABASE: XXX
   DB_USERNAME: XXX
   DB_PASSWORD: XXX
   DB_SOCKET: /cloudsql/YOUR_CLOUDSQL_CONNECTION_NAME
   QUEUE_DRIVER: database #in case you execute queued jobs
   MAIL_DRIVER: mail
   MAIL_HOST: smtp.sparkpostmail.com
   MAIL_PORT: 587
   MAIL_USERNAME: null
   MAIL_PASSWORD: null
   LOG_DELETE:  true # this is a parameter added by us in the project .env file. You can add here any setting you would add to your .env file
   GOOGLE_VISION_PROJECT_ID : PROJECT_ID
  #we need this for the flex environment
  beta_settings:
     # for Cloud SQL, set this value to the Cloud SQL connection name,
     # e.g. "project:region:cloudsql-instance"
     cloud_sql_instances: "YOUR_CLOUDSQL_CONNECTION_NAME"  
  </code></pre>
  
  <p><strong>composer.json</strong>  </p>
  
  <pre><code>"scripts": {
          "post-autoload-dump": [
              "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
              "@php artisan package:discover --ansi"
          ],
          "post-root-package-install": [
              "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
          ],
          "post-create-project-cmd": [
              "@php artisan key:generate --ansi"
          ],
          "post-install-cmd": [
             "Illuminate\\Foundation\\ComposerScripts::postInstall",
             "@php artisan optimize",
             "chmod -R 755 storage bootstrap\/cache"
         ],
         "post-update-cmd": [
             "Illuminate\\Foundation\\ComposerScripts::postUpdate",
             "@php artisan optimize"
         ]
      }
  </code></pre>
  
  <p>I have Tested on local machine and its working successfully.  </p>