Elastic beanstalk environment creation process

798 0 0 0

Last Updated : 2024-04-26 15:58:21

When creating an Elastic beanstalk environment, you might do things such as see the logs generated from the EC2 instance, deploy a composer install, give permissions for FTP connections, Run a php artisan command, add something to .ebextensions ..etc. In this article we will list some of these commands.


  • Example for a congfig file names 01appsesttings.config inside a .ebextensions directory that can be put togethr with the zipped file that will be uploaded as an application version is as follows:
    container_commands:
    01_write_permissions:
    command: "sudo chown -R ec2-user:ec2-user /var/app/current"
    02_ftp_permissions:
    command: "sudo chmod -R 777 /var/app/current"
    03_copy_env_file:
    command: "cp /var/www/html/setupfiles/alpha/.env /var/www/html/"
    04_move_to_root:
    command: "cd /var/www/html/"
    05_get_composer_file:
    command: "sudo curl -sS https://getcomposer.org/installer | sudo php"
    06_move_composer_file:
    command: "sudo mv composer.phar /usr/local/bin/composer"
    07_install_composer:
    command: "sudo ln -s /usr/local/bin/composer /usr/bin/composer"
    08_run_composer_install_for_app:
    command: "sudo composer install"
    09_app_key_generate:
    command: "php artisan key:generate"
    010_move_to_ec2user_root:
    command: "cd /home/ec2-user/"
    011_create_git_dir:
    command: "mkdir Git"
    012_move_to_git_dir:
    command: "cd /home/ec2-user/Git/"
    013_init_bare_git_repo:
    command: "git init --bare myweb.git"
    014_move_to_git_repo:
    command: "cd /home/ec2-user/Git/myweb.git"
    015_create_document_root_var:
    command: "gwt=/var/www/html/"
    016_echo_to_post_receive1:
    command: "echo '#!/bin/sh' > hooks/post-receive"
    017_echo_to_post_receive2:
    command: "echo 'GIT_WORK_TREE=$gwt git checkout -f' >> hooks/post-receive"
    018_grant_permission_to_post-receive:
    command: "chmod +x hooks/post-receive"?

    Mohammed Anwar

    Mohammed Anwar

    Experienced technical lead PHP, MySQL and Laravel Developer for 15+ years, with proven ability to develop and create high-quality and optimized web applications. Great ability to build and optimize database design, schema and queries. Versed programing trainer and instructor delivering web courses and helping others to get into the field in a timely manner. Fast and eager learner for new technologies .