Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ahaneef29/63c25dacb08f68ffd31a5efccd7c0f06 to your computer and use it in GitHub Desktop.
Save ahaneef29/63c25dacb08f68ffd31a5efccd7c0f06 to your computer and use it in GitHub Desktop.
Laravel On Azure Web Apps. Enabling Queues and Job Workers as well
# name this file as "startup.sh" and call it from "startup command" as "/home/startup.sh"
# check out my YouTube video "https://youtu.be/-PGhVFsOnGA"
cp /home/default /etc/nginx/sites-enabled/default
cp /home/php.ini /usr/local/etc/php/conf.d/php.ini
# install support for webp file conversion
apt-get update --allow-releaseinfo-change && apt-get install -y libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libwebp-dev \
&& docker-php-ext-configure gd --with-freetype --with-webp --with-jpeg
docker-php-ext-install gd
# install support for queue
apt-get install -y supervisor
cp /home/laravel-worker.conf /etc/supervisor/conf.d/laravel-worker.conf
# restart nginx
service nginx restart
service supervisor restart
php /home/site/wwwroot/artisan down --refresh=15 --secret="1630542a-246b-4b66-afa1-dd72a4c43515"
php /home/site/wwwroot/artisan migrate --force
# Clear caches
php /home/site/wwwroot/artisan cache:clear
# Clear expired password reset tokens
#php /home/site/wwwroot/artisan auth:clear-resets
# Clear and cache routes
php /home/site/wwwroot/artisan route:cache
# Clear and cache config
php /home/site/wwwroot/artisan config:cache
# Clear and cache views
php /home/site/wwwroot/artisan view:cache
# Install node modules
# npm ci
# Build assets using Laravel Mix
# npm run production --silent
# uncomment next line if you dont have S3 or Blob storage
#php /home/site/wwwroot/artisan storage:link
# Turn off maintenance mode
php /home/site/wwwroot/artisan up
# run worker
nohup php /home/site/wwwroot/artisan queue:work &
process_name=%(program_name)s_%(process_num)02d
command=php /home/site/wwwroot/artisan queue:work --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=forge
numprocs=8
redirect_stderr=true
stdout_logfile=/home/site/wwwroot/storage/logs/worker.log
stopwaitsecs=3600
# nginx default file, name it as "default"
# check out my YouTube video "https://youtu.be/-PGhVFsOnGA"
server {
#proxy_cache cache;
#proxy_cache_valid 200 1s;
listen 8080;
listen [::]:8080;
root /home/site/wwwroot/public;
server_name mywebapp.azurewebsites.net;
port_in_redirect off;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
if ($http_x_arr_ssl = "") {
return 301 https://$host$request_uri;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ /\.(?!well-known).* {
deny all;
}
# Add locations of phpmyadmin here.
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 3600;
fastcgi_read_timeout 3600;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}
error_log=/dev/stderr
display_errors=Off
log_errors=On
display_startup_errors=Off
date.timezone=Asia/Dubai
memory_limit=256M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment