It is possible and very easy to deploy and run Laravel application on shared hosting server
- create a new directory named ‘laravel’ (or any name you want to use) inside public_html (public folder) ie. public_html/laravel.
- Inside your Laravel project you have a public directory. Copy the content of that public directory into the public_html/laravel directory you created on your host.
- Except the public folder, copy every folder and file (ex. app folder, .env file, …) from your Laravel project into the public_html/laravel folder on your host.
- copy all files and folder of public directory of laravel application to root ie. public_html.
- In the public_html directory, open the index.php file in your preferred text editor, and then modify it as follows:
Locate the following line:
require DIR.’/../vendor/autoload.php’;
Modify the path to include the directory where Laravel is installed. For example, if Laravel is in the project directory, you would change the line as follows:
require DIR.’/../laravel/vendor/autoload.php’
Locate the following line:
require DIR.’/../bootstrap/app.php’;
Modify the path to include the directory where Laravel is installed. For example, if Laravel is in the project directory, you would change the line as follows:
require DIR.’/../laravel/bootstrap/app.php’
6. Config your .env file
7. update database details in config file (config/database.php)
8. Execute the artisan commands mentioned below:
- 1. composer install
- 2. php artisan key:generate
- 3. php artisan cache:clear
- 4. php artisan migrate
- 5. chmod -R 775 storage/
- 6. composer dump-autoload
- 7. sudo chown -R apache storage
- 8. sudo chown -R apache bootstrap/cache
- 9. chmod -R 775 storage
- 10. chmod -R 775 bootstrap/cache