Server Configuration Notes

Docker

installation

Official Website

add docker group

sudo groupadd docker

sudo usermod -aG docker $USER

Try to run: docker run hello-world

build a image

docker build -t logsearcherbackend .

run a container

docker run -d -p 2223:2223 logsearcherbackend

Mysql

installation

1
2
3
4
5
sudo apt-get update
sudo apt-get install mysql-server
sudo mysql_secure_installation
systemctl status mysql.service
mysqladmin -p -u root version

commands

1
mysql -u root -p
1
2
mysql> use logsearcher;
mysql> show tables;

PHP

1
sudo apt-get install php php-mbstring php-xml php-mysql php7.0-fpm composer unzip

nginx

Check this Introduction.

1
2
3
4
5
6
7
8
9
10
11
12
13
sudo apt-get install nginx

systemctl start nginx
systemctl stop nginx
systemctl restart nginx

sudo chown yzhang:yzhang /var/www/html/quickstart

sudo chgrp -R www-data storage bootstrap/cache

sudo chmod -R ug+rwx storage bootstrap/cache

# or use sudo chown -R 777 www-data /var/www/html/quickstart
/etc/nginx/conf.d/logsearcher.com
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

server {
listen 8080;
listen [::]:8080;

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /var/www/html/logsearcher/public;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

server_name logsearcher.com www.logsearcher.com;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

composer

1
2
3
4
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
1
sudo mv composer.phar /usr/local/bin/composer
.bashrc
1
2
3
4
5
# for mac
export PATH="$HOME/.composer/vendor/bin:$PATH"

# for ubuntu
export PATH="$HOME/.config/composer/vendor/bin:$PATH"

laravel

1
composer global require laravel/installer

setup schedule on linux

1
2
crontab -e
* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1

notice the timeout of php

Problem of Guzzle for opening the stream. Later find out, it was the timeout of php socket.
Make sure you have always set the timeout enough for a long term synchro call.

configure the .env

1
cp .env.example .env

Make sure to change following config:

  • QUEUE_DRIVER
  • APP_ENV
  • APP_DEBUG
  • DB_DATABASE
  • DB_USERNAME
  • DB_PASSWORD

run commands

1
2
composer install
php artisan migrate

Vim

install awesome vim

1
2
git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_awesome_vimrc.sh