- A Linux distribution (e.g., Ubuntu)
- Docker
- Docker Compose
-
Update Your Package List:
sudo apt update
-
Install Docker:
sudo apt install docker.io
-
Start and Enable Docker:
sudo systemctl start docker sudo systemctl enable docker
-
Verify Docker Installation:
docker --version
-
Download Docker Compose:
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
-
Apply Executable Permissions:
sudo chmod +x /usr/local/bin/docker-compose
-
Verify Docker Compose Installation:
docker-compose --version
-
Install Composer:
sudo apt update sudo apt install curl php-cli php-mbstring git unzip curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer
-
Create a New Laravel Project:
composer create-project laravel/laravel example-app cd example-app
-
Install Laravel Sail:
composer require laravel/sail --dev
-
Publish Sail's Docker Configuration:
php artisan sail:install
-
Start Docker Containers:
./vendor/bin/sail up
-
Copy Environment File:
cp .env.example .env
-
Generate Application Key:
./vendor/bin/sail artisan key:generate
-
Update Environment Variables: Update the
.env
file with the necessary database configuration if needed.
- Open Browser:
Open your browser and navigate to
http://localhost
. You should see the Laravel welcome page.
-
Stop Docker Containers:
./vendor/bin/sail down
-
Run Artisan Commands: To run other Artisan commands, prefix them with Sail:
./vendor/bin/sail artisan migrate
If you encounter any issues, ensure:
- Docker is running.
- Docker Compose is properly installed.
- The Linux environment is properly configured.
By following these steps, you should have a fully functional Laravel Sail and Docker environment set up on your Linux machine.