Uploading and deployment of Laravel application to cPanel step by step guide.
- Create new folder(laravelapp) in the root directory at the same level with public_html
- zip your project files and then upload to the laravelapp folder and unzip there except the public folder in your project
- upload your public folder files to the public_html
- change your index.php file content in the line 34 and 47 as follows:
34: require DIR.'/../laravelapp/vendor/autoload.php';
47: $app = require_once DIR.'/../laravelapp/bootstrap/app.php';
- Check all your assets files are working well if not check the path and give correct path.
- Create the database and user for it.
- Give the credentials in the .env file and also change the app_url to your domain name and app_debug as follows:
APP_DEBUG=false APP_URL=https://example.com DB_DATABASE=database DB_USERNAME=dbuser DB_PASSWORD=kH34Kf01@kd
-
Modify your filesyste.php file and check it in the repository. This file is located in your config folder of your project.
-
If you can't run the artisan commands then you can create a rout as follows and run in your browser it will run the command to create link.
Route::get("/storage-link", function () { $targetFolder = storage_path("app/public"); $linkFolder = $_SERVER['DOCUMENT_ROOT'] . '/storage';
if (!is_link($linkFolder)) { symlink($targetFolder, $linkFolder); return 'Storage linked successfully'; } else { return 'Storage link already exists'; } });
-
Now go to your browser and after the domain name write storage-link and hit enter
https://example.com/storage-link
-
Now your Storage/app/public will be linked to your public_html/Storage folder and if your images or Storage directory is giving the persmission error then you must check your permission where for the Storage the permission should be
0777
, for the sub folder0755
and for the images and files0644
should be the correct permissions to access.
Check the files in the repository for more details.
--------Done! Enjoy the show--------------