Install Laravel 8 Ubuntu
Bagaimana cara install Laravel di Ubuntu Linux dan cara konfigurasinya? – Secara umum, konfigurasi Laravel di berbagai OS tidak jauh berbeda. Pada saya akan membagikan bagaimana cara konfigurasi Laravel di Linux, berhubung saya menggunakan Linux berbasis Ubuntu.
Proses Instalasi Pada Ubuntu
Untuk dapat menjalankan Laravel di linux, ada beberapa syarat yang harus dilakukan yaitu:
1. Install PHP
Langkah pertama pastikan bahwa PHP sudah terinstall. Saya anggap anda udah install XAMPP dilinux teman-teman, dimana didalam XAMPP sudah termasuk PHP, MySQL, Apache Server. Namun, jika anda ingin install PHP secara terpisah, anda dapat membaca artikel Install phpmyadmin in Ubuntu.
Jika teman-teman belum tau cara install XAMPP, silahkan baca artikel Cara Install XAMPP Di Linux Ubuntu. Gunakan XAMPP versi terbaru untuk dapat pakai PHP versi diatas 7.4.
Sekarang, jika sudah install XAMPP, mari kita cek dengan menggunakan terminal dengan perintah “php -v” seperti contoh berikut:
neon@pop-os:~$ php -v PHP 7.4.16 (cli) (built: Jul 5 2021 13:04:38) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.16, Copyright (c), by Zend Technologies
Pada saat dibuat, saya menggunakan PHP versi 7.4.16 dimana versi sudah tersedia saat XAMPP diinstall.
2. Install Composer
Untuk cara install Composer, silahkan menuju halaman resminya dis. Atau bisa juga menggunakan command berikut pada terminal:
sudo apt install composer
Setelah instalasi selesai, silahkan cek pada terminal dengan perintah “composer -V” sebagai berikut:
neon@pop-os:~$ composer -V Composer 2.0.9 2021-01-27 16:09:27
Dari hasil terminal tersebut, dilihat saya menggunakan composer versi 2.0.9.
3. Install Laravel
Setelah PHP dan Composer selesai di install. Mari kita buat projek kita untuk pertama kalinya. Jadi, ceritanya sekarang kita mau buat projek laravel dengan nama projek adalah “coba_laravel” dan disimpan kedalam sebuah folder yang namanya “Aplication“.
Folder Aplication saya taruh kedalam folder /home/Document sebagaimana yang ditunjukkan pada gambar berikut:
Setelah folder Application dibuat, sekarang buka terminal dan arahkan ke folder tersebut. Perintah yang digunakan adalah:
cd Documents/Application/
Sekarang, masih didalam terminal, gunakan perintah berikut untuk instal laravel nya:
composer create-project laravel/laravel coba-laravel
Jika ada Error :Â Your requirements could not be resolved to an installable set of packages.Â
require ext-dom * -> it is missing from your system. Install or enable PHP’s dom extension.
Cara perbaikinya adalah dengan cara install PHP-XML. Adapun cara instlalnya adalah buka terminal, gunakan command berikut:
sudo apt-get install php-xml
Lalu sekarang ulangi langkah install laravel:
composer create-project laravel/laravel coba-laravel
Ini membutuhkan koneksi internet dan waktu installnya relatif lebih lama. Mohon ditunggu hingga selesai. Jika sudah proses download dan instalasinya, anda akan mendapatkan tulisan seperti :
neon@pop-os:~/Documents/Application$ composer create-project laravel/laravel coba-laravel Creating a "laravel/laravel" project at "./coba-laravel" Installing laravel/laravel (v8.5.22) - Installing laravel/laravel (v8.5.22): Extracting archive Created project in /home/neon/Documents/Application/coba-laravel > @php -r "file_exists('.env') || copy('.env.example', '.env');" Loading composer repositories with package information Updating dependencies Lock file operations: 105 installs, 0 updates, 0 removals - Locking asm89/stack-cors (v2.0.3) - Locking brick/math (0.9.2) - Locking doctrine/inflector (2.0.3) - Locking doctrine/instantiator (1.4.0) - Locking doctrine/lexer (1.2.1) - Locking dragonmantank/cron-expression (v3.1.0) - Locking egulias/email-validator (2.1.25) - Locking facade/flare-client-php (1.8.1) - Locking facade/ignition (2.11.2) - Locking facade/ignition-contracts (1.0.2) - Locking fakerphp/faker (v1.15.0) - Locking fideloper/proxy (4.4.1) - Locking filp/whoops (2.14.0) - Locking fruitcake/laravel-cors (v2.0.4) - Locking graham-campbell/result-type (v1.0.1) - Locking guzzlehttp/guzzle (7.3.0) - Locking guzzlehttp/promises (1.4.1) - Locking guzzlehttp/psr7 (2.0.0) - Locking hamcrest/hamcrest-php (v2.0.1) - Locking laravel/framework (v8.51.0) - Locking laravel/sail (v1.8.6) - Locking laravel/tinker (v2.6.1) - Locking league/commonmark (1.6.6) - Locking league/flysystem (1.1.4) - Locking league/mime-type-detection (1.7.0) - Locking mockery/mockery (1.4.3) - Locking monolog/monolog (2.3.1) - Locking myclabs/deep-copy (1.10.2) - Locking nesbot/carbon (2.50.0) - Locking nikic/php-parser (v4.12.0) - Locking nunomaduro/collision (v5.5.0) - Locking opis/closure (3.6.2) - Locking phar-io/manifest (2.0.3) - Locking phar-io/version (3.1.0) - Locking phpdocumentor/reflection-common (2.2.0) - Locking phpdocumentor/reflection-docblock (5.2.2) - Locking phpdocumentor/type-resolver (1.4.0) - Locking phpoption/phpoption (1.7.5) - Locking phpspec/prophecy (1.13.0) - Locking phpunit/php-code-coverage (9.2.6) - Locking phpunit/php-file-iterator (3.0.5) - Locking phpunit/php-invoker (3.1.1) - Locking phpunit/php-text-template (2.0.4) - Locking phpunit/php-timer (5.0.3) - Locking phpunit/phpunit (9.5.7) - Locking psr/container (1.1.1) - Locking psr/event-dispatcher (1.0.0) - Locking psr/http-client (1.0.1) - Locking psr/http-factory (1.0.1) - Locking psr/http-message (1.0.1) - Locking psr/log (1.1.4) - Locking psr/simple-cache (1.0.1) - Locking psy/psysh (v0.10.8) - Locking ralouphie/getallheaders (3.0.3) - Locking ramsey/collection (1.1.3) - Locking ramsey/uuid (4.1.1) - Locking sebastian/cli-parser (1.0.1) - Locking sebastian/code-unit (1.0.8) - Locking sebastian/code-unit-reverse-lookup (2.0.3) - Locking sebastian/comparator (4.0.6) - Locking sebastian/complexity (2.0.2) - Locking sebastian/diff (4.0.4) - Locking sebastian/environment (5.1.3) - Locking sebastian/exporter (4.0.3) - Locking sebastian/global-state (5.0.3) - Locking sebastian/lines-of-code (1.0.3) - Locking sebastian/object-enumerator (4.0.4) - Locking sebastian/object-reflector (2.0.4) - Locking sebastian/recursion-context (4.0.4) - Locking sebastian/resource-operations (3.0.3) - Locking sebastian/type (2.3.4) - Locking sebastian/version (3.0.2) - Locking swiftmailer/swiftmailer (v6.2.7) - Locking symfony/console (v5.3.2) - Locking symfony/css-selector (v5.3.0) - Locking symfony/deprecation-contracts (v2.4.0) - Locking symfony/error-handler (v5.3.3) - Locking symfony/event-dispatcher (v5.3.0) - Locking symfony/event-dispatcher-contracts (v2.4.0) - Locking symfony/finder (v5.3.0) - Locking symfony/http-client-contracts (v2.4.0) - Locking symfony/http-foundation (v5.3.3) - Locking symfony/http-kernel (v5.3.3) - Locking symfony/mime (v5.3.2) - Locking symfony/polyfill-ctype (v1.23.0) - Locking symfony/polyfill-iconv (v1.23.0) - Locking symfony/polyfill-intl-grapheme (v1.23.0) - Locking symfony/polyfill-intl-idn (v1.23.0) - Locking symfony/polyfill-intl-normalizer (v1.23.0) - Locking symfony/polyfill-mbstring (v1.23.0) - Locking symfony/polyfill-php72 (v1.23.0) - Locking symfony/polyfill-php73 (v1.23.0) - Locking symfony/polyfill-php80 (v1.23.0) - Locking symfony/process (v5.3.2) - Locking symfony/routing (v5.3.0) - Locking symfony/service-contracts (v2.4.0) - Locking symfony/string (v5.3.3) - Locking symfony/translation (v5.3.3) - Locking symfony/translation-contracts (v2.4.0) - Locking symfony/var-dumper (v5.3.3) - Locking theseer/tokenizer (1.2.0) - Locking tijsverkoyen/css-to-inline-styles (2.2.3) - Locking vlucas/phpdotenv (v5.3.0) - Locking voku/portable-ascii (1.5.6) - Locking webmozart/assert (1.10.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 105 installs, 0 updates, 0 removals - Installing doctrine/inflector (2.0.3): Extracting archive - Installing doctrine/lexer (1.2.1): Extracting archive - Installing symfony/polyfill-ctype (v1.23.0): Extracting archive - Installing webmozart/assert (1.10.0): Extracting archive - Installing dragonmantank/cron-expression (v3.1.0): Extracting archive - Installing symfony/polyfill-php80 (v1.23.0): Extracting archive - Installing symfony/polyfill-mbstring (v1.23.0): Extracting archive - Installing symfony/var-dumper (v5.3.3): Extracting archive - Installing symfony/polyfill-intl-normalizer (v1.23.0): Extracting archive - Installing symfony/polyfill-intl-grapheme (v1.23.0): Extracting archive - Installing symfony/string (v5.3.3): Extracting archive - Installing psr/container (1.1.1): Extracting archive - Installing symfony/service-contracts (v2.4.0): Extracting archive - Installing symfony/polyfill-php73 (v1.23.0): Extracting archive - Installing symfony/deprecation-contracts (v2.4.0): Extracting archive - Installing symfony/console (v5.3.2): Extracting archive - Installing psr/log (1.1.4): Extracting archive - Installing monolog/monolog (2.3.1): Extracting archive - Installing voku/portable-ascii (1.5.6): Extracting archive - Installing phpoption/phpoption (1.7.5): Extracting archive - Installing graham-campbell/result-type (v1.0.1): Extracting archive - Installing vlucas/phpdotenv (v5.3.0): Extracting archive - Installing symfony/css-selector (v5.3.0): Extracting archive - Installing tijsverkoyen/css-to-inline-styles (2.2.3): Extracting archive - Installing symfony/routing (v5.3.0): Extracting archive - Installing symfony/process (v5.3.2): Extracting archive - Installing symfony/polyfill-php72 (v1.23.0): Extracting archive - Installing symfony/polyfill-intl-idn (v1.23.0): Extracting archive - Installing symfony/mime (v5.3.2): Extracting archive - Installing symfony/http-foundation (v5.3.3): Extracting archive - Installing symfony/http-client-contracts (v2.4.0): Extracting archive - Installing psr/event-dispatcher (1.0.0): Extracting archive - Installing symfony/event-dispatcher-contracts (v2.4.0): Extracting archive - Installing symfony/event-dispatcher (v5.3.0): Extracting archive - Installing symfony/error-handler (v5.3.3): Extracting archive - Installing symfony/http-kernel (v5.3.3): Extracting archive - Installing symfony/finder (v5.3.0): Extracting archive - Installing symfony/polyfill-iconv (v1.23.0): Extracting archive - Installing egulias/email-validator (2.1.25): Extracting archive - Installing swiftmailer/swiftmailer (v6.2.7): Extracting archive - Installing ramsey/collection (1.1.3): Extracting archive - Installing brick/math (0.9.2): Extracting archive - Installing ramsey/uuid (4.1.1): Extracting archive - Installing psr/simple-cache (1.0.1): Extracting archive - Installing opis/closure (3.6.2): Extracting archive - Installing symfony/translation-contracts (v2.4.0): Extracting archive - Installing symfony/translation (v5.3.3): Extracting archive - Installing nesbot/carbon (2.50.0): Extracting archive - Installing league/mime-type-detection (1.7.0): Extracting archive - Installing league/flysystem (1.1.4): Extracting archive - Installing league/commonmark (1.6.6): Extracting archive - Installing laravel/framework (v8.51.0): Extracting archive - Installing facade/ignition-contracts (1.0.2): Extracting archive - Installing facade/flare-client-php (1.8.1): Extracting archive - Installing facade/ignition (2.11.2): Extracting archive - Installing fakerphp/faker (v1.15.0): Extracting archive - Installing fideloper/proxy (4.4.1): Extracting archive - Installing asm89/stack-cors (v2.0.3): Extracting archive - Installing fruitcake/laravel-cors (v2.0.4): Extracting archive - Installing psr/http-message (1.0.1): Extracting archive - Installing psr/http-client (1.0.1): Extracting archive - Installing ralouphie/getallheaders (3.0.3): Extracting archive - Installing psr/http-factory (1.0.1): Extracting archive - Installing guzzlehttp/psr7 (2.0.0): Extracting archive - Installing guzzlehttp/promises (1.4.1): Extracting archive - Installing guzzlehttp/guzzle (7.3.0): Extracting archive - Installing laravel/sail (v1.8.6): Extracting archive - Installing nikic/php-parser (v4.12.0): Extracting archive - Installing psy/psysh (v0.10.8): Extracting archive - Installing laravel/tinker (v2.6.1): Extracting archive - Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive - Installing mockery/mockery (1.4.3): Extracting archive - Installing filp/whoops (2.14.0): Extracting archive - Installing nunomaduro/collision (v5.5.0): Extracting archive - Installing phpdocumentor/reflection-common (2.2.0): Extracting archive - Installing phpdocumentor/type-resolver (1.4.0): Extracting archive - Installing phpdocumentor/reflection-docblock (5.2.2): Extracting archive - Installing sebastian/version (3.0.2): Extracting archive - Installing sebastian/type (2.3.4): Extracting archive - Installing sebastian/resource-operations (3.0.3): Extracting archive - Installing sebastian/recursion-context (4.0.4): Extracting archive - Installing sebastian/object-reflector (2.0.4): Extracting archive - Installing sebastian/object-enumerator (4.0.4): Extracting archive - Installing sebastian/global-state (5.0.3): Extracting archive - Installing sebastian/exporter (4.0.3): Extracting archive - Installing sebastian/environment (5.1.3): Extracting archive - Installing sebastian/diff (4.0.4): Extracting archive - Installing sebastian/comparator (4.0.6): Extracting archive - Installing sebastian/code-unit (1.0.8): Extracting archive - Installing sebastian/cli-parser (1.0.1): Extracting archive - Installing phpunit/php-timer (5.0.3): Extracting archive - Installing phpunit/php-text-template (2.0.4): Extracting archive - Installing phpunit/php-invoker (3.1.1): Extracting archive - Installing phpunit/php-file-iterator (3.0.5): Extracting archive - Installing theseer/tokenizer (1.2.0): Extracting archive - Installing sebastian/lines-of-code (1.0.3): Extracting archive - Installing sebastian/complexity (2.0.2): Extracting archive - Installing sebastian/code-unit-reverse-lookup (2.0.3): Extracting archive - Installing phpunit/php-code-coverage (9.2.6): Extracting archive - Installing doctrine/instantiator (1.4.0): Extracting archive - Installing phpspec/prophecy (1.13.0): Extracting archive - Installing phar-io/version (3.1.0): Extracting archive - Installing phar-io/manifest (2.0.3): Extracting archive - Installing myclabs/deep-copy (1.10.2): Extracting archive - Installing phpunit/phpunit (9.5.7): Extracting archive 76 package suggestions were added by new dependencies, use `composer suggest` to see details. Package sebastian/resource-operations is abandoned, you should avoid using it. No replacement was suggested. Generating optimized autoload files > IlluminateFoundationComposerScripts::postAutoloadDump > @php artisan package:discover --ansi Discovered Package: facade/ignition Discovered Package: fideloper/proxy Discovered Package: fruitcake/laravel-cors Discovered Package: laravel/sail Discovered Package: laravel/tinker Discovered Package: nesbot/carbon Discovered Package: nunomaduro/collision Package manifest generated successfully. 74 packages you are using are looking for funding. Use the `composer fund` command to find out more! > @php artisan key:generate --ansi Application key set successfully.
Application key set successfully artinya laravel telah diinstall. Untuk cek nya silahkan buka folder Appliation > coba-laravel seperti pada gambar berikut:
4. Testing Laravel
Akan ada banyak file didalam folder coba-laravel. Sekarang, masih di terminal, kita coba masuk kedalam folder coba-laravel dengan perintah:
cd coba-laravel
Mari kitat tes laravel apakah sudah bisa berjalan di web browser atau tidak. Kita gunakan fitur dari Laravel yaitu artisan untuk membuat alamat serve nya. Perintah yang digunakan adalah:
php artisan serve
maka fitur artisan akan membuat secara otomatis alamat yang dapat kita akses, sebagai mana yang ditunjukkan berikut.
neon@pop-os:~/Documents/Application/coba-laravel$ php artisan serve Starting Laravel development server: http://127.0.0.1:8000 [Fri Jul 23 07:38:00 2021] PHP 7.4.16 Development Server (http://127.0.0.1:8000) started
Alamatnya adalah http://127.0.0.1:8000. Copy alamat tersebut, lalu buka browser dan paste dan “Enter”. Jika tampilannya adalah seperti berikut, maka laravel sudah sukses terinstall di laptop kita.
Selesai. Laravel siap untuk kita gunakan. Semoga bermanfaat.