Skip to content

Instantly share code, notes, and snippets.

@johndavedecano
Last active September 15, 2021 20:39
Show Gist options
  • Save johndavedecano/09c47551404d432474a06c2f5d9c59a9 to your computer and use it in GitHub Desktop.
Save johndavedecano/09c47551404d432474a06c2f5d9c59a9 to your computer and use it in GitHub Desktop.
sudo snap install --classic certbot
sudo certbot --nginx
crontab -e
12 3 * * * /snap/bin/certbot renew
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /var/www/html/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
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 ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
apt-get update
apt-get install -y \
git \
unzip \
zip \
curl \
nginx \
supervisor
apt-get install -y \
php7.4-fpm \
php7.4-common \
php7.4-xml \
php7.4-gd \
php7.4-opcache \
php7.4-mbstring \
php7.4-curl \
php7.4-bcmath \
php7.4-iconv \
php7.4-intl \
php7.4-bcmath \
php7.4-mysql \
php7.4-zip \
php7.4-gd \
php7.4-json
apt-get install -y php-redis
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
service php7.4-fpm restart
service php7.4-fpm status
service nginx restart
service nginx status
nano /etc/nginx/sites-available/default
nano /etc/php/7.4/fpm/conf.d/laravel.ini
service php7.4-fpm restart
php artisan key:generate
chown -R www-data:www-data /var/www/html
chmod -R 755 /var/www/html/storage
chmod -R 755 /var/www/html/bootstrap/cache
php artisan storage:link
max_execution_time = 60
memory_limit = 1024M
opcache.enable=1
opcache.memory_consumption=512
opcache.interned_strings_buffer=64
opcache.max_accelerated_files=32531
opcache.validate_timestamps=0
opcache.save_comments=1
opcache.fast_shutdown=0
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:work database --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/html/worker.log
stopwaitsecs=3600
<?php
namespace App\Providers;
use Illuminate\Database\Events\MigrationsStarted;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider {
/**
* Register any application services.
*
* @return void
*/
public function register() {
// check this one here https://github.com/laravel/framework/issues/33238#issuecomment-897063577
Event::listen(MigrationsStarted::class, function (){
if (config('databases.allow_disabled_pk')) {
DB::statement('SET SESSION sql_require_primary_key=0');
}
});
Event::listen(MigrationsEnded::class, function (){
if (config('databases.allow_disabled_pk')) {
DB::statement('SET SESSION sql_require_primary_key=1');
}
});
}
// rest of the class
}
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker:*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment