# Postshop

## Installation
```bash
# Install posgres and configure
sudo su - postgres
psql
CREATE USER postshop WITH PASSWORD 'ACvL2(F@H^F)D7gs';
CREATE DATABASE postshopdb WITH OWNER = postshop LC_COLLATE = 'en_US.UTF-8' TEMPLATE template0;

# Clone
git clone --depth 1 https://github.com/nurmuhammet-ali/postshop.git

# Install packages and configure
cd postshop
cp .env.example .env
composer install --prefer-dist
vim .env
# setup db
# ...
    
# Link the storage
php artisan storage:link

# Migrate and seed
php artisan migrate --seed

# Setup permessions (nginx)
chown -R www-data:www-data ./
sudo find -type f -exec chmod 644 {} \;
sudo find -type d -exec chmod 755 {} \;
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

# Setup supervisor
apt-get install supervisor
vim /etc/supervisor/conf.d/laravel-default-worker.conf
[program:laravel-default-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/artisan queue:work --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
user=www-data
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/postshop/storage/logs/worker.log
stopwaitsecs=3600

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-default-worker:*
