Report this

What is the reason for this report?

How To Install Laravel Spark from scratch on LAMP stack

Posted on April 9, 2021

I am able to setup my LAMP inside droplet but not able to find the docs to setup Laravel Spark. Can anyone guide me???



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

I would usually stick to LEMP, there is a nice community tool that does all of the server setup and Laravel installation for you with a couple of commands:

https://www.digitalocean.com/community/tools/larasail

It is very well documented and it pulls up the latest Laravel version for you.

Once you have the Laravel application installed, you can follow the steps here on how to add the Laravel Spark Package and include the API Key:

https://spark.laravel.com/docs/1.x/installation.html

Alternatively, if you prefer LAMP, you could install Laravel by following the steps here:

https://devdojo.com/bobbyiliev/laravel-app-on-digital-ocean-ubuntu-1904-droplet-step-by-step-guide

Hope that this helps. Regards, Bobby

Setting up Laravel Spark on a LAMP stack involves several steps. Laravel Spark is a premium package that adds subscription billing features to your Laravel application. Here’s how you can set it up from scratch on your LAMP stack:


Step 1: Prerequisites

Before installing Laravel Spark, ensure the following are installed on your LAMP stack:

  1. PHP (8.0 or later preferred):

    bash Copy code

    php -v

    Ensure extensions like pdo, openssl, mbstring, tokenizer, json, xml, and bcmath are installed.

    Install missing extensions (if necessary):

    bash Copy code

    sudo apt install php-mbstring php-xml php-bcmath php-curl

  2. Composer: Laravel Spark requires Composer for managing dependencies.

    bash Copy code

    composer --version

    Install Composer if not already installed:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
  1. MySQL/MariaDB: Ensure your database is set up and a database is created for Laravel Spark.

  2. Laravel Installer: Install the Laravel installer globally (optional but helpful):

composer global require laravel/installer
  1. Node.js and NPM: Install Node.js and npm for managing frontend assets:
sudo apt install nodejs npm
  1. Enable Required Apache Modules: Enable the necessary modules:
sudo a2enmod rewrite 
sudo systemctl restart apache2

Step 2: Purchase and Download Laravel Spark

Laravel Spark is a commercial package available at Laravel Spark. Purchase a license and download the Spark installer.


Step 3: Create a New Laravel Application

Create a new Laravel project for Spark:

laravel new my-spark-app
# OR using Composer
composer create-project --prefer-dist laravel/laravel my-spark-app

Navigate to the project directory:

cd my-spark-app

Step 4: Install Laravel Spark

Install Laravel Spark using the Spark installer or Composer:

Using Spark Installer:

Download and install Spark into your Laravel app:

php artisan spark:install

Using Composer:

Alternatively, if you’ve been provided a Composer package for Spark:

composer require laravel/spark-audio
# Replace "audio" with your purchased edition if applicable.

Run Spark’s installation script:

php artisan spark:install

Step 5: Configure Environment

Update the .env file to set up the database and environment:

APP_NAME="Laravel Spark App"
APP_ENV=local
APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
APP_DEBUG=true
APP_URL=http://yourdomain.com

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=spark_database
DB_USERNAME=spark_user
DB_PASSWORD=spark_password

Step 6: Run Migrations

Migrate the database to set up Spark’s tables:

php artisan migrate

Step 7: Install Frontend Dependencies

Install Node.js dependencies and build assets:

npm install npm run dev

For production:

npm run prod

Step 8: Set Permissions

Ensure the storage and bootstrap cache directories are writable:

sudo chown -R www-data:www-data /path/to/my-spark-app
sudo chmod -R 775 /path/to/my-spark-app/storage /path/to/my-spark-app/bootstrap/cache

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.