Thursday, April 23, 2020

linux server environment setup step by step process

sudo apt update

sudo apt install curl wget php-cli php-zip php-mbstring git unzip php-xml php7.2-gd

sudo service apache2 restart


php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

HASH="$(wget -q -O - https://composer.github.io/installer.sig)"




php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH')
{ echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer



sudo a2enmod rewrite

sudo chown -R www-data:www-data /var/www/html/sitedomain

sudo nano /etc/apache2/sites-available/000-default.conf


//for centos7
sudo chmod -R gu+w storage/
sudo chmod -R guo+w storage/ sudo chmod -R gu+w bootstrap/cache/ sudo chmod -R guo+w bootstrap/cache/

//for centos7

then

DocumentRoot /var/www/html/sitedomain/public
ServerName sitedomain.com
CustomLog /var/log/apache2/sitedomain.com-access.log combined
ErrorLog /var/log/apache2/sitedomain.com-error.log

Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted

sudo service apache2 restart

https://docs.beyondco.de/laravel-websockets/1.0/basic-usage/starting.html#using-a-different-port

MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=password
MAIL_ENCRYPTION=null

truncate -s0 error.log //for truncate any file

vim /etc/mysql/mysql.conf.d/mysqld.cnf
systemctl restart mysql.service


[program:websockets]
command=/usr/bin/php /var/www/html/sitedomain/artisan websockets:serve --port=3030
numprocs=1
autostart=true
autorestart=true
user=root
stdout_logfile=/var/www/html/sitedomain/websockets.log



[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/sitedomain/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=root
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/html/sitedomain/worker.log
stopwaitsecs=3600


https://stillat.com/blog/2016/12/07/laravel-task-scheduling-running-the-task-scheduler


[program:laravel_corn]
command=* * * * * php /var/www/html/sitedomain/artisan schedule:run >> /dev/null 2>&1
process_name=%(program_name)s_%(process_num)02d
numprocs=1
autostart=true
autorestart=true
startsecs=0
user=www-data
redirect_stderr=true
stderr_logfile = /var/www/html/sitedomain/laravel_corn_err.log
stdout_logfile = /var/www/html/sitedomain/laravel_corn_stdout.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=10


In SqsConnector.php line 26:

Class 'Aws\Sqs\SqsClient' not found


nano /etc/php/7.2/apache2/php.ini

max_execution_time = 120
max_input_vars = 2500
memory_limit = 128M
post_max_size = 32M
upload_max_filesize = 24M
max_file_uploads = 100

sudo service apache2 restart

ab -k -n 500 -c 50 http://sitedomain.com/ //apache branch mark testing for 500 request and 50 concurent user