Deploying to Shared Hosting
A step-by-step guide for a typical cPanel-based shared host (Hostinger, Namecheap, GoDaddy, Bluehost, etc.). Steps are the same in spirit on other panels (Plesk, DirectAdmin) β just under different menu names.
1. Requirements checklist
- PHP 8.2+ with extensions:
openssl,pdo_mysql,mbstring,tokenizer,xml,ctype,json,bcmath,fileinfo,curl. Addgdif you want the image watermark feature to work. - A MySQL/MariaDB database (cPanel → MySQL Databases to create one, plus a user with all privileges on it).
- Composer β ideally available in your host's terminal; if not, you'll run it on your own machine instead (covered below).
- Your domain or subdomain already pointed at the hosting account.
2. Prepare the app on your own machine first
- Run
composer install --no-dev --optimize-autoloaderlocally β this downloadsvendor/so you don't need Composer on the host at all. - Copy
.env.exampleto.envand fill in production values (you'll fix the DB credentials again once they exist on the host β see step 3). - Generate an app key locally so you don't need SSH for it: run
php artisan key:generate, or generate one offline withopenssl rand -base64 32and paste it into.envasAPP_KEY=base64:.... - Zip the whole project folder (this now includes
vendor/) β one zip upload is far faster than uploading thousands of individual files over FTP.
3. Create the database
In cPanel: MySQL Databases → create a database and a user, add the user to the database with All Privileges. Note the full database name, username, and password β shared hosts usually prefix them with your account name, e.g. cpaneluser_dbname.
4. Upload and place the files
The key rule: only the contents of the public/ folder should be web-accessible β everything else (app/, .env, etc.) must sit outside the public web root, or anyone could potentially browse to your .env file.
Option A β your host lets you set a custom document root (most cPanel accounts, via "Domains")
- Upload the whole project to a folder outside
public_html, e.g./home/youruser/preciseclassify. - Extract the zip there via cPanel File Manager.
- Go to cPanel → Domains, find your domain, and set its Document Root to
preciseclassify/public.
Option B β you can only serve from public_html directly (no document-root control)
- Upload the whole project to a folder outside
public_html, e.g./home/youruser/preciseclassify(same as Option A). - Copy (not move) everything inside
preciseclassify/public/intopublic_html/. - Edit the
index.phpyou just copied intopublic_html/: it has two lines requiringvendor/autoload.phpandbootstrap/app.phpβ change__DIR__.'/../vendor/autoload.php'to__DIR__.'/../preciseclassify/vendor/autoload.php', and the same pattern for the bootstrap line, so they point at the app folder that now sits one level up frompublic_html.
5. Configure .env on the server
Edit .env (via File Manager's code editor, or SSH) with your real values:
APP_ENV=production APP_DEBUG=false APP_URL=https://yourdomain.com DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_DATABASE=cpaneluser_dbname DB_USERNAME=cpaneluser_dbuser DB_PASSWORD=your-db-password
Always set APP_DEBUG=false in production β leaving it on exposes stack traces (including config values) to visitors.
6. Run migrations & seed the database
With SSH access
SSH in, cd into the app folder, then run:
php artisan migrate --seed php artisan storage:link php artisan config:cache php artisan route:cache
Without SSH access
Run php artisan migrate --seed against a MySQL database on your own machine (or a free local install), then use mysqldump to export the schema and seeded rows, and import that .sql file through cPanel's phpMyAdmin into the host's database. This gets you the same tables and starter data (default currencies, categories, admin user) without ever needing a terminal on the host.
7. Storage symlink & file permissions
php artisan storage:link creates a symlink so uploaded listing photos are web-accessible. Some shared hosts disable PHP's symlink() function for security β if the command errors or does nothing:
- Check cPanel's MultiPHP INI Editor to see if
symlinkis in the disabled-functions list; ask support to remove it if so. - If it truly can't be enabled, as a fallback you can point
FILESYSTEM_DISKat a folder directly underpublic/instead of using the symlink, and adjust the upload paths inListingController/VendorProfileControlleraccordingly β more work, so it's worth pushing your host to allowsymlink()first.
Make sure storage/ and bootstrap/cache/ are writable by the web server β 755 is usually enough on shared hosts; only go to 775/777 if you get permission-denied errors in storage/logs/laravel.log.
8. Set up the cron job (needed for expiry notifications)
cPanel → Cron Jobs → add a job that runs every minute:
* * * * * /usr/local/bin/php /home/youruser/preciseclassify/artisan schedule:run >> /dev/null 2>&1
The exact PHP path varies by host β check cPanel's MultiPHP Manager or ask support for the CLI PHP binary path if php alone doesn't work. This single cron entry is all Laravel's scheduler needs; it internally runs listings:notify-expiring daily.
9. Queues & real-time chat
By default nothing here needs a persistent background worker β notifications and jobs run synchronously, and chat works via polling. Shared hosts generally don't allow long-running processes, so:
- Leave
QUEUE_CONNECTION=sync(the default) β no queue worker to babysit. - Skip self-hosting Reverb (it needs a persistent WebSocket process shared hosts won't run). If you want real-time chat instead of 4-second polling, use a managed service like Pusher instead β it only needs outbound HTTPS calls, which works fine from shared hosting.
10. HTTPS and final checks
- cPanel → SSL/TLS Status → run AutoSSL (free Let's Encrypt certificate) for your domain.
- Confirm
APP_URLin.envuseshttps://. - Visit your domain, confirm the homepage loads, register a test account, post a test listing, and check
/sitemap.xmlrenders.
Troubleshooting
storage/logs/laravel.log first β it almost always names the real error. Common causes: .env missing/misconfigured, storage/ or bootstrap/cache/ not writable, or APP_KEY not set.composer install was never run (re-upload with vendor/ included, per step 2), or β if you used Option B in step 4 β the path you edited into public_html/index.php doesn't actually match where the app folder lives.php artisan storage:link actually created the symlink (see step 7), and that the gd PHP extension is enabled in MultiPHP Manager if you want watermarking specifically.memory_limit at 128M and max_execution_time at 30s, which can be tight for larger image uploads. Raise both in MultiPHP INI Editor if your plan allows it, or ask support to bump them for your account.