To deploy a Laravel app with Breeze Inertia SSR to AWS Elastic Beanstalk, you need to make sure that the Node server for Inertia can run. Here are the steps you can follow:
- Make sure that Node.js is installed on your Elastic Beanstalk instance. You can do this by adding a
.ebextensionsfolder to your project root and creating a file callednode.configwith the following content:
packages:
yum:
nodejs: []
commands:
"echo 'export PATH=$PATH:/opt/elasticbeanstalk/node-install/node-v14.16.0-linux-x64/bin' >> /etc/profile.d/node.sh":
cwd: "/tmp"
This will install Node.js on your instance and add it to the PATH.
- Make sure that your Elastic Beanstalk instance has enough memory to run the Node server. You can do this by adding a file called
.platform/nginx/conf.d/elasticbeanstalk/php.confwith the following content:
location / {
client_max_body_size 100M;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Increase the memory limit for the Node server
proxy_set_header X-Node-Memory-Limit "512M";
}
This will increase the memory limit for the Node server to 512MB.
- Make sure that your Elastic Beanstalk instance can run npm and node commands. You can do this by adding a file called
.platform/hooks/prebuild/01_install_dependencies.shwith the following content:
#!/bin/bash
# Install npm and Node.js
curl -sL https://rpm.nodesource.com/setup_14.x | bash -
yum install -y nodejs
# Install dependencies
cd /var/app/current
npm install
This will install npm and Node.js and then install the dependencies for your project.
- Make sure that your Elastic Beanstalk instance can run the Node server. You can do this by adding a file called
.platform/hooks/postdeploy/01_start_node_server.shwith the following content:
#!/bin/bash
# Start the Node server
cd /var/app/current
npm run start
This will start the Node server after the deployment is complete.
With these steps, you should be able to deploy your Laravel app with Breeze Inertia SSR to AWS Elastic Beanstalk.