Skip to main content

Posts

Showing posts with the label Shared Hosting

How to Use Laravel with Subdomains on cPanel

How to Use Laravel with Subdomains on cPanel Laravel supports subdomain routing out of the box, but configuring it on cPanel can be confusing for new developers. Whether you're building a multi-tenant app or organizing admin panels, here's how to properly set up subdomains with Laravel on shared hosting. 🛠️ Prerequisites Laravel project deployed on a cPanel-hosted domain Access to the Subdomains section in cPanel Basic knowledge of Laravel routing 🌐 Step 1: Create Subdomains in cPanel Log in to your cPanel account. Go to Subdomains under the Domains section. Create a subdomain like admin.example.com . Point the document root to your Laravel project’s public/ directory. For example: /home/your-user/your-laravel-project/public Repeat for each subdomain (e.g. user.example.com ). 🧭 Step 2: Define Subdomain Routes in Laravel In your Larav...

Laravel Queue Setup on Shared Hosting

Laravel Queue Setup on Shared Hosting Laravel queues allow you to defer time-consuming tasks like sending emails or processing uploads. But on shared hosting, there’s no supervisor tool like on VPS. Don’t worry — with cPanel and cron, you can still run queues efficiently. 🛠️ Prerequisites Laravel project already deployed on shared hosting (via cPanel) Queueable jobs created using php artisan make:job Basic understanding of Laravel's queue system ⚙️ Step 1: Configure Your Laravel Queue By default, Laravel uses the sync driver, which runs jobs immediately. Update the driver to database (or Redis, if supported): QUEUE_CONNECTION=database In your .env file, set the queue driver. If using database , run: php artisan queue:table && php artisan migrate This creates the necessary table for storing queued jobs. 📍 Step 2: Locate the Laravel Project Path Find your full La...

How to Schedule Cron Jobs in Laravel on cPanel

How to Schedule Cron Jobs in Laravel on cPanel Laravel's task scheduler makes it easy to automate repetitive tasks like sending emails or cleaning up logs. On shared hosting with cPanel , you can trigger Laravel's scheduler using cron jobs. In this post, I’ll guide you through setting it up step by step. 🛠️ Prerequisites Laravel project already deployed on cPanel Access to cPanel's Cron Jobs section Basic knowledge of Laravel commands 📄 Step 1: Create Your Laravel Scheduled Tasks Define your scheduled tasks inside the app/Console/Kernel.php file under the schedule() method: protected function schedule(Schedule $schedule) { $schedule->command('emails:send')->daily(); $schedule->command('backup:run')->weekly(); } You can schedule Artisan commands, closures, queue jobs, and more. 📍 Step 2: Locate the Laravel Project Path Find the absolute...

How to Upload a PHP/Laravel Project on cPanel

How to Upload a PHP/Laravel Project on cPanel Deploying a Laravel project on cPanel can seem tricky, especially if you're coming from a local development environment. But don’t worry — in this post, I’ll walk you through every step to make your Laravel application live on shared hosting via cPanel. 🛠️ Prerequisites Laravel project ready on your local machine cPanel access with PHP 8.0+ support Access to MySQL via phpMyAdmin 📁 Step 1: Prepare Your Laravel Project Run composer install --optimize-autoloader --no-dev to install only production dependencies. Run php artisan config:cache and php artisan route:cache . Zip the entire Laravel project. 📤 Step 2: Upload Project to cPanel Login to your cPanel account. Open File Manager . Navigate to the public_html directory. Upload your Laravel zip file and extract it. 🔄 Step 3: Move Folde...