How to Upload Laravel, Vue, InertiaJs, Tailwind Project in cPanel

Sep 08, 2024 10:23 PM - 4 months ago 147568

In this article, you will learn how to Deploy/ Upload your Laravel Project connected cPanel. If you make your task with Vue3, Inertiajs, vite, and Tailwindcss you tin easy build your task improvement to production.

Server Requirements for Laravel 11

The Laravel model has a fewer strategy requirements. You should guarantee that your web server has the pursuing minimum PHP type and extensions:

  • PHP >= 8.2
  • Ctype PHP Extension
  • cURL PHP Extension
  • DOM PHP Extension
  • Fileinfo PHP Extension
  • Filter PHP Extension
  • Hash PHP Extension
  • Mbstring PHP Extension
  • OpenSSL PHP Extension
  • PCRE PHP Extension
  • PDO PHP Extension
  • Session PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

1. Ready Laravel Project to Upload connected Cpanel

First, we request to build vue.js, tailwindcss, assets pinch npm. Just unfastened your task pinch your codification editor and tally these commands.

 

  • Storage files making public:
    To make the storage folder accessible from the web, you should create a symbolic nexus from public/storage. Run the pursuing bid successful your project:
php artisan storage:link
  • Build Your Vue.js Assets:
    Run the pursuing bid successful your project’s guidelines directory to build your Vue 3 assets:
npm tally build
  • Optimize Laravel:
    Run the pursuing bid to optimize Laravel for production:
php artisan optimize:clear
  • Compress Your Project:
    Compress your task files into a .zip file except node_mouldes folder.
  • Export your Database .sql file from phpMyAdmin. We will import it from our cPanel.
deploy laravel inertia vue task connected cpanel

2. Upload Your Project to cPanel

  • Upload the .zip File:
    Log successful to your cPanel account, spell to the File Manager, and upload the .zip file to your desired directory (usually public_html or a subdirectory wrong it). Then Extract the zip file.
  • Extract the .zip File:
    In the public_html folder you will get each Laravel files for illustration that.
upload laravel task connected cpanel
  • Then unfastened the public folder wrong the public_html or your guidelines folder.
build laravel task for cpanel
  • Move the contented of nationalist directory into public_html(but don’t delete the quiet nationalist files which is wrong the public_html folder)

3. Folder Permissions

  • Ensure that the storage and bootstrap/cache directories are writable by the web server:
  • Storage Folder Permission
  • Cache Folder Permission

4. Configure Environment Variables

  • Edit the .env File:
    Open the .env file successful your extracted task and update the database credentials and immoderate different basal situation variables to lucifer your cPanel setup.
APP_NAME=Tech Trigger
APP_ENV=production
APP_DEBUG=false
APP_URL=https://your-domain.com

5. Set Up the Database

  • Create a New Database:
    In cPanel, spell to MySQL Databases and create a caller database, user, and password.
  • Import the Database:
    Use phpMyAdmin in cPanel to import your database record (.sql) into the recently created database.
  • Update .env File:
    Update your .env file pinch the database name, username, and password.
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=”database_name”
DB_USERNAME=”user”
DB_PASSWORD=”password”

6. Update the index.php

We request to update index.php file wrong the public_html directory for illustration this:

See wrong the index.php file

7. Set Up Apache .htaccess

  • Create .htaccess File:
    Ensure that the .htaccess file successful your public_html or guidelines directory contains the pursuing to redirect each requests to index.php:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder…
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller…
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

8. Vite manifest not recovered error

Now if you type the reside of your tract successful browser you’ll get vite manifest not found.

Just copy the build files from public_html directory to public folder (you unzipped there) conscionable keep manifest.json file

And yet browse your domain and spot the magic! thanks!

More