Running Laravel's migration command on AWS Elastic Beanstalk
I'm having a hard time deploying a Laravel app for test purposes on AWS Elastic Beanstalk.
Followed all sources i could find in web including AWS documentation.
Created a Elastic Beanstalk environment and uploading an application is straightforward as long as i do not include .ebextensions
and the .yaml
file in it.
Based on Maximilian's tutorial i created init.config
file inside .ebextensions
with contents:
container_commands:
01initdb:
command: "php artisan migrate"
Environment gets to a degraded state as it finishes to update and i get the following logs:
[2018-11-20T23:14:08.485Z] INFO [7969] : Command processor returning results:
{"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"(TRUNCATED)...y exists")n/var/app/ondeck/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458nn2 PDOStatement::execute()n/var/app/ondeck/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458nnPlease use the argument -v to see more details. ncontainer_command 01initdb in .ebextensions/init.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI","returncode":1,"events":}],"truncated":"true"}
I have been trying different .config
files from other instruction resources but none of them seems to work.
I'm running:
Laravel Framework 5.7.5
EB Platform uses PHP 7.2 running on 64bit Amazon Linux/2.8.4
RDS uses MySQL 5.6.40
I really do not know what is going on and would appreciate if you could give any suggestion.
laravel amazon-web-services amazon-elastic-beanstalk
add a comment |
I'm having a hard time deploying a Laravel app for test purposes on AWS Elastic Beanstalk.
Followed all sources i could find in web including AWS documentation.
Created a Elastic Beanstalk environment and uploading an application is straightforward as long as i do not include .ebextensions
and the .yaml
file in it.
Based on Maximilian's tutorial i created init.config
file inside .ebextensions
with contents:
container_commands:
01initdb:
command: "php artisan migrate"
Environment gets to a degraded state as it finishes to update and i get the following logs:
[2018-11-20T23:14:08.485Z] INFO [7969] : Command processor returning results:
{"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"(TRUNCATED)...y exists")n/var/app/ondeck/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458nn2 PDOStatement::execute()n/var/app/ondeck/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458nnPlease use the argument -v to see more details. ncontainer_command 01initdb in .ebextensions/init.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI","returncode":1,"events":}],"truncated":"true"}
I have been trying different .config
files from other instruction resources but none of them seems to work.
I'm running:
Laravel Framework 5.7.5
EB Platform uses PHP 7.2 running on 64bit Amazon Linux/2.8.4
RDS uses MySQL 5.6.40
I really do not know what is going on and would appreciate if you could give any suggestion.
laravel amazon-web-services amazon-elastic-beanstalk
1
Are you able to see any more details on the error in/var/log/eb-activity.log
using the console? Looks like it is running the migration but it could be a DB error that happens while it is running.
– Peter
Nov 21 '18 at 1:43
add a comment |
I'm having a hard time deploying a Laravel app for test purposes on AWS Elastic Beanstalk.
Followed all sources i could find in web including AWS documentation.
Created a Elastic Beanstalk environment and uploading an application is straightforward as long as i do not include .ebextensions
and the .yaml
file in it.
Based on Maximilian's tutorial i created init.config
file inside .ebextensions
with contents:
container_commands:
01initdb:
command: "php artisan migrate"
Environment gets to a degraded state as it finishes to update and i get the following logs:
[2018-11-20T23:14:08.485Z] INFO [7969] : Command processor returning results:
{"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"(TRUNCATED)...y exists")n/var/app/ondeck/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458nn2 PDOStatement::execute()n/var/app/ondeck/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458nnPlease use the argument -v to see more details. ncontainer_command 01initdb in .ebextensions/init.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI","returncode":1,"events":}],"truncated":"true"}
I have been trying different .config
files from other instruction resources but none of them seems to work.
I'm running:
Laravel Framework 5.7.5
EB Platform uses PHP 7.2 running on 64bit Amazon Linux/2.8.4
RDS uses MySQL 5.6.40
I really do not know what is going on and would appreciate if you could give any suggestion.
laravel amazon-web-services amazon-elastic-beanstalk
I'm having a hard time deploying a Laravel app for test purposes on AWS Elastic Beanstalk.
Followed all sources i could find in web including AWS documentation.
Created a Elastic Beanstalk environment and uploading an application is straightforward as long as i do not include .ebextensions
and the .yaml
file in it.
Based on Maximilian's tutorial i created init.config
file inside .ebextensions
with contents:
container_commands:
01initdb:
command: "php artisan migrate"
Environment gets to a degraded state as it finishes to update and i get the following logs:
[2018-11-20T23:14:08.485Z] INFO [7969] : Command processor returning results:
{"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"(TRUNCATED)...y exists")n/var/app/ondeck/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458nn2 PDOStatement::execute()n/var/app/ondeck/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458nnPlease use the argument -v to see more details. ncontainer_command 01initdb in .ebextensions/init.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI","returncode":1,"events":}],"truncated":"true"}
I have been trying different .config
files from other instruction resources but none of them seems to work.
I'm running:
Laravel Framework 5.7.5
EB Platform uses PHP 7.2 running on 64bit Amazon Linux/2.8.4
RDS uses MySQL 5.6.40
I really do not know what is going on and would appreciate if you could give any suggestion.
laravel amazon-web-services amazon-elastic-beanstalk
laravel amazon-web-services amazon-elastic-beanstalk
edited Nov 21 '18 at 20:20
Guilherme Souza
asked Nov 20 '18 at 23:26
Guilherme SouzaGuilherme Souza
4315
4315
1
Are you able to see any more details on the error in/var/log/eb-activity.log
using the console? Looks like it is running the migration but it could be a DB error that happens while it is running.
– Peter
Nov 21 '18 at 1:43
add a comment |
1
Are you able to see any more details on the error in/var/log/eb-activity.log
using the console? Looks like it is running the migration but it could be a DB error that happens while it is running.
– Peter
Nov 21 '18 at 1:43
1
1
Are you able to see any more details on the error in
/var/log/eb-activity.log
using the console? Looks like it is running the migration but it could be a DB error that happens while it is running.– Peter
Nov 21 '18 at 1:43
Are you able to see any more details on the error in
/var/log/eb-activity.log
using the console? Looks like it is running the migration but it could be a DB error that happens while it is running.– Peter
Nov 21 '18 at 1:43
add a comment |
1 Answer
1
active
oldest
votes
I finally found my way out. Providing some documentation for anyone that hits the same issue.
What i was trying to do...
My main objective was to test a Laravel 5.7 application on a live AWS Elastic Beanstalk (EB) server. I was also in need of a way to visualize data using phpMyAdmin, a tool that fits my need. This is a very simple CRUD app just for learning the basics of both technologies.
What i did (worked)
Followed the normal workflow of creating an EB application mainly using web console.
- Name the application
- Chose PHP as platform
- Start off with a base application (do not upload code yet)
- Hit configure more options
- In security card select your key pair and save. (This is valuable for SSH'ing on your server)
- In database card create a RDS instance. Select whatever options that fits your needs and set a username/password.
- Create environment.
After a while you should have all resources created by EB (EC2 and RDS instances, security group, EIP, Buckets, etc) in the app environment.
Preparing you Laravel application is a straight forward process. You must not forget to change config/database.php to read server variables. My approach was to define them in at the start of the file.
The main sources of troubles resides in configuring your server instance to include all software and configuration needed by your app and specific needs. This is done by including a .yaml
file inside .ebextensions
folder. This folder should reside in the root directory of you laravel application. It's also a good idea to check your syntax before submitting another app version to EB. As per my needs i used this script which basically installs phpMyAdmin as i deploy a new version. Specifically for this startup script, environment variables should be defined, namely $PMA_VER, $PMA_USERNAME, $PMA_PASSWORD
for phpMyAdmin to work. You can create more environment variables in software tab of you EB configuration page. Read the docs.
Another detail that might cause issues in running commands at start up using yaml script (specifically migration) is caused by Laravel and MySql versions. As for example, i am using Laravel 5.7 and the default mySql version option in EB RDS creation wizard is something like 5.6.x. This will throw issues of the type:
IlluminateDatabaseQueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
If this is your scenario, despite you should have already googled and sorted out that adding the line of code Schema::defaultStringLength(191);
to the boot function of your app/Providers/AppServiceProviders.php file will do the trick.
You can do a typical migration passing the script:
container_commands:
01_drop_tables:
command:
"php artisan migrate:fresh"
02_initdb:
command:
"php artisan migrate"
This will drop existing tables avoiding conflicts and create new one based on you code. You can read more logs from you server by SSH'ing and getting content of /var/log/eb-activity.log
.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403142%2frunning-laravels-migration-command-on-aws-elastic-beanstalk%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I finally found my way out. Providing some documentation for anyone that hits the same issue.
What i was trying to do...
My main objective was to test a Laravel 5.7 application on a live AWS Elastic Beanstalk (EB) server. I was also in need of a way to visualize data using phpMyAdmin, a tool that fits my need. This is a very simple CRUD app just for learning the basics of both technologies.
What i did (worked)
Followed the normal workflow of creating an EB application mainly using web console.
- Name the application
- Chose PHP as platform
- Start off with a base application (do not upload code yet)
- Hit configure more options
- In security card select your key pair and save. (This is valuable for SSH'ing on your server)
- In database card create a RDS instance. Select whatever options that fits your needs and set a username/password.
- Create environment.
After a while you should have all resources created by EB (EC2 and RDS instances, security group, EIP, Buckets, etc) in the app environment.
Preparing you Laravel application is a straight forward process. You must not forget to change config/database.php to read server variables. My approach was to define them in at the start of the file.
The main sources of troubles resides in configuring your server instance to include all software and configuration needed by your app and specific needs. This is done by including a .yaml
file inside .ebextensions
folder. This folder should reside in the root directory of you laravel application. It's also a good idea to check your syntax before submitting another app version to EB. As per my needs i used this script which basically installs phpMyAdmin as i deploy a new version. Specifically for this startup script, environment variables should be defined, namely $PMA_VER, $PMA_USERNAME, $PMA_PASSWORD
for phpMyAdmin to work. You can create more environment variables in software tab of you EB configuration page. Read the docs.
Another detail that might cause issues in running commands at start up using yaml script (specifically migration) is caused by Laravel and MySql versions. As for example, i am using Laravel 5.7 and the default mySql version option in EB RDS creation wizard is something like 5.6.x. This will throw issues of the type:
IlluminateDatabaseQueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
If this is your scenario, despite you should have already googled and sorted out that adding the line of code Schema::defaultStringLength(191);
to the boot function of your app/Providers/AppServiceProviders.php file will do the trick.
You can do a typical migration passing the script:
container_commands:
01_drop_tables:
command:
"php artisan migrate:fresh"
02_initdb:
command:
"php artisan migrate"
This will drop existing tables avoiding conflicts and create new one based on you code. You can read more logs from you server by SSH'ing and getting content of /var/log/eb-activity.log
.
add a comment |
I finally found my way out. Providing some documentation for anyone that hits the same issue.
What i was trying to do...
My main objective was to test a Laravel 5.7 application on a live AWS Elastic Beanstalk (EB) server. I was also in need of a way to visualize data using phpMyAdmin, a tool that fits my need. This is a very simple CRUD app just for learning the basics of both technologies.
What i did (worked)
Followed the normal workflow of creating an EB application mainly using web console.
- Name the application
- Chose PHP as platform
- Start off with a base application (do not upload code yet)
- Hit configure more options
- In security card select your key pair and save. (This is valuable for SSH'ing on your server)
- In database card create a RDS instance. Select whatever options that fits your needs and set a username/password.
- Create environment.
After a while you should have all resources created by EB (EC2 and RDS instances, security group, EIP, Buckets, etc) in the app environment.
Preparing you Laravel application is a straight forward process. You must not forget to change config/database.php to read server variables. My approach was to define them in at the start of the file.
The main sources of troubles resides in configuring your server instance to include all software and configuration needed by your app and specific needs. This is done by including a .yaml
file inside .ebextensions
folder. This folder should reside in the root directory of you laravel application. It's also a good idea to check your syntax before submitting another app version to EB. As per my needs i used this script which basically installs phpMyAdmin as i deploy a new version. Specifically for this startup script, environment variables should be defined, namely $PMA_VER, $PMA_USERNAME, $PMA_PASSWORD
for phpMyAdmin to work. You can create more environment variables in software tab of you EB configuration page. Read the docs.
Another detail that might cause issues in running commands at start up using yaml script (specifically migration) is caused by Laravel and MySql versions. As for example, i am using Laravel 5.7 and the default mySql version option in EB RDS creation wizard is something like 5.6.x. This will throw issues of the type:
IlluminateDatabaseQueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
If this is your scenario, despite you should have already googled and sorted out that adding the line of code Schema::defaultStringLength(191);
to the boot function of your app/Providers/AppServiceProviders.php file will do the trick.
You can do a typical migration passing the script:
container_commands:
01_drop_tables:
command:
"php artisan migrate:fresh"
02_initdb:
command:
"php artisan migrate"
This will drop existing tables avoiding conflicts and create new one based on you code. You can read more logs from you server by SSH'ing and getting content of /var/log/eb-activity.log
.
add a comment |
I finally found my way out. Providing some documentation for anyone that hits the same issue.
What i was trying to do...
My main objective was to test a Laravel 5.7 application on a live AWS Elastic Beanstalk (EB) server. I was also in need of a way to visualize data using phpMyAdmin, a tool that fits my need. This is a very simple CRUD app just for learning the basics of both technologies.
What i did (worked)
Followed the normal workflow of creating an EB application mainly using web console.
- Name the application
- Chose PHP as platform
- Start off with a base application (do not upload code yet)
- Hit configure more options
- In security card select your key pair and save. (This is valuable for SSH'ing on your server)
- In database card create a RDS instance. Select whatever options that fits your needs and set a username/password.
- Create environment.
After a while you should have all resources created by EB (EC2 and RDS instances, security group, EIP, Buckets, etc) in the app environment.
Preparing you Laravel application is a straight forward process. You must not forget to change config/database.php to read server variables. My approach was to define them in at the start of the file.
The main sources of troubles resides in configuring your server instance to include all software and configuration needed by your app and specific needs. This is done by including a .yaml
file inside .ebextensions
folder. This folder should reside in the root directory of you laravel application. It's also a good idea to check your syntax before submitting another app version to EB. As per my needs i used this script which basically installs phpMyAdmin as i deploy a new version. Specifically for this startup script, environment variables should be defined, namely $PMA_VER, $PMA_USERNAME, $PMA_PASSWORD
for phpMyAdmin to work. You can create more environment variables in software tab of you EB configuration page. Read the docs.
Another detail that might cause issues in running commands at start up using yaml script (specifically migration) is caused by Laravel and MySql versions. As for example, i am using Laravel 5.7 and the default mySql version option in EB RDS creation wizard is something like 5.6.x. This will throw issues of the type:
IlluminateDatabaseQueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
If this is your scenario, despite you should have already googled and sorted out that adding the line of code Schema::defaultStringLength(191);
to the boot function of your app/Providers/AppServiceProviders.php file will do the trick.
You can do a typical migration passing the script:
container_commands:
01_drop_tables:
command:
"php artisan migrate:fresh"
02_initdb:
command:
"php artisan migrate"
This will drop existing tables avoiding conflicts and create new one based on you code. You can read more logs from you server by SSH'ing and getting content of /var/log/eb-activity.log
.
I finally found my way out. Providing some documentation for anyone that hits the same issue.
What i was trying to do...
My main objective was to test a Laravel 5.7 application on a live AWS Elastic Beanstalk (EB) server. I was also in need of a way to visualize data using phpMyAdmin, a tool that fits my need. This is a very simple CRUD app just for learning the basics of both technologies.
What i did (worked)
Followed the normal workflow of creating an EB application mainly using web console.
- Name the application
- Chose PHP as platform
- Start off with a base application (do not upload code yet)
- Hit configure more options
- In security card select your key pair and save. (This is valuable for SSH'ing on your server)
- In database card create a RDS instance. Select whatever options that fits your needs and set a username/password.
- Create environment.
After a while you should have all resources created by EB (EC2 and RDS instances, security group, EIP, Buckets, etc) in the app environment.
Preparing you Laravel application is a straight forward process. You must not forget to change config/database.php to read server variables. My approach was to define them in at the start of the file.
The main sources of troubles resides in configuring your server instance to include all software and configuration needed by your app and specific needs. This is done by including a .yaml
file inside .ebextensions
folder. This folder should reside in the root directory of you laravel application. It's also a good idea to check your syntax before submitting another app version to EB. As per my needs i used this script which basically installs phpMyAdmin as i deploy a new version. Specifically for this startup script, environment variables should be defined, namely $PMA_VER, $PMA_USERNAME, $PMA_PASSWORD
for phpMyAdmin to work. You can create more environment variables in software tab of you EB configuration page. Read the docs.
Another detail that might cause issues in running commands at start up using yaml script (specifically migration) is caused by Laravel and MySql versions. As for example, i am using Laravel 5.7 and the default mySql version option in EB RDS creation wizard is something like 5.6.x. This will throw issues of the type:
IlluminateDatabaseQueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
If this is your scenario, despite you should have already googled and sorted out that adding the line of code Schema::defaultStringLength(191);
to the boot function of your app/Providers/AppServiceProviders.php file will do the trick.
You can do a typical migration passing the script:
container_commands:
01_drop_tables:
command:
"php artisan migrate:fresh"
02_initdb:
command:
"php artisan migrate"
This will drop existing tables avoiding conflicts and create new one based on you code. You can read more logs from you server by SSH'ing and getting content of /var/log/eb-activity.log
.
edited Nov 21 '18 at 20:19
answered Nov 21 '18 at 20:13
Guilherme SouzaGuilherme Souza
4315
4315
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403142%2frunning-laravels-migration-command-on-aws-elastic-beanstalk%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Are you able to see any more details on the error in
/var/log/eb-activity.log
using the console? Looks like it is running the migration but it could be a DB error that happens while it is running.– Peter
Nov 21 '18 at 1:43