I have able to successfully deploy a php application using git in elastic beanstalk, but the configuration files doesnot work. I created a .ebextensions folder on my root application folder and created a config file with the following command:
container_commands:
00_make_assets:
command: "sudo mkdir /var/app/current/assets"
I get the following error message on the dashboard
Command failed on instance. Return code: 1 Output: [CMD-AppDeploy/AppDeployStage0/EbExtensionPostBuild] command failed with error code 1: Error occurred during build: Command 00_make_assets failed.
All I want to do is create a folder and give 777 permission to it.
The output in the log file (/var/log/eb-commandprocessor.log) shows:
[2014-10-17T11:01:43.487Z] ERROR [2341] : Command CMD-AppDeploy failed!
[2014-10-17T11:01:43.488Z] INFO [2341] : Command processor returning results:
{"status":"FAILURE","api_version":"1.0","truncated":"false","results":[{"status":"FAILURE","msg":"[CMD-AppDeploy/AppDeployStage0/EbExtensionPostBuild] command failed with error code 1: Error occurred during build: Command 00_make_assets failed","returncode":1,"events":[]}]}
Has anyone been in this situation? How can this issue be solved? Any help will be much appreciated.
Related
Working on setup for a php class, and I keep running into an error when trying to setup the example windows laravel app from the docs (https://laravel.com/docs/9.x/installation#getting-started-on-windows). After entering:
curl -s https://laravel.build/example-app | bash
I get the following error:
Processing fstab with mount -a failed.
<3>WSL (17) ERROR: CreateProcessEntryCommon:358: getpwuid(0) failed 2
<3>WSL (17) ERROR: CreateProcessEntryCommon:362: getpwuid(0) failed 2
<3>WSL (17) ERROR: CreateProcessEntryCommon:570: execvpe /bin/bash failed 2
<3>WSL (17) ERROR: CreateProcessEntryCommon:579: Create process not expected to return
As far as I know, I have docker and wsl2 installed correctly so I am unsure as to what is causing this error. I have Ubuntu installed as well, but unless I misunderstood the docs, I should just be able to punch the curl straight into cmd prompt to build it in the desired directory.
I'm using Symfony 5.0.7
My live deploy ansible after-symlink-shared.yaml file:
---
- name: Set up infrastructure-related parameters
template:
src: '{{ playbook_dir }}/templates/.env_live.dist'
dest: '{{ ansistrano_release_path.stdout }}/.env'
- name: Install Composer dependencies
composer:
command: install
arguments: --classmap-authoritative
no_dev: no
optimize_autoloader: yes
working_dir: '{{ ansistrano_release_path.stdout }}'
- name: Clear the cache
command: 'php {{ release_console_path }} cache:clear --no-warmup --env=prod'
- name: Warm up the cache
command: 'php {{ release_console_path }} cache:warmup --env=prod'
- name: Create DB if not exists
command: 'php {{ release_console_path }} doctrine:database:create --if-not-exists --env=prod'
register: create_db_output
changed_when: create_db_output.stdout is not search('already exists. Skipped')
- name: Run migrations
command: 'php {{ release_console_path }} doctrine:migrations:migrate --no-interaction --env=prod'
register: run_migrations_output
changed_when: run_migrations_output.stdout is not search('No migrations to execute')
- name: Install bundle assets
command: 'php {{ release_console_path }} assets:install --symlink --env=prod {{ ansistrano_release_path.stdout }}/public'
- name: Copy build directory
command: 'cp -a {{ ansistrano_release_path.stdout }}/public/build /var/www/project/public'
tags:
- deploy
The deployment works perfectly, however every time I deploy to the server, my production environment hits a 500 error.
I take a look at my prod.log file to understand what is causing the error and I get the following:
[2020-05-09 21:40:59] request.CRITICAL: Uncaught PHP Exception RuntimeException: "Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler)." at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php line 43 {"exception":"[object] (RuntimeException(code: 0): Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:43)"} []
[2020-05-09 21:40:59] php.CRITICAL: Uncaught Exception: Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). {"exception":"[object] (RuntimeException(code: 0): Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:43)"} []
[2020-05-09 21:40:59] request.CRITICAL: Uncaught PHP Exception RuntimeException: "Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler)." at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php line 43 {"exception":"[object] (RuntimeException(code: 0): Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:43)"} []
[2020-05-09 21:40:59] php.CRITICAL: Uncaught Exception: Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). {"exception":"[object] (RuntimeException(code: 0): Unable to create the storage directory (/var/www/project/symfony/releases/20200509213543Z/var/cache/prod/profiler). at /var/www/project/symfony/releases/20200509213543Z/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:43)"}
This looks like a permissions issue because every time I deploy, this error comes up. Is is possible I can do something from the NGINX perspective to ensure this functions properly? Or is this an ansible solution? I'm trying to avoid manually fixing these errors with each deployment.
The user running the deployment seems to be different than the one that runs php, that's why the user doesn't have permissions to the cache directory after cache:warmup is run.
You have several options:
Change the user the app runs under:
Since you say you are using nginx I guess you are running php-fpm. You can change the user and group parameters in your php-fpm.conf to the one running the deployment. If you are running multiple applications, create a new pool. (Here's slightly outdated guide to fpm and pools to get you going, and the FPM reference).
Adjust primary groups and umask or acls so both users have access.
Run the cache tasks as the php user using become.
Fix permissions as part of the deploy process by running an ansible task. You can use the file module for this. You can either use open permissions or use become.
Keep in mind that using become (the last two options) requires changing the sudoers file so the deploy user can act as the php user.
If you have an uploads directory under public that needs write access by the php process, you need to fix those permissions too.
I figured out the issue.
It was purely a permissions issue that I had to firstly go to the highest level folder of where the var prod folder was and updated the permissions using chown then updated the permissions for all folder below recursively using chmod to ensure everything else moving forward would be written just as the parent was.
Issue happens probably because ansible runs on root user, but PHP server didn't
Try to add the last step for change ownership of directory in the playbook
- name: Fix user rights
command: 'chown -R www-data: /var/www/project/public'
tags:
- deploy
in my example ownership grants to user www-data (default), but in your case it can be different.
For check right user, use command
cd /var/www/project && ls -la
here is my shell snip
Maan#DESKTOP-TNA7PJU MINGW64 /d/xampp1/htdocs/app
$ bin/cake serve
Exception: Shell class for "Serve" could not be found. in [D:\xampp1\htdocs\app\vendor\cakephp\cakephp\src\Console\ShellDispatcher.php, line 327]
Maan#DESKTOP-TNA7PJU MINGW64 /d/xampp1/htdocs/app
$ cd ../pocketpa-git-clone000000/
Maan#DESKTOP-TNA7PJU MINGW64 /d/xampp1/htdocs/pocketpa-git-clone000000 (master)
$ bin/cake serve
Exception: Shell class for "Serve" could not be found. in [D:\xampp1\htdocs\pocketpa-git-clone000000\vendor\cakephp\cakephp\src\Console\ShellDispatcher.php, line 327]
Warning Error: file_put_contents(D:\xampp1\htdocs\pocketpa-git-clone000000\logs\cli-error.log): failed to open stream: No such file or directory in [D:\xampp1\htdocs\pocketpa-git-clone000000\vendor\cakephp\cakephp\src\Log\Engine\FileLog.php, line 133]
PHP Warning: file_put_contents(D:\xampp1\htdocs\pocketpa-git-clone000000\logs\cli-error.log): failed to open stream: No such file or directory in D:\xampp1\htdocs\pocketpa-git-clone000000\vendor\cakephp\cakephp\src\Log\Engine\FileLog.php on line 133
last night i shut down my pc and in morning when i restart i am facing this issue
cakephp version 3.4.14
php 5.6.36
and having this problem when wants to start project
Sorry my bad i was messed up with diffferent projects i was working on Laravel Projects and using frequently
php artisan serve
This command will start a development server at http://localhost:8000:
when i come back to CakePhp Project i was messed up and trying
bin\cake serve
command to start local server for cakephp environment http://localhost:8765/
thats make me so much trouble
But the orignal command to run CakePhp Sever on LocalHost is
bin\cake server
here you can get more details https://book.cakephp.org/3.0/en/installation.html#development-server
I'm deploying code to a single-instance web server AWS EB environment that will provision/update my connected RDS database. I've got an .ebextensions file that calls deployment code:
---
container_commands:
01deploydb:
command: /var/www/html/php/cli/deploy-db.php
leader_only: true
On the same deployment, I dropped the deploy-db.php file back one directory into /cli/. On deployment, I get ERROR: [Instance: i-*****] Command failed on instance. Return code: 127 Output: /bin/sh: /var/www/html/php/cli/deploy-db.php: No such file or directory.
container_command 01deploydb in .ebextensions/01_db.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
If I deploy a version that does not include the command, then deploy a second update including the command, there is no error. However, adding the command and the file it calls at the same time produces the error. A similar sequence occurred earlier with a different command/file.
My question is: is there a documented order/sequence for how AWS updates the environment? I would have expected that my new version would have fully deployed (and the .php file installed) before container_commands are called.
The commands: section runs before the project files are put in place. This is where you can install server packages for example.
The container_commands: section runs in a staging directory before the files are put in its final destination. Here you can modify your files if you need to. Current path is this staging directory so you can run it like this (I might get the app directory wrong, maybe it should be php/cli/deploy-db.php)
container_commands:
01deploydb:
command: cli/deploy-db.php
leader_only: true
Reference for above: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
You can also run a post deploy scripts. This is not very well documented (at least it wasn't). You can do something like this (it won't be leader only though, but you could put a file in this directory through a container_commands:):
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_deploy.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
/var/www/html/php/cli/deploy-db.php
I have a Laravel 5.1 application that I'm trying to deploy on my CentOS 6.4 VPS server. The problem is that I am getting Error 500 when trying to load the page. When I check the error log it shows me this:
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/home/pams/pams_todo_list/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /home/pams/pams_todo_list/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87
I have changed the permissions in pams_todo_list/storage and pams_todo_list/vendors to 777 instead of 755 as a test, but no love.
This problem has been solved, thanks to FFForever and lagbox on the Laravel IRC channel.
My owner permissions were wrong. I had inadvertently uploaded the project using the root account. The fix was two fold. First, I setup suPHP as my php handler (I do have root access to this server) through the EasyApache3 UI in WHM. Then I set the owner:
chown -R pams:pams pams_todo_list
Now it works. I cannot say if it would have worked without setting up suPHP, however it was strongly recommended to set that up, so I did.