Host a Laravel project in cPanel

Posted On November 21, 2022
Host a Laravel project in cPanel

Huge amount of developers having trouble while uploading Laravel applications into a cPanel shared hosting server.

Upload Laravel in cPanel Step By Step

  1. First, you have to make a zip of your project on your computer.
  2. Then you can open your cPanel and upload that into it. All files should be in the public_html folder
  3. Once you upload and extract the files we have to make an htaccess rewrite rule.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]

If you have a database with your project you have to go to your cPanel and create a MySQL user and password also a database.

Once that is done, you have to export your database from your localhost and import it into your cPanel database.

You have to change the database details inside your env file. if you are getting can’t connect error after this you can add a single quote ‘database username’, or ‘database password’ like this in the env file. Then it will work perfectly.