Getting Started with SaasCart API Deployment

1. Prepare Files for Upload

  • Open the saascart-api directory that you downloaded from SaasCart.
  • Zip all files and folders in the saascart-api folder, creating a .zip file for upload.

2. Create Subdomains

  • Log in to your cPanel account and go to Domains > Subdomains.
  • Create separate subdomains:
    • store.your-domain.com for the Next.js frontend
    • api.your-domain.com for the Laravel API
    • admin.your-domain.com for the Next.js backend

3. Upload and Extract the Zip File

  • Upload the saascart-api.zip file to the File Manager in the api.your-domain.com directory.
  • Once uploaded, click Go Back and extract the .zip file.

4. Create a MySQL Database

  • In cPanel, go to MySQL Database Wizard to create a new database.
  • Set up a new database user and assign the user to the database with all necessary permissions.
  • Take note of the DB_DATABASE, DB_USERNAME, and DB_PASSWORD for later.

5. Update the Environment File

  • Open the .env file in the api.your-domain.com directory.
  • Update the following values:
    • APP_URL=https://api.your-domain.com
    • APP_ENV=production
    • DB_DATABASE=your_db_name
    • DB_USERNAME=your_db_username
    • DB_PASSWORD=your_db_password
Ensure APP_URL is correct to enable file uploads and image display.

6. Open cPanel Terminal

  • Search for Terminal in cPanel, or use SSH access if terminal access is unavailable in cPanel.
  • Navigate to the Laravel project root directory.

7. Install Required Dependencies

Run the following command in the api.your-domain.com directory:

composer install
Composer must be using PHP 8.2. If your Composer version is lower, run the command: /usr/local/bin/ea-php82 /opt/cpanel/composer/bin/composer install

8. Generate Laravel APP Key

Generate the Laravel app key by running:

php artisan key:generate

9. Set Up the Database in phpMyAdmin

Before running the SaasCart installation command, set up your database using phpMyAdmin.

  1. Open phpMyAdmin: Go to http://your-domain.com/phpmyadmin.
  2. Select Your Database: Choose the database you created in Step 4 (e.g., saascart_db).
  3. Import Data:
    • For a pre-configured setup, choose the saascart_dummy_data.sql file to import sample data.
    • For a clean setup, select saascart_no_data.sql to import only the essential structure.
If tables already exist in the database, this process will overwrite them, so proceed with caution if data is present.

Run the following command to link storage and display images correctly:

php artisan storage:link

Congratulations

๐ŸŽ‰ SaasCart API has been successfully installed and configured on your system! Visit your website to ensure everything is working correctly.

Additional Resources

  • If youโ€™re encountering issues with loading the API, you may need to verify your .htaccess configuration. Ensure your .htaccess file includes the following rules:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

  • Laravel Official Documentation: Refer to Laravel Documentation for deployment best practices.
  • cPanel Documentation: Check cPanel Documentation for server management tips.
  • Hosting Provider Guides: Your hosting provider may offer specific Laravel deployment documentation.