October 28, 2019 · Laravel PHP

Setup PHP 7.1 / Laravel

Server Update File Permission

echo "Upgrading to php7.1"
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get upgrade
sudo apt-get remove php7.0
sudo apt-get install php7.1
sudo apt-get install php7.1-xml php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-mysqli php7.1-curl

echo "updating file permission.."
sudo usermod -aG www-data dev
sudo chown -R dev:www-data .
sudo find ./src/ -type d -exec chmod 775 {} \;
#sudo find ./src/ -type d -exec chmod ug+s {} \;
sudo find  ./src/ -type f -exec chmod 664 {} \;
sudo chmod -R 777 ./src/storage
sudo chmod -R 777 ./src/bootstrap/cache/
sudo chmod -R 777 ./src/node_modules
sudo find ./src/ -type d -exec chmod g+s {} \;

npm install
composer install
npm run dev

App Configurations

php artisan key:generate
php artisan migrate
php artisan passport:install
#php artisan passport:keys

Redis

# Server
echo "port 6384" | redis-server -
# Client
redis-cli -p 6384
flushdb

init Application Daemons

bash start-daemon.sh

Daemon

#!/usr/bin/env bash
kill $(ps aux | grep 'artisan' | awk '{print $2}')
nohup php artisan daemon:start-listen-fb-post &> storage/logs/daemons.log &
nohup php artisan daemon:start-listen-schedule &> storage/logs/daemons.log &
nohup php artisan daemon:start-listen-general &> storage/logs/daemons.log &
nohup php artisan daemon:start-listen-plan &> storage/logs/daemons.log &
nohup php artisan queue:work --queue=normal --timeout=0 &> storage/logs/queues.log &
nohup php artisan queue:work --queue=sns --timeout=0 &> storage/logs/queues.log &
echo 'started daemon'