Last active
November 13, 2021 07:10
-
-
Save dwaqaddi/4d80619f7061c9617f78d12dccd7232a to your computer and use it in GitHub Desktop.
Setup Strapi and Laravel on AWS Lightsail (Nginx)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- SSH to AWS Lightsail Server -- | |
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - | |
sudo apt-get install nodejs | |
node -v && npm -v | |
cd ~ | |
mkdir ~/.npm-global | |
npm config set prefix '~/.npm-global' | |
sudo nano ~/.profile | |
source ~/.profile | |
-- Clone your Strapi Project -- | |
git clone URL | |
cd ./project-folder | |
npm install | |
NODE_ENV=production npm run build | |
npm install pm2@latest -g | |
cd ~ | |
pm2 init | |
sudo nano ecosystem.config.js | |
pm2 start ecosystem.config.js | |
pm2 startup systemd | |
sudo env PATH=$PATH:/usr/bin /home/ubuntu/.npm-global/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu | |
pm2 save | |
pm2 restart ecosystem.config.js | |
If you get a status of 'errored' after restarting, run the command below | |
pm2 del 0 | |
pm2 save | |
pm2 update | |
pm2 restart ecosystem.config.js | |
-- Install Database (SQLite) -- | |
sudo apt install sqlite | |
pm2 restart ecosystem.config.js | |
-- Install Laravel -- | |
composer global require laravel/installer | |
echo 'PATH=$PATH:$HOME/.config/composer/vendor/bin' | sudo tee -a /etc/profile | |
export PATH=PATH=$PATH:$HOME/.config/composer/vendor/bin | |
sudo mkdir -p /opt/bitnami/projects | |
sudo chown $USER /opt/bitnami/projects | |
cd /opt/bitnami/projects | |
laravel new APPNAME | |
sudo chown daemon:daemon /opt/bitnami/projects/APPNAME/storage | |
sudo nano /opt/bitnami/nginx/conf/server_blocks/APPNAME-server-block.conf | |
server { | |
# Port to listen on, can also be set in IP:PORT format | |
listen 80 default_server; | |
root /opt/bitnami/myapp/public; | |
# Catch-all server block | |
# See: https://nginx.org/en/docs/http/server_names.html#miscellaneous_names | |
server_name _; | |
include "/opt/bitnami/nginx/conf/bitnami/*.conf"; | |
} | |
sudo nano /opt/bitnami/nginx/conf/server_blocks/APPNAME-https-server-block.conf | |
server { | |
# Port to listen on, can also be set in IP:PORT format | |
listen 443 ssl default_server; | |
root /opt/bitnami/myapp/public; | |
# Catch-all server block | |
# See: https://nginx.org/en/docs/http/server_names.html#miscellaneous_names | |
server_name _; | |
ssl_certificate bitnami/certs/server.crt; | |
ssl_certificate_key bitnami/certs/server.key; | |
include "/opt/bitnami/nginx/conf/bitnami/*.conf"; | |
} | |
sudo /opt/bitnami/ctlscript.sh restart nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment