SlideShare a Scribd company logo
1 of 8
Download to read offline
How to upload Laravel
Project on Shared Hosting
With cPanel?
Uploading a Laravel project to a shared hosting platform like
cPanel can be difficult. You may already have tried doing so and
failed. This is mainly because most shared hosting platforms
don’t provide an SSH terminal which is crucial to run PHP artisan
commands like; PHP artisan cache: clear, PHP artisan storage:
link, etc. And cPanel is one of them.
Enough about the problem; let us look at the solution and upload
your Laravel project step-by-step.
Step I: Remove the public from the URL
First, you’ll have to remove the public word from the URL in our
Laravel project so that you don’t need the PHP artisan command
to access your Laravel project and access it as a normal PHP
project. It is a simple task to perform; you just have to:
o Move the index.php and .htaccess files from the project
public folder to the project root directory.
o Open the index.php file and change line 24 to “require
_DIR_.‘/vendor/autoload.php’;” and line 38 to “$app =
require_once _DIR_.‘/bootstrap/app.php’;”
As the public word has been removed from the URL, we have
added the public word in the asset helper method where the CSS,
JS, or image file is linked. For Example, asset(‘css/style.css’)
will become an asset(‘public/css/style.css’)
What is FTP & How to Create an FTP Account In cPanel?
Step II: Open your database using your MySQL client, export it,
and save it to your PC.
Step III: Compress your Laravel project files into a ZIP file. If
git, node_modules folders exist in your Laravel project, be sure
not to add them in the zip file.
How to Add a New Domain To Cpanel?
Step IV: Login to your cPanel
Create a database & user. (Make sure to save the database
name, user, and password into a text file in a safe place.)
 Add New User
 Add User to Database
