I am the designer for a small business and I have been tasked with trying to get a Laravel project to work on the customer's server. I am not a PHP expert and only know a small amount - I've taken this on at very short notice due to a very tight deadline and my clients inability to find anyone else at such short notice.
I have attempted a Google search but nothing seemed to help. The file structure of the cPanel is as follows:
All of which is inside the handymans-hardware.co.uk folder. When I navigate to the domain root I can just see the file tree and when navigating to root/public in the browser I get an error. How can I set this up? It seems the developer that built this didn't set it up correctly and has caused some issues.
Here is the error:
Line 50 of index.php is $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
When uploading Laravel to cPanel there are some few things you have to note
is your hosting provider having php 7.2 enabled
are your files in the public html directory
copy every thing in the public directory of your Laravel application and paste them at your root directory
if you have done that then check your index.php file that have now been moved to the root directory and do this
look for this lines of code in the index.php
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
Then edit those two above to this
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
If you are still confused view this video tutorial: Youtube Upload Laravel to cpanel
Looking at the screen shots, it appears you did not upload the site content to public_html?, I could be wrong, but upload what you have inside of the project folder "handymans-hardware.co.uk" directly to public_html (seems simple and you may have done this, but thought I would ask)
Appears there is some SQL table errors triggered as well navigating to: http://www.handymans-hardware.co.uk/shop
Related
Hello everyone i am new to laravel and i hope someone can help me about my problem. I created a laravel project. After that I import it to cpanel using softaculous. Then, I made some changes base on what i research in the net to avoid showing important file like .env . I created a folder relative to public_html, let say the folder name is 'tamangbilang' where i put almost all of my code except the index.php. Inside my public_html folder, I have another folder named as 'tamangbilang' where my index.php resides. I have followed this instruction https://dev.to/pushpak1300/deploying-laravel7-app-on-shared-hosting-hostinger-31cj the only difference is that I put another folder inside public_html.I also did some changes on the index.php code
require __DIR__.'/../../tamangbilang/vendor/autoload.php';
$app = require_once __DIR__.'/../../tamangbilang/bootstrap/app.php';
Everything is working fine on my login page(my first page) but when I try to login, an error occur.
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
It seems like the connection between routes was lost. I did further testing and I notice that the code is working well only if there is an index.php, before the route in the url. example
http://my-sample-domain.org/tamangbilang/index.php/login
P.S. I don't have access for ssh.
go to bootstrap folder & open cache folder then delete config. after that please check your routes this error basically arises due to routes not found for that go to your project installed on local and write php artisan route: list check if the route is present or not.
I have project on localhost and I Need someone can help me to deploy lumen framework to hosting, i have been search in google for deploy lumen but i just found deploy laravel, maybe laravel and lumen is the same framework but i don't know how to deploy the lumen framework to my shared hosting in subdomain.
I have be been upload to :
/home/usernamecpanel/lumen
and public folder i put to my subdomain like
/home/usernamecpanel/public_html/subdomain/index.php
/home/usernamecpanel/public_html/subdomain/.htaccess
but i just got error 500.
oh, before i run i have been edit index.php to directing to lumenproject :
$app = require __DIR__.'/../../lumen/bootstrap/app.php';
I really confuse and i have been search in few day but cannot found the solution, i think someone can help me.
thank you.
Thanks for reviewing my edit
How to Fix it?
Zipping your Lumen Project
Go to your shared hosting file manager
I assume your shared hosting file manager have this directory structure like /home/username/public_html.
Create a folder outside public_html or htdocs, the folder name is up to you, example "myfolder" the structure looks like /home/username/myfolder
Upload your project to the new folder you have been created and unzip.
After unzip, inside the "myfolder" there is a folder named "public", move the contents inside to
For Main Domain
/home/username/public_html
For Subdomain or Subfolder
/home/username/public_html/sub
After moving those files, edit the index.php inside /home/username/public_html or /home/username/public_html/sub
Inside the file you see this code
$app = require __DIR__.'/../bootstrap/app.php';
change the code to
For Main Domain
$app = require __DIR__.'/../myfolder/bootstrap/app.php';
For Sub Domain/Subfolder
$app = require __DIR__.'/../../myfolder/bootstrap/app.php';
Don't forget to edit the APP_URL in .env file inside "myfolder"
Example the APP_URL .env file
APP_URL=http://yourdomain.com or http://sub.yourdomain.com or http://yourdomain.com/sub
I not got any answer from stackoverflow, and doesn't one onswer my question in stackoverflow, so i try hard find own solution with manual upload my lumen application in my shared hosting.
just put your lumen application in outside public_html and put your index.php file to subdomain and edit index.php set route to your subdomain.
if anyone have problem like me and read this question, you can ask from this question, i will help you if i got notice from this page.
You will need to move it with FileZilla to a subfolder inside /var/www/html/foldername and set configuration to the directory, but I wouldn't recommend you to set up a Micro Service in Shared host.
I made a laravel project on my localserver. I just copy the project folder and pasted on my web server in public_html folder. It's giving an error when i open it.
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Can anyone please let me know step by step how to put my laravel project on web serve?
Well there are three ways to upload and make workable on shared hosting which I came to know.
Rename server.php file to index.php (which is not the correct way)
Shift public/* to root (also, its not the correct way)
Need to add a line in public/index.php after initialization of $app
$app->bind('path.public', function() {
return _DIR_;
});
and that's proper way as per my knowledge.
(My last answer was deleted before I could submit my edits, so here's another, more complete answer)
There is an easy answer, and a long answer.
Long answer
The most important part to know is that the only part of Laravel that should be accessible to the public is in the public folder. Which means that, on your shared host, the content of public should reside in whatever folder is the public on your host (they usually are named "www", or "public_html", but it can be anything, really).
I'm going to assume here that you have only one project on your account and say that, if it's the case, you now only need to upload every other file and folder at the same level as the public folder you have and set the correct permission to the storage folder.
In the end, if the only thing you do is upload all of your project to the root folder of your account, then rename Laravel's public folder to public_html, this is supposed to work (of course, assuming that you can also use the CLI and call artisan and composer commands).
Easy answer
If you can use the command line and create synlinks on your host, you can simplify your life by uploading all of your project into a folder outside of the public_html folder and symlink public to your public_html like so: ln -s /full/path1/project/public /full/path/to/public_html
Detailed answer and more tips
You can read this article that goes into more detail and gives commands to achieve everything. I tried to keep my answer as concise as possible, so if you want a more step by step approach, this link or a bit of google searching will do the trick!
I'm trying to remove the public/index from laravel url, since this is one of the common question so there are lot of tutorials and answer. I also searched about this and followed the #rimon.ekjon answer which is working fine for me it's pretty simple.
Rename the server.php in the your Laravel root folder to index.php and copy the .htaccess file from /public directory to your Laravel root folder. -- Thats it !! :)
I'm confuse why i should rename or move something from one place to another because there will be a reason why files exist in public folder. I want to show another good answer which is also following the almost same pattern.
I'm thinking that by following above answers' step may be create some issues in future if there will be a new requirement or new feature request in the project.
So can anyone guide me is there any best to rewrite or remove the public/index from laravel 5. I would like to appreciate if someone guide me.
You should configure your web server's document / web root to be the public directory. That way you don't have to copy/move/delete anything.
For apache you can look here.
For nginx you can read here.
I've visited your link and saw really terrible advices.
You do no need to move any Laravel files or modify them. What you need is to setup web server. You need to point it to a public directory which is inside Laravel project root folder.
Please look here for an example config directives for Apache and nginx.
One other option is to symlink the public folder to your server's root folder (e.g. /var/www/). This article is a great guide on how to do this.
On your dev environment however you can use php artisan serve.
In case, if you don't have access to you server config, this is a perfect solution https://stackoverflow.com/a/32580688/5015089 .
Remove public from url without htaccess. It will work on laravel latest versions also.
step 1. Copy all files from public and paste on root directory
step 2. Open index.php file remove ../ from path as given below
Laravel5:
require __DIR__.'/../bootstrap/autoload.php';
to
require __DIR__.'/bootstrap/autoload.php';
and
require_once __DIR__.'/../bootstrap/app.php';
to
$app = require_once __DIR__.'/bootstrap/app.php';
Laravel 7:
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
I have a problem when upload laravel project on my shared hosting. On that hosting I have two addon domains with separate folders in document root. But when I put laravel project in document root and move everything from public folder in root to remove that "/public" from url, I cant access to my addon domains. I'm getting 500 Internal service error. When I remove .htaccess file I can access to my other domains, but I can't access to my Laravel project. How can I change default laravel .htaccess file?
Well, you should not move everything from public folder, this is a very important part of your Laravel application, it was built this way to separate your application source code from the public files anyone can access, if you make your application root also your public folder, anyone will be able to access any php files from your application, and this is so unsafe...
What you need to do is to point your document root to /serverRoot/applicationRoot/public.
If you really cannot do that, I'm afraid you'll have to edit index.php and try to change thos two lines:
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/start.php';
to
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/start.php';
And see if it works for you.
EDIT
Laravel's default .htaccess file is there just for rewriting your URLs, so you dont see aindex.php` on them. Basically it does 2 things:
1) If you access your site using http://www.site.com/, internally it will point to http://www.site.com/index.php.
2) When you access your site using http://www.site.com/index.php it hides the index.php part.
This is kind of recursive, because the first step leads to the second one.
Now you have to think and see how this is conflicting with your other domains, because the files you are serving in those domains matters and since we are not aware of what they are, helping more is kind of difficult.