Laravel Shared Hosting: Difference between revisions
Line 36: | Line 36: | ||
== Remove Public == | == Remove Public == | ||
The artisan {{FormFCTW|8|blue|bold|php artisan serve}} command is not possible. | The artisan {{FormFCTW|8|blue|bold|php artisan serve}} command is not possible on the Share Host. | ||
<br>Removing the {{FormFCTW|8|blue|bold|public}} word from the URL enables access of your Laravel project as normal PHP-project. The actions are: | <br>Removing the {{FormFCTW|8|blue|bold|public}} word from the URL enables access of your Laravel project as normal PHP-project. The actions are: | ||
* Create a deployment of the project | * Create a deployment of the project | ||
** Use BC to make the first clone of the DT → AP environment <br> | ** Use <abbr title="Beyond Compare">BC</abbr> to make the first clone of the <abbr title="Development-Test">DT</abbr> → <abbr title="Acceptance/Production">AP</abbr> environment <br>without the .git-folders. | ||
* On AP-environment: | * On <abbr title="Acceptance/Production environment">AP-environment</abbr>: | ||
** Cut the {{FormFCTW|9|blue|bold|index.php}} and {{FormFCTW|9|blue|bold|.htaccess}} from the project {{FormFCTW|9|green|bold|public}} folder and paste them into the project {{FormFCTW|8|blue|bold|root}} directory. | ** Cut the {{FormFCTW|9|blue|bold|index.php}} and {{FormFCTW|9|blue|bold|.htaccess}} from the project {{FormFCTW|9|green|bold|public}} folder and paste them into the project {{FormFCTW|8|blue|bold|root}} directory. | ||
** Open {{FormFCTW|9|blue|bold|index.php}} and make the following changes: | ** Open {{FormFCTW|9|blue|bold|index.php}} and make the following changes: |
Revision as of 13:17, 13 July 2022
Laravel is not suited for Shared Hosting Servers. However it is possible according an article on Laravel Article [1]
This article focuses on the shared hosting on One Hosting [2]
Introduction
Shared hosting is very popular (Budget hosting), but will not provide the user from ssh access. On One you have ssh access, but the possibility of running commands is limited.
Welcome on the One.com SSH service This service offers an environment for you to interact with your files in your web space, either directly using your shell, or by using secure file transfer protocols such as SFTP, SCP, RSYNC over SSH. ...
So you can not deploy or run artisan commands like php artisan serve.
Important differences in the steps and actions on an ITIL based development environment.
- Using an DTAP (Develop, Test, Acceptance, Production) environment changes the way to do the required actions.
- In this article we do and the Acceptance (Local environment is equal to the Production env).
- ZIP is not used, instead the D/T-environment is compared with the A/P-environment.
- Beyond Compare (BC or any other diff tool) is used to make the necessary changes.
- Filezilla (Fz) to make the changes on the Production environment using SFTP.
- Please note that the required changes to make Laravel running are only made on A/P-environment.
Deployment Steps
- Remove the public from the URL.
- Export database from the local environment.
- Do ZIP your Laravel project.
- Create a database in your cPanel.
- Import the local exported database into a shared hosting database.
- Upload project ZIP file to public_html folder and extract.
- Update database details into the config file.
- Some security setup.
Remove Public
The artisan php artisan serve command is not possible on the Share Host.
Removing the public word from the URL enables access of your Laravel project as normal PHP-project. The actions are:
- Create a deployment of the project
- Use BC to make the first clone of the DT → AP environment
without the .git-folders.
- Use BC to make the first clone of the DT → AP environment
- On AP-environment:
- Cut the index.php and .htaccess from the project public folder and paste them into the project root directory.
- Open index.php and make the following changes:
- Change the line containing autoload into require __DIR__.'/vendor/autoload.php';
- Change the line containing bootstrap into $app = require_once __DIR__.'/bootstrap/app.php';
Please check if your app is using the public on other places!
Export Database
Exports the schema/tables of your local Database into a uploadable file.
ZIP or SFTP Files
There are 2 options:
- Create a ZIP from the entire project files without the .git folder(s).
or
- Use Beyond compare
- Filezilla (or equivalent SFTP tool) and
Create Database
Import Database
Upload Files
Update Database Details
Security setup
See also
Reference
- ↑ https://laravelarticle.com/deploy-laravel-on-shared-hosting LaravelArticle], Deploy Laravel on shared hosting.
- ↑ One.com, Shared Hosting Provider.