Step V: Go to the phpMyAdmin tab and select the database we
have created in ‘Step IV’. Now go to the import tab and import
the database file we have exported in ‘Step II’.
How To Install WordPress On VPS Hosting
Step VI: Open your File Manager in cPanel and upload the ZIP
file of your Laravel project into the public_html directory and
extract the ZIP file. The ZIP file should be uploaded and
extracted directly in the public_html folder and not inside any
subfolder.
Move an email account from one cPanel server to another
Step VII: Now update your database details into the config file
by opening the database.php file from the config folder and
updating your database name, username and password into the
database.php file. Now save the file. (Any sensitive credentials
should not be uploaded in the env file in shared hosting.)
Copy this & modify the details:
'mysql' => [
'driver' => 'mysql',
'url' => '',
'host' => '255.255.255.255',
'port' => '123',
'database' => 'yourdatabase',
'username' => 'yourusername',
'password' => 'your_p@$$word',
'unix_socket' => '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA =>
env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
Congratulations, You have successfully uploaded your Laravel
project to your cPanel.
To make your project secure and protect your .htaccess and .env
files, open the .htaccess file from the public_html folder and
write the following code to disable direct access and directory
browsing:
Copy this:
#disable directory browsing
Options – Indexes
#PROTECT ENV FILE
<Files .env>
Order allow,deny
Deny from all
</Files>
#PROTECT ENV FILE
<Files .htaccess>
Order allow,deny
Deny from all
</Files>
You have successfully deployed your Laravel Project to cPanel
and secured it from direct access and directory browsing.
Conclusion
Uploading a Laravel project on a shared hosting platform can be
difficult, but it is not impossible. In this article, we have
successfully uploaded your first Laravel project to cPanel.
Source - https://www.hostitsmart.com/manage/knowledgebase/228/How-to-
upload-Laravel-Project-on-Shared-Hosting-With-cPanel.html
How to upload Laravel Project on Shared Hosting With CPanel.pdf

More Related Content

Similar to How to upload Laravel Project on Shared Hosting With CPanel.pdf

Mantis Installation for Windows Box
Mantis Installation for Windows BoxMantis Installation for Windows Box
Mantis Installation for Windows Boxguest34a3a419
 
Mantis Installation for Windows Box
Mantis Installation for Windows BoxMantis Installation for Windows Box
Mantis Installation for Windows BoxJayanta Dash
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentationToufiq Mahmud
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroChristopher Pecoraro
 
php-and-zend-framework-getting-started
php-and-zend-framework-getting-startedphp-and-zend-framework-getting-started
php-and-zend-framework-getting-startedtutorialsruby
 
php-and-zend-framework-getting-started
php-and-zend-framework-getting-startedphp-and-zend-framework-getting-started
php-and-zend-framework-getting-startedtutorialsruby
 
php-and-zend-framework-getting-started
php-and-zend-framework-getting-startedphp-and-zend-framework-getting-started
php-and-zend-framework-getting-startedtutorialsruby
 
php-and-zend-framework-getting-started
php-and-zend-framework-getting-startedphp-and-zend-framework-getting-started
php-and-zend-framework-getting-startedtutorialsruby
 
Hands on Docker - Launch your own LEMP or LAMP stack
Hands on Docker -  Launch your own LEMP or LAMP stackHands on Docker -  Launch your own LEMP or LAMP stack
Hands on Docker - Launch your own LEMP or LAMP stackDana Luther
 
Step by step guide for creating wordpress plugin
Step by step guide for creating wordpress pluginStep by step guide for creating wordpress plugin
Step by step guide for creating wordpress pluginMainak Goswami
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesGerald Villorente
 
How to use_000webhost
How to use_000webhostHow to use_000webhost
How to use_000webhostIIUM
 
Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress Maurizio Pelizzone
 

Similar to How to upload Laravel Project on Shared Hosting With CPanel.pdf (20)

Mantis Installation for Windows Box
Mantis Installation for Windows BoxMantis Installation for Windows Box
Mantis Installation for Windows Box
 
Mantis Installation for Windows Box
Mantis Installation for Windows BoxMantis Installation for Windows Box
Mantis Installation for Windows Box
 
Its3 Drupal
Its3 DrupalIts3 Drupal
Its3 Drupal
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentation
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
 
PHP
PHP PHP
PHP
 
php-and-zend-framework-getting-started
php-and-zend-framework-getting-startedphp-and-zend-framework-getting-started
php-and-zend-framework-getting-started
 
php-and-zend-framework-getting-started
php-and-zend-framework-getting-startedphp-and-zend-framework-getting-started
php-and-zend-framework-getting-started
 
php-and-zend-framework-getting-started
php-and-zend-framework-getting-startedphp-and-zend-framework-getting-started
php-and-zend-framework-getting-started
 
php-and-zend-framework-getting-started
php-and-zend-framework-getting-startedphp-and-zend-framework-getting-started
php-and-zend-framework-getting-started
 
Hands on Docker - Launch your own LEMP or LAMP stack
Hands on Docker -  Launch your own LEMP or LAMP stackHands on Docker -  Launch your own LEMP or LAMP stack
Hands on Docker - Launch your own LEMP or LAMP stack
 
Step by step guide for creating wordpress plugin
Step by step guide for creating wordpress pluginStep by step guide for creating wordpress plugin
Step by step guide for creating wordpress plugin
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, Terminologies
 
Lampstack (1)
Lampstack (1)Lampstack (1)
Lampstack (1)
 
How to use_000webhost
How to use_000webhostHow to use_000webhost
How to use_000webhost
 
09 Oo Php Register
09 Oo Php Register09 Oo Php Register
09 Oo Php Register
 
Monteiro_WS
Monteiro_WSMonteiro_WS
Monteiro_WS
 
Monteiro_WS
Monteiro_WSMonteiro_WS
Monteiro_WS
 
Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress
 
instaling
instalinginstaling
instaling
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

How to upload Laravel Project on Shared Hosting With CPanel.pdf

  • 1. How to upload Laravel Project on Shared Hosting With cPanel? Uploading a Laravel project to a shared hosting platform like cPanel can be difficult. You may already have tried doing so and failed. This is mainly because most shared hosting platforms don’t provide an SSH terminal which is crucial to run PHP artisan commands like; PHP artisan cache: clear, PHP artisan storage: link, etc. And cPanel is one of them. Enough about the problem; let us look at the solution and upload your Laravel project step-by-step. Step I: Remove the public from the URL First, you’ll have to remove the public word from the URL in our Laravel project so that you don’t need the PHP artisan command to access your Laravel project and access it as a normal PHP project. It is a simple task to perform; you just have to: o Move the index.php and .htaccess files from the project public folder to the project root directory. o Open the index.php file and change line 24 to “require _DIR_.‘/vendor/autoload.php’;” and line 38 to “$app = require_once _DIR_.‘/bootstrap/app.php’;” As the public word has been removed from the URL, we have added the public word in the asset helper method where the CSS, JS, or image file is linked. For Example, asset(‘css/style.css’) will become an asset(‘public/css/style.css’) What is FTP & How to Create an FTP Account In cPanel? Step II: Open your database using your MySQL client, export it, and save it to your PC. Step III: Compress your Laravel project files into a ZIP file. If git, node_modules folders exist in your Laravel project, be sure not to add them in the zip file.
  • 2. How to Add a New Domain To Cpanel? Step IV: Login to your cPanel Create a database & user. (Make sure to save the database name, user, and password into a text file in a safe place.)
  • 3.  Add New User  Add User to Database Step V: Go to the phpMyAdmin tab and select the database we have created in ‘Step IV’. Now go to the import tab and import the database file we have exported in ‘Step II’.
  • 4. How To Install WordPress On VPS Hosting Step VI: Open your File Manager in cPanel and upload the ZIP file of your Laravel project into the public_html directory and extract the ZIP file. The ZIP file should be uploaded and extracted directly in the public_html folder and not inside any subfolder.
  • 5. Move an email account from one cPanel server to another Step VII: Now update your database details into the config file by opening the database.php file from the config folder and updating your database name, username and password into the database.php file. Now save the file. (Any sensitive credentials should not be uploaded in the env file in shared hosting.)
  • 6. Copy this & modify the details: 'mysql' => [ 'driver' => 'mysql', 'url' => '', 'host' => '255.255.255.255', 'port' => '123', 'database' => 'yourdatabase', 'username' => 'yourusername', 'password' => 'your_p@$$word', 'unix_socket' => '', 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], Congratulations, You have successfully uploaded your Laravel project to your cPanel. To make your project secure and protect your .htaccess and .env files, open the .htaccess file from the public_html folder and write the following code to disable direct access and directory browsing:
  • 7. Copy this: #disable directory browsing Options – Indexes #PROTECT ENV FILE <Files .env> Order allow,deny Deny from all </Files> #PROTECT ENV FILE <Files .htaccess> Order allow,deny Deny from all </Files> You have successfully deployed your Laravel Project to cPanel and secured it from direct access and directory browsing. Conclusion Uploading a Laravel project on a shared hosting platform can be difficult, but it is not impossible. In this article, we have successfully uploaded your first Laravel project to cPanel. Source - https://www.hostitsmart.com/manage/knowledgebase/228/How-to- upload-Laravel-Project-on-Shared-Hosting-With-cPanel.html