DEPLOY SERVER
Install Docker on server and Install Docker compose
1 . clone dari github git clone https://github.com/bradi25/laraveltest.git laraveltest
-
Pindah direktori cd ~/laraveltest
-
Install composer image dan memasang ke directory laraveltest docker run --rm -v $(pwd):/app composer install
-
set permission di direktori laraveltest sudo chown -R $USER:$USER ~/laraveltest
-
Membuat docker compose yml vim ~/laraveltest/docker-compose.yml docker-compose.yml seperti sudah ada di atas bernama docker-compose.yml
-
Membuat docker file untuk spesifik images Dockerfile yang sudah ada di directory ini bernama Dockerfile
-
Membuat konfigurasi PHP mkdir ~/laraveltest/php vim ~/laraveltest/php/local.ini Tambahkan command ini upload_max_filesize=40M post_max_size=40M
-
Membuat konfigurasi Nginx mkdir -p ~/laraveltest/nginx/conf.d nano ~/laraveltest/nginx/conf.d/app.conf Tambahkan command ini server { listen 80; index index.php index.html; error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; root /var/www/public; location ~ .php$ { try_files
$uri =404; fastcgi_split_path_info ^(.+.php)(/.+)$ ; fastcgi_pass app:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } location / { try_files $uri $uri/ /index.php?$query_string; gzip_static on; } } -
Membuat konfigurasi Mysql mkdir ~/laraveltest/mysql vim ~/laraveltest/mysql/my.cnf Tambahkan command ini [mysqld] general_log = 1 general_log_file = /var/lib/mysql/general.log
-
Mengubah env cp .env.example .env vim .env
DB_CONNECTION=mysql DB_HOST=db DB_PORT=3306 DB_DATABASE=laraveltest DB_USERNAME=root DB_PASSWORD= Jika di production password di buat sulit tapi di sini saya buat kosong
-
Menjalankan Containers Command docker-compose up -d
-
Melihat Containers yang berjalan docker ps
-
Men generate key di env docker-compose exec app php artisan key:generate
-
Membuat User sql docker-compose exec db bash mysql -u root -p GRANT ALL ON laraveltest.* TO 'laraveluser'@'%' IDENTIFIED BY ''; FLUSH PRIVILEGES; exit sql EXIT; exit containers EXIT;
-
Migrasi Database docker-compose exec app php artisan migrate