Last active
May 19, 2020 03:22
-
-
Save irfan-dahir/b11e11a7c7303e4b1427bbeaf4634e3e to your computer and use it in GitHub Desktop.
Quick & dirty local instance installation. I use this for the slave servers only who's only inbound access is restricted to the master. If you're using this locally, that's fine then. Otherwise for production, use it as a reference and secure the permissions on your own accord.
This file contains 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
#!/usr/bin/env bash | |
BUILD_DEPS="zip unzip git" | |
DEPS="php7.3 curl redis supervisor apache2 php7.3-{xml,mbstring,common,curl,opcache} composer" | |
JIKAN_PATH="/var/www/jikan" | |
apt-get update \ | |
&& apt-get -y dist-upgrade \ | |
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C \ | |
&& echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu $(lsb_release -s -c) main" | tee /etc/apt/sources.list.d/php.list \ | |
&& apt install software-properties-common \ | |
&& add-apt-repository ppa:ondrej/php \ | |
&& apt-get update \ | |
&& apt-get -y install --no-install-recommends $BUILD_DEPS $DEPS \ | |
&& service redis start | |
php -v | |
chmod -R 755 /var/www | |
mkdir /var/www/jikan | |
chmod -R 777 /var/www/jikan | |
git clone https://github.com/jikan-me/jikan-rest.git /var/www/jikan | |
chmod -R 777 /var/www/jikan | |
cp "$JIKAN_PATH/.env.dist" "$JIKAN_PATH/.env" | |
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)" | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" | |
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] | |
then | |
>&2 echo 'ERROR: Invalid installer signature' | |
rm composer-setup.php | |
exit 1 | |
fi | |
php composer-setup.php --quiet | |
RESULT=$? | |
rm composer-setup.php | |
chmod -R 777 /var/www/jikan | |
php composer.phar install -d /var/www/jikan | |
php /var/www/jikan/artisan key:generate | |
php /var/www/jikan/artisan cache:method queue | |
php /var/www/jikan/artisan cache:driver redis | |
a2enmod deflate | |
a2enmod rewrite | |
sed -i '/<Directory \/var\/www\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride all/' /etc/apache2/apache2.conf | |
bash -c 'echo -e "<VirtualHost *:80>\n#ServerName www.example.com\nServerAdmin [email protected]\nDocumentRoot /var/www/jikan/public\nErrorLog \${APACHE_LOG_DIR}/error.log\nCustomLog \${APACHE_LOG_DIR}/access.log combined\n</VirtualHost>" > "/etc/apache2/sites-available/000-default.conf"' | |
apt-get clean | |
service apache2 restart | |
bash -c 'echo -e "[program:jikan-worker]\nprocess_name=%(program_name)s_%(process_num)02d\ncommand=php '$JIKAN_PATH'/artisan queue:work --queue=high,low\nautostart=true\nautorestart=true\nnumprocs=1\nstdout_logfile='$JIKAN_PATH'/storage/logs/worker.log\nstderr_logfile='$JIKAN_PATH'/storage/logs/worker.error.log" > /etc/supervisor/conf.d/jikan-worker.conf' | |
service supervisor start | |
supervisorctl reread | |
supervisorctl reload | |
supervisorctl update | |
supervisorctl start jikan-worker:* | |
redis-cli config set stop-writes-on-bgsave-error no | |
chown -R $USER:$USER /var/www/jikan | |
chmod -R 777 /var/www/jikan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment