Deployment
cPanel Installation
Guide for deploying the SaasCart API to cPanel with subdomain setup and database configuration
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 frontendapi.your-domain.com
for the Laravel APIadmin.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 theapi.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
, andDB_PASSWORD
for later.
5. Update the Environment File
- Open the
.env
file in theapi.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 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:
9. Set Up the Database in phpMyAdmin
Before running the SaasCart installation command, set up your database using phpMyAdmin.
- Open phpMyAdmin: Go to http://your-domain.com/phpmyadmin.
- Select Your Database: Choose the database you created in Step 4 (e.g.,
saascart_db
). - 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.
- For a pre-configured setup, choose the
If tables already exist in the database, this process will overwrite them, so proceed with caution if data is present.
10. Link Storage Folder to Public Folder
Run the following command to link storage and display images correctly:
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:
- 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.