Heroku - andreydiveev/wiki GitHub Wiki
Delegate the domain name (wwwizer.com/naked-domain-redirect):
@ A 174.129.25.170
www CNAME proxy.heroku.com
Install macOS:
brew install heroku/brew/heroku
Install Debian/Ubuntu:
wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
Create app:
cd myapp
heroku create
git push heroku master
Setup nginx webroot:
composer require --dev heroku/heroku-buildpack-php
... in myapp/Procfile
:
web: vendor/bin/heroku-php-nginx -C nginx_app.conf public/
Dokku specify buildpack:
echo "https://github.com/heroku/heroku-buildpack-php" >> .buildpacks
Dokku setup MySQL:
dokku plugin:install https://github.com/dokku/dokku-mysql.git
dokku mysql:create my-database
dokku mysql:link my-database-name my-add-name
Git push via ssh-keys:
heroku keys:add
git remote add heroku [email protected]:polar-lake-50525.git
git push heroku master
Config ssh (~/.ssh/config):
Host heroku.com
HostName heroku.com
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
Lumen nginx_app.conf:
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass heroku-fcgi;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
Running Laravel Migrations after Heroku web-hook:
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize",
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
"@php artisan key:generate",
"@php artisan package:discover",
"php artisan migrate --force"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
Run command on remote app from local:
# heroku run php artisan migrate --app my-app-name-12345
Multiple git remotes:
# git remote set-url --add origin https://git.heroku.com/weird-name-12345.git
Show remove env vars:
# heroku config
Set remote env var:
# heroku config:set MY_VAR=value123