In this article, you will learn how to Deploy/ Upload your Laravel Project on cPanel. If you make your project with Vue3, Inertiajs, vite, and Tailwindcss you can easily build your project development to production.
Server Requirements for Laravel 11
The Laravel framework has a few system requirements. You should ensure that your web server has the following minimum PHP version 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 on Cpanel
First, we need to build vue.js, tailwindcss, assets with npm. Just open your project with your code editor and run these commands.
- Storage folder making public:
To make the storage folder accessible from the web, you should create a symbolic link from public/storage. Run the following command in your project:
- Build Your Vue.js Assets:
Run the following command in your project’s root directory to build your Vue 3 assets:
- Optimize Laravel:
Run the following command to optimize Laravel for production:
- Compress Your Project:
Compress your project files into a.zip
file except node_mouldes folder. - Export your Database .sql file from phpMyAdmin. We will import it from our cPanel.
2. Upload Your Project to cPanel
- Upload the .zip File:
Log in to your cPanel account, go to the File Manager, and upload the.zip
file to your desired directory (usuallypublic_html
or a subdirectory within it). Then Extract the zip file. - Extract the .zip File:
In the public_html folder you will get all Laravel files like that.
- Then open the public folder inside the public_html or your root folder.
- Move the content of public directory into public_html(but don’t delete the empty public folder which is inside the public_html folder)
3. Folder Permissions
- Ensure that the
storage
andbootstrap/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 in your extracted project and update the database credentials and any other necessary environment variables to match your cPanel setup.
5. Set Up the Database
- Create a New Database:
In cPanel, go to MySQL Databases and create a new database, user, and password. - Import the Database:
Use phpMyAdmin in cPanel to import your database file (.sql
) into the newly created database.
- Update
.env
File:
Update your.env
file with the database name, username, and password.
6. Update the index.php
We need to update index.php file inside the public_html directory like this:
See inside the index.php file
7. Set Up Apache .htaccess
- Create .htaccess File:
Ensure that the.htaccess
file in yourpublic_html
or root directory contains the following to redirect all requests toindex.php
:
8. Vite manifest not found error
Now if you type the address of your site in browser you’ll get vite manifest not found.
Just copy the build folder from public_html directory to public folder (you unzipped there) just keep manifest.json file
And finally browse your domain and see the magic! thanks!